Example #1
0
def test_testing_wont_refresh_keys(flask_app: Flask, requests_mock: Mocker):
    flask_app.config["AUTH0_TESTING"] = True
    auth0_endpoint_mock = requests_mock.get(
        "https://perdu.auth0.com/.well-known/jwks.json")
    Auth0Authenticator(flask_app)

    assert auth0_endpoint_mock.call_count == 0
Example #2
0
def test_refresh_keys_failure(requests_mock: Mocker, flask_app: Flask):
    requests_mock.get(
        "https://perdu.auth0.com/.well-known/jwks.json",
        exc=requests.exceptions.ConnectTimeout,
    )
    authenticator = Auth0Authenticator(flask_app)
    assert authenticator.keys == {}
Example #3
0
def test_testing_add_key(flask_app: Flask, requests_mock: Mocker,
                         sign_key: Dict[str, Any]):
    flask_app.config["AUTH0_TESTING"] = True
    auth0_endpoint_mock = requests_mock.get(
        "https://perdu.auth0.com/.well-known/jwks.json")
    authenticator = Auth0Authenticator(flask_app)
    assert not authenticator.keys

    authenticator.add_key(sign_key)
    assert authenticator.keys
Example #4
0
def authenticator(flask_app: Flask, requests_mock: Mocker,
                  keys: Dict[str, str]) -> Auth0Authenticator:
    requests_mock.get("https://perdu.auth0.com/.well-known/jwks.json",
                      json=keys)
    return Auth0Authenticator(flask_app)
Example #5
0
def test_missing_authentication(flask_app: Flask):
    with pytest.raises(
            Exception,
            match=r"Must specify at least one method of authentication"):
        flask_app.config["AUTH0_HEADER_AUTHENTICATION"] = False
        Auth0Authenticator(flask_app)