forked from microsoftgraph/msgraph-sdk-python-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_auth_handler.py
More file actions
35 lines (26 loc) · 1.19 KB
/
test_auth_handler.py
File metadata and controls
35 lines (26 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# ------------------------------------
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------
import pytest
from msgraph.core.middleware.authorization import AuthorizationHandler
from msgraph.core.middleware.request_context import RequestContext
def test_context_options_override_default_scopes():
""" Test scopes found in the request context override default scopes"""
default_scopes = ['.default']
middleware_control = {
'scopes': ['email.read'],
}
request_context = RequestContext(middleware_control, {})
auth_handler = AuthorizationHandler(None, scopes=default_scopes)
auth_handler_scopes = auth_handler.get_scopes(request_context)
assert auth_handler_scopes == middleware_control['scopes']
def test_auth_handler_get_scopes_does_not_overwrite_default_scopes():
default_scopes = ['.default']
middleware_control = {
'scopes': ['email.read'],
}
request_context = RequestContext(middleware_control, {})
auth_handler = AuthorizationHandler(None, scopes=default_scopes)
auth_handler_scopes = auth_handler.get_scopes(request_context)
assert auth_handler.scopes == default_scopes