Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions buildspec/linuxE2ETests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ env:
# followed by Error: Could not delete obsolete instance handle Error: ENOENT: no such file or directory, unlink <path>
AWS_TOOLKIT_TEST_CACHE_DIR: '/tmp/.vscode-test/'
AWS_TOOLKIT_TEST_USER_DIR: '/tmp/.vscode-test/user-data/'
AUTH_UTIL_LAMBDA_ARN: '/GitHubBot/AuthLambdaArn'

phases:
install:
Expand All @@ -38,8 +39,9 @@ phases:
build:
commands:
- export HOME=/home/codebuild-user
# Ignore failure until throttling issues are fixed.
- xvfb-run npm run testE2E; npm run mergeReports -- "$?"
- export NODE_OPTIONS='--max-old-space-size=8192'
- npm ci
- xvfb-run npm run test:ui
- VCS_COMMIT_ID="${CODEBUILD_RESOLVED_SOURCE_VERSION}"
- CI_BUILD_URL=$(echo $CODEBUILD_BUILD_URL | sed 's/#/%23/g')
- CI_BUILD_ID="${CODEBUILD_BUILD_ID}"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"testE2E": "npm run testE2E -w packages/ --if-present",
"test:ui:prepare": "./node_modules/.bin/extest get-vscode -s ~/.vscode-test-resources -n && extest get-chromedriver -s ~/.vscode-test-resources -n",
"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'",
"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",
"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",
"test:ui": "npm run test:ui:prepare && npm run test:ui:install && npm run test:ui:run",
"testInteg": "npm run testInteg -w packages/ --if-present",
"package": "npm run package -w packages/toolkit -w packages/amazonq",
Expand Down
2 changes: 1 addition & 1 deletion packages/amazonq/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "amazon-q-vscode",
"displayName": "Amazon Q",
"description": "The most capable generative AI–powered assistant for software development.",
"version": "1.89.0-SNAPSHOT",
"version": "1.89.0-g8987bf5",
"extensionKind": [
"workspace"
],
Expand Down
24 changes: 20 additions & 4 deletions packages/amazonq/test/e2e_new/amazonq/utils/authUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
import { Workbench, By, WebviewView } from 'vscode-extension-tester'
import { findItemByText, sleep, waitForElements } from './generalUtils'
import { Workbench, By, WebviewView, until, ModalDialog } from 'vscode-extension-tester'
import { findItemByText, printElementHTML, sleep, waitForElements } from './generalUtils'
import { testContext } from './testContext'

/* Completes the entire Amazon Q login flow
Expand All @@ -18,8 +18,7 @@ TO-DO: Currently this signInToAmazonQ is not fully autonomous as we ran into a b
export async function signInToAmazonQ(): Promise<void> {
const workbench = new Workbench()
await workbench.executeCommand('Amazon Q: Open Chat')

await sleep(5000)
await sleep(8000)
let webviewView = new WebviewView()
await webviewView.switchToFrame()

Expand All @@ -42,6 +41,21 @@ export async function signInToAmazonQ(): Promise<void> {
const UrlContinue = await webviewView.findWebElement(By.css('button.continue-button.topMargin'))
await UrlContinue.click()

/**
* this is the moment that a browser should pop up, at this moment can we just call the browser auth function?
*/
await webviewView.switchBack()
const driver = workbench.getDriver()
const modalWnd = By.className('monaco-dialog-box')
await driver.wait(until.elementLocated(modalWnd), 10_000)
const dialog = new ModalDialog()
const details = await dialog.getDetails()

console.log('this should be the url:', details)

// await dialog.pushButton('Open')

/** */
console.log('Waiting for manual authentication...')
await sleep(12000)
console.log('Manual authentication should be done')
Expand All @@ -52,6 +66,8 @@ export async function signInToAmazonQ(): Promise<void> {
webviewView = new WebviewView()
await webviewView.switchToFrame()

await printElementHTML(webviewView)

testContext.workbench = workbench
testContext.webviewView = webviewView
}
Expand Down
23 changes: 23 additions & 0 deletions packages/core/src/auth/sso/ssoAccessTokenProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import { asStringifiedStack } from '../../shared/telemetry/spans'
import { showViewLogsMessage } from '../../shared/utilities/messages'
import _ from 'lodash'
import { builderIdStartUrl } from './constants'
import { invokeLambda, patchObject } from '../../test/setupUtil'

export const authenticationPath = 'sso/authenticated'

Expand Down Expand Up @@ -583,6 +584,28 @@ class AuthFlowAuthorization extends SsoAccessTokenProvider {
codeChallengeMethod: 'S256',
})

getLogger().debug('AUTH LAMBDA ABOUT TO BE CALLED')
const lambdaId = process.env['AUTH_UTIL_LAMBDA_ARN']
if (lambdaId) {
const openStub = patchObject(vscode.env, 'openExternal', async (target) => {
try {
const urlString = target.toString(true)
const verificationUri = urlString.split('?')[0]
const params = urlString.split('?')[1]
const userCode = new URLSearchParams(params).get('user_code')
await invokeLambda(lambdaId, {
secret: 'amazonq-test-account',
userCode,
verificationUri,
})
} finally {
openStub.dispose()
}
return true
})
}
getLogger().debug('AUTH CALLED AFTER')

await vscode.env.openExternal(vscode.Uri.parse(location))

const authorizationCode = await authServer.waitForAuthorization()
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/shared/settings-amazonq.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ export const amazonqSettings = {
"amazonQ.workspaceIndexMaxFileSize": {},
"amazonQ.workspaceIndexCacheDirPath": {},
"amazonQ.workspaceIndexIgnoreFilePatterns": {},
"amazonQ.ignoredSecurityIssues": {}
"amazonQ.ignoredSecurityIssues": {},
"amazonQ.proxy.certificateAuthority": {}
}

export default amazonqSettings
Loading