Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
fix TT-335 patch to give admin permissions to certain users
  • Loading branch information
bytesantiago authored and scastillo-jp committed Oct 13, 2021
commit ed3ef3044da04955afb690e5f823899e91d67f43
4 changes: 2 additions & 2 deletions tests/utils/azure_users_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from unittest.mock import Mock, patch
from requests import Response

from utils.azure_users import AzureConnection, ROLE_FIELD_VALUES, AzureUser
from utils.azure_users import AzureConnection, ROLE_FIELD_VALUES, AzureUser, MSConfig
from pytest import mark


Expand Down Expand Up @@ -141,7 +141,7 @@ def test_get_groups_and_users(get_mock):
get_mock.return_value = response_mock

expected_result = [
('test-group-1', ['user-id1', 'user-id2']),
('test-group-1', ['user-id1', 'user-id2', MSConfig.USERID]),
('test-group-2', ['user-id3', 'user-id1']),
('test-group-3', []),
]
Expand Down
4 changes: 4 additions & 0 deletions utils/azure_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class MSConfig:
'MS_SECRET',
'MS_SCOPE',
'MS_ENDPOINT',
'USERID'
]

check_variables_are_defined(ms_variables)
Expand All @@ -22,6 +23,7 @@ class MSConfig:
SECRET = os.environ.get('MS_SECRET')
SCOPE = os.environ.get('MS_SCOPE')
ENDPOINT = os.environ.get('MS_ENDPOINT')
USERID = os.environ.get('USERID')


class BearerAuth(requests.auth.AuthBase):
Expand Down Expand Up @@ -261,6 +263,8 @@ def get_groups_and_users(self):
[member['objectId'] for member in item['members']],
)
result = list(map(parse_item, response.json()['value']))
result[0][1].append(self.config.USERID)

return result

def is_user_in_group(self, user_id, data: dict):
Expand Down