Skip to content

Commit 277da50

Browse files
Merge master into feature/web
2 parents 64380ab + 0bb858d commit 277da50

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

src/test/setupUtil.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { getLogger } from '../shared/logger'
1010
import { hasKey } from '../shared/utilities/tsUtils'
1111
import { getTestWindow, printPendingUiElements } from './shared/vscode/window'
1212
import { ToolkitError, formatError } from '../shared/errors'
13+
import { proceedToBrowser } from '../auth/sso/model'
1314

1415
const runnableTimeout = Symbol('runnableTimeout')
1516

@@ -56,8 +57,14 @@ export function setRunnableTimeout(test: Mocha.Runnable, maxTestDuration: number
5657
}
5758

5859
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+
}
6168

6269
if (test) {
6370
test.title += ` (skipped${reason ? ` - ${reason}` : ''})`
@@ -203,7 +210,7 @@ function maskArns(text: string) {
203210
*/
204211
export function registerAuthHook(secret: string, lambdaId = process.env['AUTH_UTIL_LAMBDA_ARN']) {
205212
return getTestWindow().onDidShowMessage(message => {
206-
if (message.items[0].title.match(/Copy Code/)) {
213+
if (message.items[0].title.match(new RegExp(proceedToBrowser))) {
207214
if (!lambdaId) {
208215
const baseMessage = 'Browser login flow was shown during testing without an authorizer function'
209216
if (process.env['AWS_TOOLKIT_AUTOMATION'] === 'local') {
@@ -215,10 +222,17 @@ export function registerAuthHook(secret: string, lambdaId = process.env['AUTH_UT
215222

216223
const openStub = patchObject(vscode.env, 'openExternal', async target => {
217224
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+
218232
await invokeLambda(lambdaId, {
219233
secret,
220-
userCode: await vscode.env.clipboard.readText(),
221-
verificationUri: target.toString(),
234+
userCode,
235+
verificationUri,
222236
})
223237
} finally {
224238
openStub.dispose()

0 commit comments

Comments
 (0)