예제 #1
0
def test_validate_jwt_with_wrong_audience(jwt_payload):
    signed_jwt = create_signed_jwt_with_claims(
        get_resource_content("key/private_key_from_cert.pem"), jwt_payload)

    with pytest.raises(InvalidAudienceError):
        validate_jwt(
            signed_jwt,
            get_resource_content("cert/certificate_from_private_key.cert"),
            "wrong audience")
예제 #2
0
def test_validate_jwt(jwt_payload):
    signed_jwt = create_signed_jwt_with_claims(
        get_resource_content("key/private_key_from_cert.pem"), jwt_payload)

    claims = validate_jwt(
        signed_jwt,
        get_resource_content("cert/certificate_from_private_key.cert"),
        AUDIENCE)
    assert claims == jwt_payload
예제 #3
0
def test_validate_jwt_with_invalid_jwt():
    with pytest.raises(AuthInitializationError):
        validate_jwt(
            "invalid jwt",
            get_resource_content("cert/certificate_from_private_key.cert"),
            AUDIENCE)
예제 #4
0
def test_validate_jwt_with_invalid_cert(jwt_payload):
    with pytest.raises(AuthInitializationError):
        signed_jwt = create_signed_jwt_with_claims(
            get_resource_content("key/private_key_from_cert.pem"), jwt_payload)
        validate_jwt(signed_jwt, "invalid cert content", AUDIENCE)
def test_validate_jwt_with_invalid_jwt(certificate):
    with pytest.raises(AuthInitializationError):
        validate_jwt("invalid jwt", certificate, AUDIENCE)
def test_validate_jwt_with_invalid_cert(jwt_payload, rsa_key):
    signed_jwt = create_signed_jwt_with_claims(rsa_key, jwt_payload)

    with pytest.raises(AuthInitializationError):
        validate_jwt(signed_jwt, "invalid cert content", AUDIENCE)
def test_validate_jwt_with_wrong_audience(jwt_payload, certificate, rsa_key):
    signed_jwt = create_signed_jwt_with_claims(rsa_key, jwt_payload)

    with pytest.raises(InvalidAudienceError):
        validate_jwt(signed_jwt, certificate, "wrong audience")
def test_validate_jwt(jwt_payload, certificate, rsa_key):
    signed_jwt = create_signed_jwt_with_claims(rsa_key, jwt_payload)

    claims = validate_jwt(signed_jwt, certificate, AUDIENCE)
    assert claims == jwt_payload