Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
TT-94 feat: extract role fields as global var
  • Loading branch information
Angeluz-07 committed Jan 5, 2021
commit 275d6c5a425ad6ef034f5a1414be5f00d0a22ce9
19 changes: 10 additions & 9 deletions utils/azure_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ def __init__(self, id, name, email, role):
'Accept': 'application/json',
}

ROLE_FIELD_VALUES = {
'admin': (
'extension_1d76efa96f604499acc0c0ee116a1453_role',
'time_tracker_admin',
),
'test': ('waitforrealvalue', 'waitforrealvalue'),
}


class AzureConnection:
def __init__(self, config=MSConfig):
Expand Down Expand Up @@ -83,7 +91,7 @@ def users(self) -> List[AzureUser]:
assert 'value' in response.json()
return [self.to_azure_user(item) for item in response.json()['value']]

# TODO : DEPRECATE OR UPDATE
# TODO : DEPRECATE
def update_user_role(self, id, role):
endpoint = "{endpoint}/users/{user_id}?api-version=1.6".format(
endpoint=self.config.ENDPOINT, user_id=id
Expand Down Expand Up @@ -132,14 +140,7 @@ def update_role(self, user_id, role_id, is_grant):
return self.to_azure_user(response.json())

def get_role_data(self, role_id, is_grant=True):
ROLE_VALUES = {
'admin': (
'extension_1d76efa96f604499acc0c0ee116a1453_role',
'time_tracker_admin',
),
'test': ('waitforrealvalue', 'waitforrealvalue'),
}
field_name, field_value = ROLE_VALUES[role_id]
field_name, field_value = ROLE_FIELD_VALUES[role_id]
if is_grant:
return {field_name: field_value}
else:
Expand Down