-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsingle_sign_on.py
More file actions
37 lines (27 loc) · 942 Bytes
/
single_sign_on.py
File metadata and controls
37 lines (27 loc) · 942 Bytes
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
36
37
class FakeSingleSignOnRegistry:
def __init__(self):
self.tokens = set()
def register(self, credentials):
if are_valid(credentials):
toekn = SSOToken()
self.tokens.add(token)
return token
def is_valid(self, token):
return token in self.tokens
def end_session(self, token):
self.tokens.remove(token)
class MockSingleSignOnRegistry:
def __init__(self, expected_token, token_is_valid=True):
self.expected_token = expected_token
self.token_is_valid = token_is_valid
self.is_valid_was_called = False
def is_valid(self, token):
if not token == self.expected_token:
raise Exception("this mock was givnen an unexpected argument. Expected {0}\
got {1}".format(self.expected_token, token))
return self.token_is_valid
class SSOToken:
pass
def are_valid(credentials):
#check the credentials
return True