Skip to content

Commit d969b5d

Browse files
committed
trying the patch fix
1 parent 8987bf5 commit d969b5d

File tree

6 files changed

+50
-8
lines changed

6 files changed

+50
-8
lines changed

buildspec/linuxE2ETests.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ env:
1313
# followed by Error: Could not delete obsolete instance handle Error: ENOENT: no such file or directory, unlink <path>
1414
AWS_TOOLKIT_TEST_CACHE_DIR: '/tmp/.vscode-test/'
1515
AWS_TOOLKIT_TEST_USER_DIR: '/tmp/.vscode-test/user-data/'
16+
AUTH_UTIL_LAMBDA_ARN
1617

1718
phases:
1819
install:
@@ -38,8 +39,9 @@ phases:
3839
build:
3940
commands:
4041
- export HOME=/home/codebuild-user
41-
# Ignore failure until throttling issues are fixed.
42-
- xvfb-run npm run testE2E; npm run mergeReports -- "$?"
42+
- export NODE_OPTIONS='--max-old-space-size=8192'
43+
- npm ci
44+
- xvfb-run npm run test:ui
4345
- VCS_COMMIT_ID="${CODEBUILD_RESOLVED_SOURCE_VERSION}"
4446
- CI_BUILD_URL=$(echo $CODEBUILD_BUILD_URL | sed 's/#/%23/g')
4547
- CI_BUILD_ID="${CODEBUILD_BUILD_ID}"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"testE2E": "npm run testE2E -w packages/ --if-present",
3131
"test:ui:prepare": "./node_modules/.bin/extest get-vscode -s ~/.vscode-test-resources -n && extest get-chromedriver -s ~/.vscode-test-resources -n",
3232
"test:ui:install": "cd packages/amazonq && npm run package 2>&1 | grep -o 'VSIX Version: [^ ]*' | cut -d' ' -f3 | xargs -I{} bash -c 'cd ../../ && ./node_modules/.bin/extest install-vsix -f amazon-q-vscode-{}.vsix -e packages/amazonq/test/e2e_new/amazonq/resources -s ~/.vscode-test-resources'",
33-
"test:ui:run": "npm run testCompile && ./node_modules/.bin/extest run-tests -s ~/.vscode-test-resources -e packages/amazonq/test/e2e_new/amazonq/resources packages/amazonq/dist/test/e2e_new/amazonq/tests/*.test.js 2>&1 | tee packages/amazonq/test/e2e_new/amazonq/logs/ui_e2e_testlog_$(date +%Y%m%d_%H%M%S).log",
33+
"test:ui:run": "npm run testCompile && ./node_modules/.bin/extest run-tests -s ~/.vscode-test-resources -e packages/amazonq/test/e2e_new/amazonq/resources packages/amazonq/dist/test/e2e_new/amazonq/tests/*.test.js",
3434
"test:ui": "npm run test:ui:prepare && npm run test:ui:install && npm run test:ui:run",
3535
"testInteg": "npm run testInteg -w packages/ --if-present",
3636
"package": "npm run package -w packages/toolkit -w packages/amazonq",

packages/amazonq/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "amazon-q-vscode",
33
"displayName": "Amazon Q",
44
"description": "The most capable generative AI–powered assistant for software development.",
5-
"version": "1.89.0-SNAPSHOT",
5+
"version": "1.89.0-g8987bf5",
66
"extensionKind": [
77
"workspace"
88
],

packages/amazonq/test/e2e_new/amazonq/utils/authUtils.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
* SPDX-License-Identifier: Apache-2.0
44
*/
5-
import { Workbench, By, WebviewView } from 'vscode-extension-tester'
6-
import { findItemByText, sleep, waitForElements } from './generalUtils'
5+
import { Workbench, By, WebviewView, until, ModalDialog } from 'vscode-extension-tester'
6+
import { findItemByText, printElementHTML, sleep, waitForElements } from './generalUtils'
77
import { testContext } from './testContext'
88

99
/* Completes the entire Amazon Q login flow
@@ -18,7 +18,6 @@ TO-DO: Currently this signInToAmazonQ is not fully autonomous as we ran into a b
1818
export async function signInToAmazonQ(): Promise<void> {
1919
const workbench = new Workbench()
2020
await workbench.executeCommand('Amazon Q: Open Chat')
21-
2221
await sleep(5000)
2322
let webviewView = new WebviewView()
2423
await webviewView.switchToFrame()
@@ -42,6 +41,21 @@ export async function signInToAmazonQ(): Promise<void> {
4241
const UrlContinue = await webviewView.findWebElement(By.css('button.continue-button.topMargin'))
4342
await UrlContinue.click()
4443

44+
/**
45+
* this is the moment that a browser should pop up, at this moment can we just call the browser auth function?
46+
*/
47+
await webviewView.switchBack()
48+
const driver = workbench.getDriver()
49+
const modalWnd = By.className('monaco-dialog-box')
50+
await driver.wait(until.elementLocated(modalWnd), 10_000)
51+
const dialog = new ModalDialog()
52+
const details = await dialog.getDetails()
53+
54+
console.log('this should be the url:', details)
55+
56+
// await dialog.pushButton('Open')
57+
58+
/** */
4559
console.log('Waiting for manual authentication...')
4660
await sleep(12000)
4761
console.log('Manual authentication should be done')
@@ -52,6 +66,8 @@ export async function signInToAmazonQ(): Promise<void> {
5266
webviewView = new WebviewView()
5367
await webviewView.switchToFrame()
5468

69+
await printElementHTML(webviewView)
70+
5571
testContext.workbench = workbench
5672
testContext.webviewView = webviewView
5773
}

packages/core/src/auth/sso/ssoAccessTokenProvider.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import { asStringifiedStack } from '../../shared/telemetry/spans'
3939
import { showViewLogsMessage } from '../../shared/utilities/messages'
4040
import _ from 'lodash'
4141
import { builderIdStartUrl } from './constants'
42+
import { invokeLambda, patchObject } from '../../test/setupUtil'
4243

4344
export const authenticationPath = 'sso/authenticated'
4445

@@ -583,6 +584,28 @@ class AuthFlowAuthorization extends SsoAccessTokenProvider {
583584
codeChallengeMethod: 'S256',
584585
})
585586

587+
getLogger().debug('AUTH LAMBDA ABOUT TO BE CALLED')
588+
const lambdaId = process.env['AUTH_UTIL_LAMBDA_ARN']
589+
if (lambdaId) {
590+
const openStub = patchObject(vscode.env, 'openExternal', async (target) => {
591+
try {
592+
const urlString = target.toString(true)
593+
const verificationUri = urlString.split('?')[0]
594+
const params = urlString.split('?')[1]
595+
const userCode = new URLSearchParams(params).get('user_code')
596+
await invokeLambda(lambdaId, {
597+
secret: 'amazonq-test-account',
598+
userCode,
599+
verificationUri,
600+
})
601+
} finally {
602+
openStub.dispose()
603+
}
604+
return true
605+
})
606+
}
607+
getLogger().debug('AUTH CALLED AFTER')
608+
586609
await vscode.env.openExternal(vscode.Uri.parse(location))
587610

588611
const authorizationCode = await authServer.waitForAuthorization()

packages/core/src/shared/settings-amazonq.gen.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ export const amazonqSettings = {
3636
"amazonQ.workspaceIndexMaxFileSize": {},
3737
"amazonQ.workspaceIndexCacheDirPath": {},
3838
"amazonQ.workspaceIndexIgnoreFilePatterns": {},
39-
"amazonQ.ignoredSecurityIssues": {}
39+
"amazonQ.ignoredSecurityIssues": {},
40+
"amazonQ.proxy.certificateAuthority": {}
4041
}
4142

4243
export default amazonqSettings

0 commit comments

Comments
 (0)