@@ -143,38 +143,56 @@ describe('AuthUtil', async function () {
143
143
assert . strictEqual ( auth . getConnectionState ( conn ) , 'valid' )
144
144
} )
145
145
146
- it ( 'reauthenticate does NOT add missing CodeWhisperer scopes if not required to ' , async function ( ) {
147
- const conn = await auth . createConnection ( createBuilderIdProfile ( { scopes : codeWhispererCoreScopes } ) )
146
+ it ( 'reauthenticates Builder ID connection that already has all scopes ' , async function ( ) {
147
+ const conn = await auth . createInvalidSsoConnection ( createBuilderIdProfile ( { scopes : amazonQScopes } ) )
148
148
await auth . useConnection ( conn )
149
149
150
+ // method under test
150
151
await authUtil . reauthenticate ( )
151
152
152
153
assert . strictEqual ( authUtil . conn ?. type , 'sso' )
153
- assert . deepStrictEqual ( authUtil . conn ?. scopes , codeWhispererCoreScopes )
154
+ assert . deepStrictEqual ( authUtil . conn ?. scopes , amazonQScopes )
155
+ assert . strictEqual ( auth . getConnectionState ( conn ) , 'valid' )
154
156
} )
155
157
156
- it ( 'reauthenticate adds missing Builder ID scopes when explicitly required' , async function ( ) {
157
- const conn = await auth . createConnection ( createBuilderIdProfile ( { scopes : codeWhispererCoreScopes } ) )
158
+ it ( 'reauthenticates IdC connection that already has all scopes' , async function ( ) {
159
+ const conn = await auth . createInvalidSsoConnection (
160
+ createSsoProfile ( { startUrl : enterpriseSsoStartUrl , scopes : codeWhispererCoreScopes } )
161
+ )
158
162
await auth . useConnection ( conn )
159
163
160
164
// method under test
161
- await authUtil . reauthenticate ( true )
165
+ await authUtil . reauthenticate ( )
162
166
163
167
assert . strictEqual ( authUtil . conn ?. type , 'sso' )
164
168
assert . deepStrictEqual ( authUtil . conn ?. scopes , amazonQScopes )
169
+ assert . strictEqual ( auth . getConnectionState ( conn ) , 'valid' )
165
170
} )
166
171
167
- it ( 'reauthenticate adds missing Amazon Q IdC scopes when explicitly required' , async function ( ) {
168
- const conn = await auth . createConnection (
172
+ it ( 'reauthenticate adds missing Builder ID scopes' , async function ( ) {
173
+ const conn = await auth . createInvalidSsoConnection ( createBuilderIdProfile ( { scopes : codeWhispererCoreScopes } ) )
174
+ await auth . useConnection ( conn )
175
+
176
+ // method under test
177
+ await authUtil . reauthenticate ( )
178
+
179
+ assert . strictEqual ( authUtil . conn ?. type , 'sso' )
180
+ assert . deepStrictEqual ( authUtil . conn ?. scopes , amazonQScopes )
181
+ assert . strictEqual ( auth . getConnectionState ( conn ) , 'valid' )
182
+ } )
183
+
184
+ it ( 'reauthenticate adds missing Amazon Q IdC scopes' , async function ( ) {
185
+ const conn = await auth . createInvalidSsoConnection (
169
186
createSsoProfile ( { startUrl : enterpriseSsoStartUrl , scopes : codeWhispererCoreScopes } )
170
187
)
171
188
await auth . useConnection ( conn )
172
189
173
190
// method under test
174
- await authUtil . reauthenticate ( true )
191
+ await authUtil . reauthenticate ( )
175
192
176
193
assert . strictEqual ( authUtil . conn ?. type , 'sso' )
177
194
assert . deepStrictEqual ( authUtil . conn ?. scopes , amazonQScopes )
195
+ assert . strictEqual ( auth . getConnectionState ( conn ) , 'valid' )
178
196
} )
179
197
180
198
it ( 'CodeWhisperer uses fallback connection when switching to an unsupported connection' , async function ( ) {
0 commit comments