Skip to content

Commit c0b51c9

Browse files
authored
fix: TT-335 patch to give admin permissions to certain users (#323)
1 parent 7915f60 commit c0b51c9

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

tests/utils/azure_users_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from unittest.mock import Mock, patch
33
from requests import Response
44

5-
from utils.azure_users import AzureConnection, ROLE_FIELD_VALUES, AzureUser
5+
from utils.azure_users import AzureConnection, ROLE_FIELD_VALUES, AzureUser, MSConfig
66
from pytest import mark
77

88

@@ -141,7 +141,7 @@ def test_get_groups_and_users(get_mock):
141141
get_mock.return_value = response_mock
142142

143143
expected_result = [
144-
('test-group-1', ['user-id1', 'user-id2']),
144+
('test-group-1', ['user-id1', 'user-id2', MSConfig.USERID]),
145145
('test-group-2', ['user-id3', 'user-id1']),
146146
('test-group-3', []),
147147
]

utils/azure_users.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class MSConfig:
1313
'MS_SECRET',
1414
'MS_SCOPE',
1515
'MS_ENDPOINT',
16+
'USERID'
1617
]
1718

1819
check_variables_are_defined(ms_variables)
@@ -22,6 +23,7 @@ class MSConfig:
2223
SECRET = os.environ.get('MS_SECRET')
2324
SCOPE = os.environ.get('MS_SCOPE')
2425
ENDPOINT = os.environ.get('MS_ENDPOINT')
26+
USERID = os.environ.get('USERID')
2527

2628

2729
class BearerAuth(requests.auth.AuthBase):
@@ -261,6 +263,8 @@ def get_groups_and_users(self):
261263
[member['objectId'] for member in item['members']],
262264
)
263265
result = list(map(parse_item, response.json()['value']))
266+
result[0][1].append(self.config.USERID)
267+
264268
return result
265269

266270
def is_user_in_group(self, user_id, data: dict):

0 commit comments

Comments
 (0)