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
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)
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)
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
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
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)
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