def testGetFieldsFromSequenceWhenValidityNotBeforeFail(self):
    sig_alg_seq = ('a','b')
    sig_alg = 'sigalg'
    before_ts = self.mox.CreateMockAnything()
    after_ts = self.mox.CreateMockAnything()
    mock_utctime = self.mox.CreateMockAnything()
    self.stubs.Set(x509.pyasn1.type.useful, 'UTCTime', mock_utctime)
    mock_utctime().AndReturn(mock_utctime)
    before_ts.isSameTypeWith(mock_utctime).AndReturn(False)  # fails
    serial_num = 12345
    bad_oid_cn = (9) * 10

    seq = (
        x509.X509_CERT_VERSION_3,
        serial_num,
        sig_alg_seq,
        (((x509.OID_ID['CN'], 'issuer'),),),
        (before_ts, after_ts),
        (((x509.OID_ID['CN'], 'subject'),),),
        'public key',
        'x509v3 extensions',
    )

    self.mox.StubOutWithMock(self.x, '_GetSignatureAlgorithmFromSequence')
    self.mox.StubOutWithMock(self.x, '_AssembleDNSequence')
    self.x._GetSignatureAlgorithmFromSequence(
        sig_alg_seq).AndReturn(sig_alg)
    self.x._AssembleDNSequence(seq[3]).AndReturn('CN=issuer')

    self.mox.ReplayAll()
    self.assertRaises(
        x509.CertificateParseError,
        self.x._GetFieldsFromSequence, seq)
    self.mox.VerifyAll()
Test _GetFieldsFromSequence().
dataset/ETHPy150Open google/simian/src/tests/simian/auth/x509_test.py/X509CertificateTest.testGetFieldsFromSequenceWhenValidityNotBeforeFail