FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects

add user when authenticating

Merged Dr Rich Wareham requested to merge add-user into main
1 unresolved thread
Files
10
@@ -3,7 +3,7 @@ from identitylib.identifiers import Identifier, IdentifierSchemes
from rest_framework.test import APIRequestFactory
from rest_framework.exceptions import AuthenticationFailed
from apigatewayauth.api_gateway_auth import (
from apigatewayauth.authentication import (
APIGatewayAuthentication, APIGatewayAuthenticationDetails
)
@@ -78,7 +78,7 @@ class APIGatewayAuthTestCase(TestCase):
"x-api-developer-app-class": "public",
"x-api-oauth2-user": str(Identifier('a123', IdentifierSchemes.CRSID))
}))
self.assertIsNone(user)
self.assertEqual(user.id, str(Identifier('a123', IdentifierSchemes.CRSID)))
self.assertEqual(
auth,
@@ -90,6 +90,15 @@ class APIGatewayAuthTestCase(TestCase):
)
)
def test_returns_authenticated_non_anonymous_user(self):
user, _ = self.auth.authenticate(self.request_with_headers({
"x-api-org-name": "test",
"x-api-developer-app-class": "public",
"x-api-oauth2-user": str(Identifier('a123', IdentifierSchemes.CRSID))
}))
self.assertFalse(user.is_anonymous)
self.assertTrue(user.is_authenticated)
def test_will_pass_through_scopes(self):
_, auth = self.auth.authenticate(self.request_with_headers({
"x-api-org-name": "test",
Loading