Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/msal/auth_scheme.py: 53%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

19 statements  

1try: 

2 from urllib.parse import urlparse 

3except ImportError: # Fall back to Python 2 

4 from urlparse import urlparse 

5 

6# We may support more auth schemes in the future 

7class PopAuthScheme(object): 

8 HTTP_GET = "GET" 

9 HTTP_POST = "POST" 

10 HTTP_PUT = "PUT" 

11 HTTP_DELETE = "DELETE" 

12 HTTP_PATCH = "PATCH" 

13 _HTTP_METHODS = (HTTP_GET, HTTP_POST, HTTP_PUT, HTTP_DELETE, HTTP_PATCH) 

14 # Internal design: https://identitydivision.visualstudio.com/DevEx/_git/AuthLibrariesApiReview?path=/PoPTokensProtocol/PopTokensProtocol.md 

15 def __init__(self, http_method=None, url=None, nonce=None): 

16 """Create an auth scheme which is needed to obtain a Proof-of-Possession token. 

17 

18 :param str http_method: 

19 Its value is an uppercase http verb, such as "GET" and "POST". 

20 :param str url: 

21 The url to be signed. 

22 :param str nonce: 

23 The nonce came from resource's challenge. 

24 """ 

25 if not (http_method and url and nonce): 

26 # In the future, we may also support accepting an http_response as input 

27 raise ValueError("All http_method, url and nonce are required parameters") 

28 if http_method not in self._HTTP_METHODS: 

29 raise ValueError("http_method must be uppercase, according to " 

30 "https://datatracker.ietf.org/doc/html/draft-ietf-oauth-signed-http-request-03#section-3") 

31 self._http_method = http_method 

32 self._url = urlparse(url) 

33 self._nonce = nonce 

34