Пример #1
0
 def test_error_handling_in_verify_certificate_chain(self):
     self.assertRaises(ValueError,
                       self.verifier.verify_certificate_chain, [])
     certs = decode_json_bytes(EXPIRED_ASSERTION)["certificates"]
     certs = [jwt.parse(cert) for cert in certs]
     self.assertRaises(ExpiredSignatureError,
                       self.verifier.verify_certificate_chain, certs)
Пример #2
0
 def test_error_handling_in_verify_certificate_chain(self):
     self.assertRaises(ValueError,
                       self.verifier.verify_certificate_chain, [])
     certs = decode_json_bytes(EXPIRED_ASSERTION)["certificates"]
     certs = [jwt.parse(cert) for cert in certs]
     self.assertRaises(ExpiredSignatureError,
                       self.verifier.verify_certificate_chain, certs)
Пример #3
0
    def test_get_identity_assertion_handles_duration(self):
        millis = int(round(time.time() * 1000))
        bid_assertion = self.session.get_identity_assertion(
            "http://example.com", 1234)
        cert, assertion = browserid.utils.unbundle_certs_and_assertion(
            bid_assertion)
        cert = jwt.parse(cert[0]).payload
        assertion = jwt.parse(assertion).payload

        # Validate cert expiry
        ttl = round(float(cert['exp'] - millis) / 1000)
        self.assertGreaterEqual(ttl, 1230)
        self.assertLessEqual(ttl, 1260)

        # Validate assertion expiry
        ttl = round(float(assertion['exp'] - millis) / 1000)
        self.assertGreaterEqual(ttl, 1230)
        self.assertLessEqual(ttl, 1260)
Пример #4
0
    def test_get_identity_assertion_handles_duration(self):
        millis = int(round(time.time() * 1000))
        bid_assertion = self.session.get_identity_assertion(
            "http://example.com", 1234)
        cert, assertion = browserid.utils.unbundle_certs_and_assertion(
            bid_assertion)
        cert = jwt.parse(cert[0]).payload
        assertion = jwt.parse(assertion).payload

        # Validate cert expiry
        ttl = round(float(cert['exp'] - millis) / 1000)
        self.assertGreaterEqual(ttl, 1230)
        self.assertLessEqual(ttl, 1260)

        # Validate assertion expiry
        ttl = round(float(assertion['exp'] - millis) / 1000)
        self.assertGreaterEqual(ttl, 1230)
        self.assertLessEqual(ttl, 1260)
 def test_error_jwt_with_mismatched_algorithm(self):
     pub, priv = get_keypair("TEST")
     token = jwt.generate({}, priv)
     token = jwt.parse(token)
     pub["algorithm"] = "RS"
     self.assertFalse(token.check_signature(pub))
Пример #6
0
 def parse_jwt(self, data):
     return jwt.parse(data)
Пример #7
0
 def parse_jwt(self, data):
     return jwt.parse(data)
Пример #8
0
 def parse_jwt(self, data):
     return jwt.parse(data, self.parser_cls)
Пример #9
0
 def parse_jwt(self, data):
     return jwt.parse(data, self.parser_cls)
Пример #10
0
 def test_error_jwt_with_mismatched_algorithm(self):
     pub, priv = get_keypair("TEST")
     token = jwt.generate({}, priv)
     token = jwt.parse(token)
     pub["algorithm"] = "RS"
     self.assertFalse(token.check_signature(pub))