MCPcopy
hub / github.com/authlib/authlib / test_scope_operator

Function test_scope_operator

tests/django/test_oauth2/test_resource_protector.py:104–124  ·  view source on GitHub ↗
(factory, token)

Source from the content-addressed store, hash-verified

102
103
104def test_scope_operator(factory, token):
105 @require_oauth(["profile email"])
106 def operator_and(request):
107 user = request.oauth_token.user
108 return JsonResponse(dict(sub=user.pk, username=user.username))
109
110 @require_oauth(["profile", "email"])
111 def operator_or(request):
112 user = request.oauth_token.user
113 return JsonResponse(dict(sub=user.pk, username=user.username))
114
115 request = factory.get("/user", HTTP_AUTHORIZATION="bearer a1")
116 resp = operator_and(request)
117 assert resp.status_code == 403
118 data = json.loads(resp.content)
119 assert data["error"] == "insufficient_scope"
120
121 resp = operator_or(request)
122 assert resp.status_code == 200
123 data = json.loads(resp.content)
124 assert data["username"] == "foo"
125
126
127def test_decorator_without_parentheses(factory, token):

Callers

nothing calls this directly

Calls 3

operator_andFunction · 0.70
operator_orFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…