Beispiel #1
0
 def get_expected_mail_time(self):
     if self.expected_mail_time is not None:
         # Variant I
         expected_mail_time = self.expected_mail_time
     else:
         # Variant II
         expected_mail_time = str(
             datetime_utc_normalize(
                 datetime.datetime.strptime(self.email_items['datetime'],
                                            self._input_dt_pattern)))
     return expected_mail_time
Beispiel #2
0
def _format_openssl_dt(dt):
    """The format of the date is YYMMDDHHMMSSZ (the same as an ASN1 UTCTime structure)

           Arg: dt <datetime>

           Ret: <string> (format YYMMDDHHMMSSZ)

           Raises: AssertionError (if format is not datetime)

    >>> naive_dt_1 = datetime.datetime(2013, 6, 6, 12, 13, 57)
    >>> _format_openssl_dt(naive_dt_1)
    '130606121357Z'

    >>> naive_dt_2 = datetime.datetime(2013, 6, 6, 12, 13, 57, 951211)
    >>> _format_openssl_dt(naive_dt_2)
    '130606121357Z'

    >>> from n6lib.datetime_helpers import FixedOffsetTimezone
    >>> tz_aware_dt = datetime.datetime(
    ...     2013, 6, 6, 14, 13, 57, 951211,   # note: 14 instead of 12
    ...     tzinfo=FixedOffsetTimezone(120))
    >>> _format_openssl_dt(tz_aware_dt)
    '130606121357Z'

    >>> _format_openssl_dt('2014-08-08 12:01:23')  # doctest: +IGNORE_EXCEPTION_DETAIL
    Traceback (most recent call last):
        ...
    TypeError: a datetime.datetime instance is required
    >>> _format_openssl_dt(None)                   # doctest: +IGNORE_EXCEPTION_DETAIL
    Traceback (most recent call last):
        ...
    TypeError: a datetime.datetime instance is required
    """
    if isinstance(dt, datetime.datetime):
        return datetime_utc_normalize(dt).strftime("%y%m%d%H%M%SZ")
    raise TypeError('a datetime.datetime instance is required')
Beispiel #3
0
def get_cert_not_before(cert):
    return datetime_utc_normalize(cert.get_not_before().get_datetime())
Beispiel #4
0
def get_cert_not_after(cert):
    return datetime_utc_normalize(cert.get_not_after().get_datetime())