Exemplo n.º 1
0
 def test_it_reads_general_time_format(self):
     dt = datetime(2018, 1, 25, 16, 1, 13, 0)
     date_format = '%Y%m%d%H%M%SZ'
     timestamp = dt.strftime(date_format).encode()
     assert signing.read_timestamp_object({'generalTime': timestamp}) == dt
Exemplo n.º 2
0
 def test_it_errors_on_unsupported_formats(self):
     with pytest.raises(signing.BadCertificate) as exc:
         signing.read_timestamp_object(
             {'unsupportedTimestamp': b'gibberish'})
     assert 'Timestamp not in expected format' in str(exc)
     assert 'unsupportedTimestamp' in str(exc)
Exemplo n.º 3
0
 def test_it_errors_on_unsupported_formats(self):
     with pytest.raises(signing.BadCertificate) as exc:
         signing.read_timestamp_object(
             {"unsupportedTimestamp": b"gibberish"})
     assert "Timestamp not in expected format" in str(exc.value)
     assert "unsupportedTimestamp" in str(exc.value)
Exemplo n.º 4
0
 def test_it_reads_general_time_format(self):
     dt = datetime(2018, 1, 25, 16, 1, 13, 0, tzinfo=pytz.UTC)
     obj = rfc5280.Time()
     obj["generalTime"] = pyasn1_useful.GeneralizedTime.fromDateTime(dt)
     assert signing.read_timestamp_object(obj) == dt
Exemplo n.º 5
0
 def test_it_reads_utc_time_format(self):
     dt = datetime(2018, 1, 25, 16, 1, 13, 0)
     date_format = "%y%m%d%H%M%SZ"
     timestamp = dt.strftime(date_format).encode()
     assert signing.read_timestamp_object({"utcTime": timestamp}) == dt
Exemplo n.º 6
0
 def test_it_errors_on_unsupported_formats(self):
     with pytest.raises(signing.BadCertificate) as exc:
         signing.read_timestamp_object({"unsupportedTimestamp": b"gibberish"})
     assert "Timestamp not in expected format" in str(exc)
     assert "unsupportedTimestamp" in str(exc)
Exemplo n.º 7
0
 def test_it_reads_general_time_format(self):
     dt = datetime(2018, 1, 25, 16, 1, 13, 0)
     date_format = "%Y%m%d%H%M%SZ"
     timestamp = dt.strftime(date_format).encode()
     assert signing.read_timestamp_object({"generalTime": timestamp}) == dt