@@ -10,6 +10,7 @@ import { getLogger } from '../shared/logger'
10
10
import { hasKey } from '../shared/utilities/tsUtils'
11
11
import { getTestWindow , printPendingUiElements } from './shared/vscode/window'
12
12
import { ToolkitError , formatError } from '../shared/errors'
13
+ import { proceedToBrowser } from '../auth/sso/model'
13
14
14
15
const runnableTimeout = Symbol ( 'runnableTimeout' )
15
16
@@ -56,8 +57,14 @@ export function setRunnableTimeout(test: Mocha.Runnable, maxTestDuration: number
56
57
}
57
58
58
59
export function skipTest ( testOrCtx : Mocha . Context | Mocha . Test | undefined , reason ?: string ) {
59
- const test =
60
- testOrCtx ?. type === 'test' ? ( testOrCtx as Mocha . Test ) : ( testOrCtx as Mocha . Context | undefined ) ?. currentTest
60
+ let test
61
+
62
+ if ( testOrCtx ?. type === 'test' ) {
63
+ test = testOrCtx as Mocha . Test
64
+ } else {
65
+ const context = testOrCtx as Mocha . Context | undefined
66
+ test = context ?. currentTest ?? context ?. test
67
+ }
61
68
62
69
if ( test ) {
63
70
test . title += ` (skipped${ reason ? ` - ${ reason } ` : '' } )`
@@ -203,7 +210,7 @@ function maskArns(text: string) {
203
210
*/
204
211
export function registerAuthHook ( secret : string , lambdaId = process . env [ 'AUTH_UTIL_LAMBDA_ARN' ] ) {
205
212
return getTestWindow ( ) . onDidShowMessage ( message => {
206
- if ( message . items [ 0 ] . title . match ( / C o p y C o d e / ) ) {
213
+ if ( message . items [ 0 ] . title . match ( new RegExp ( proceedToBrowser ) ) ) {
207
214
if ( ! lambdaId ) {
208
215
const baseMessage = 'Browser login flow was shown during testing without an authorizer function'
209
216
if ( process . env [ 'AWS_TOOLKIT_AUTOMATION' ] === 'local' ) {
@@ -215,10 +222,17 @@ export function registerAuthHook(secret: string, lambdaId = process.env['AUTH_UT
215
222
216
223
const openStub = patchObject ( vscode . env , 'openExternal' , async target => {
217
224
try {
225
+ const url = new URL ( target . toString ( true ) )
226
+ const userCode = url . searchParams . get ( 'user_code' )
227
+
228
+ // TODO: Update this to just be the full URL if the authorizer lambda ever
229
+ // supports the verification URI with user code embedded (VerificationUriComplete).
230
+ const verificationUri = url . origin
231
+
218
232
await invokeLambda ( lambdaId , {
219
233
secret,
220
- userCode : await vscode . env . clipboard . readText ( ) ,
221
- verificationUri : target . toString ( ) ,
234
+ userCode,
235
+ verificationUri,
222
236
} )
223
237
} finally {
224
238
openStub . dispose ( )
0 commit comments