@@ -33,42 +33,79 @@ def parametrize(cases):
33
33
sso_provider_resolution_cases = [
34
34
{
35
35
"documentation" : "Full valid profile" ,
36
- "profile" : {
37
- "sso_region" : "us-east-1" ,
38
- "sso_start_url" : "https://d-abc123.awsapps.com/start" ,
36
+ "config" : {
37
+ "profiles" : {"test" : {"sso_session" : "admin" }},
38
+ "sso_sessions" : {
39
+ "admin" : {
40
+ "sso_region" : "us-east-1" ,
41
+ "sso_start_url" : "https://d-abc123.awsapps.com/start" ,
42
+ }
43
+ },
39
44
},
40
45
"resolves" : True ,
41
46
},
42
47
{
43
48
"documentation" : "Non-SSO profiles are skipped" ,
44
- "profile " : {"region" : "us-west-2" },
49
+ "config " : {"profiles" : { "test" : { " region" : "us-west-2" }} },
45
50
"resolves" : False ,
46
51
},
47
52
{
48
53
"documentation" : "Only start URL is invalid" ,
49
- "profile" : {"sso_start_url" : "https://d-abc123.awsapps.com/start" },
54
+ "config" : {
55
+ "profiles" : {"test" : {"sso_session" : "admin" }},
56
+ "sso_sessions" : {
57
+ "admin" : {
58
+ "sso_start_url" : "https://d-abc123.awsapps.com/start"
59
+ }
60
+ },
61
+ },
62
+ "resolves" : False ,
63
+ "expectedException" : InvalidConfigError ,
64
+ },
65
+ {
66
+ "documentation" : "Only sso_region is invalid" ,
67
+ "config" : {
68
+ "profiles" : {"test" : {"sso_session" : "admin" }},
69
+ "sso_sessions" : {"admin" : {"sso_region" : "us-east-1" }},
70
+ },
50
71
"resolves" : False ,
51
72
"expectedException" : InvalidConfigError ,
52
73
},
53
74
{
54
- "documentation" : "SSO Region only is skipped" ,
55
- "profile" : {"sso_region" : "us-east-1" },
75
+ "documentation" : "Specified sso-session must exist" ,
76
+ "config" : {
77
+ "profiles" : {"test" : {"sso_session" : "dev" }},
78
+ "sso_sessions" : {"admin" : {"sso_region" : "us-east-1" }},
79
+ },
80
+ "resolves" : False ,
81
+ "expectedException" : InvalidConfigError ,
82
+ },
83
+ {
84
+ "documentation" : "The sso_session must be specified" ,
85
+ "config" : {
86
+ "profiles" : {"test" : {"region" : "us-west-2" }},
87
+ "sso_sessions" : {
88
+ "admin" : {
89
+ "sso_region" : "us-east-1" ,
90
+ "sso_start_url" : "https://d-abc123.awsapps.com/start" ,
91
+ }
92
+ },
93
+ },
56
94
"resolves" : False ,
57
95
},
58
96
]
59
97
60
98
61
99
def _create_mock_session (config ):
62
100
mock_session = mock .Mock (spec = Session )
63
- mock_session .get_config_variable .return_value = "default "
64
- mock_session .full_config = { "profiles" : { "default" : config }}
101
+ mock_session .get_config_variable .return_value = "test "
102
+ mock_session .full_config = config
65
103
return mock_session
66
104
67
105
68
106
@parametrize (sso_provider_resolution_cases )
69
107
def test_sso_token_provider_resolution (test_case ):
70
- config = test_case ["profile" ]
71
- mock_session = _create_mock_session (config )
108
+ mock_session = _create_mock_session (test_case ["config" ])
72
109
resolver = SSOTokenProvider (mock_session )
73
110
74
111
expected_exception = test_case .get ("expectedException" )
@@ -196,8 +233,6 @@ def test_sso_token_provider_resolution(test_case):
196
233
"clientId" : "clientid" ,
197
234
"clientSecret" : "YSBzZWNyZXQ=" ,
198
235
"registrationExpiresAt" : "2022-12-25T13:30:00Z" ,
199
- # TODO: Verify if we should preserve old refresh token
200
- "refreshToken" : "cachedrefreshtoken" ,
201
236
},
202
237
"expectedToken" : {
203
238
"token" : "newtoken" ,
@@ -225,10 +260,15 @@ def test_sso_token_provider_resolution(test_case):
225
260
@parametrize (sso_provider_refresh_cases )
226
261
def test_sso_token_provider_refresh (test_case ):
227
262
config = {
228
- "sso_region" : "us-west-2" ,
229
- "sso_start_url" : "https://d-123.awsapps.com/start" ,
263
+ "profiles" : {"test" : {"sso_session" : "admin" }},
264
+ "sso_sessions" : {
265
+ "admin" : {
266
+ "sso_region" : "us-west-2" ,
267
+ "sso_start_url" : "https://d-123.awsapps.com/start" ,
268
+ }
269
+ },
230
270
}
231
- cache_key = "2b829a45f04c9828cb45b7d092d8e4aa30818393 "
271
+ cache_key = "d033e22ae348aeb5660fc2140aec35850c4da997 "
232
272
token_cache = {}
233
273
234
274
# Prepopulate the token cache
0 commit comments