Added application token for easier auth

This commit is contained in:
Agate 2020-08-19 11:41:17 +02:00
parent 0dfe633d65
commit f2e5969c44
9 changed files with 130 additions and 4 deletions

View file

@ -60,3 +60,13 @@ def test_json_webtoken_auth_verify_email_validity(
auth.authenticate(request)
should_verify.assert_called_once_with(user)
def test_app_token_authentication(factories, api_request):
user = factories["users.User"]()
app = factories["users.Application"](user=user, scope="read write")
request = api_request.get("/", HTTP_AUTHORIZATION="Bearer {}".format(app.token))
auth = authentication.ApplicationTokenAuthentication()
assert auth.authenticate(request)[0] == app.user
assert request.scopes == ["read", "write"]