1- import os
2-
31import pytest
4-
52from src .shared .clients .github import get_teams_from_github_topics
63from src .shared .clients .jit import list_assets , get_existing_teams , create_teams , add_teams_to_asset , delete_teams , \
74 get_jit_jwt_token
8- from src .shared .consts import JIT_DEFAULT_API_ENDPOINT
9- from src .shared .models import TeamAttributes , Asset , Organization , TeamStructure , Resource
5+ from src .shared .env_tools import get_jit_endpoint_base_url
6+ from src .shared .models import TeamAttributes , Asset , Organization , TeamStructure , Resource , ResourceType
107
118
129class MockRepo :
@@ -25,20 +22,22 @@ def get_topics(self):
2522 ([MockRepo ("repo1" , [])], Organization (teams = [])),
2623 ([MockRepo ("repo1" , ["topic1" ]), MockRepo ("repo2" , ["topic2" ])],
2724 Organization (teams = [
28- TeamStructure (name = "topic1" , members = [], resources = [Resource (type = "github_repo" , name = "repo1" )]),
29- TeamStructure (name = "topic2" , members = [], resources = [Resource (type = "github_repo" , name = "repo2" )])
25+ TeamStructure (name = "topic1" , members = [],
26+ resources = [Resource (type = ResourceType .GithubRepo , name = "repo1" )]),
27+ TeamStructure (name = "topic2" , members = [],
28+ resources = [Resource (type = ResourceType .GithubRepo , name = "repo2" )])
3029 ])),
3130 ([MockRepo ("repo1" , ["topic1" ]), MockRepo ("repo2" , ["topic2" ]), MockRepo ("repo3" , ["topic2" ]),
3231 MockRepo ("repo4" , ["topic1" , "topic2" ])],
3332 Organization (teams = [
3433 TeamStructure (name = "topic1" , members = [], resources = [
35- Resource (type = "github_repo" , name = "repo1" ),
36- Resource (type = "github_repo" , name = "repo4" )
34+ Resource (type = ResourceType . GithubRepo , name = "repo1" ),
35+ Resource (type = ResourceType . GithubRepo , name = "repo4" )
3736 ]),
3837 TeamStructure (name = "topic2" , members = [], resources = [
39- Resource (type = "github_repo" , name = "repo2" ),
40- Resource (type = "github_repo" , name = "repo3" ),
41- Resource (type = "github_repo" , name = "repo4" )
38+ Resource (type = ResourceType . GithubRepo , name = "repo2" ),
39+ Resource (type = ResourceType . GithubRepo , name = "repo3" ),
40+ Resource (type = ResourceType . GithubRepo , name = "repo4" )
4241 ])
4342 ])),
4443 ]
@@ -93,7 +92,7 @@ def test_get_jwt_token(status_code, expected_result, mocker):
9392 token = get_jit_jwt_token ()
9493
9594 requests_post_mock .assert_called_once_with (
96- f"{ os . getenv ( 'JIT_API_ENDPOINT' , JIT_DEFAULT_API_ENDPOINT )} /authentication/login" ,
95+ f"{ get_jit_endpoint_base_url ( )} /authentication/login" ,
9796 json = {"clientId" : None , "secret" : None }
9897 )
9998 assert token == expected_result
@@ -205,7 +204,7 @@ def test_delete_teams(mocker, status_code, existing_team_names, input_team_names
205204 expected_warning ):
206205 mock_existing_teams = [
207206 TeamAttributes (tenant_id = f"tenant{ i + 1 } " , id = str (i + 1 ), created_at = f"date{ i + 1 } " , modified_at = f"date{ i + 2 } " ,
208- name = team_name )
207+ name = team_name )
209208 for i , team_name in enumerate (existing_team_names )
210209 ]
211210
0 commit comments