Exemplo n.º 1
0
def test_verify_basic_missing_auth_header():
    def somefunc(username, password, required_scopes=None):
        return None

    wrapped_func = verify_basic(somefunc)

    request = MagicMock()
    request.headers = {"Authorization": "Bearer 123"}

    assert wrapped_func(request, ['admin']) is None
Exemplo n.º 2
0
def test_verify_basic():
    def basic_info(username, password, required_scopes=None):
        if username == 'foo' and password == 'bar':
            return {'sub': 'foo'}
        return None

    wrapped_func = verify_basic(basic_info)

    request = MagicMock()
    request.headers = {"Authorization": 'Basic Zm9vOmJhcg=='}

    assert wrapped_func(request, ['admin']) is not None