예제 #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
예제 #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)
예제 #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)
예제 #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
예제 #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
예제 #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)
예제 #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