@@ -7,16 +7,21 @@ import * as vscode from 'vscode'
77import assert from 'assert'
88import * as sinon from 'sinon'
99import { resetCodeWhispererGlobalVariables } from 'aws-core-vscode/test'
10- import { assertTelemetryCurried , getTestWindow , getTestLogger } from 'aws-core-vscode/test'
10+ import { assertTelemetryCurried , getTestWindow } from 'aws-core-vscode/test'
1111import { AuthUtil , awsIdSignIn , showCodeWhispererConnectionPrompt } from 'aws-core-vscode/codewhisperer'
12+ import { SsoAccessTokenProvider , constants } from 'aws-core-vscode/auth'
1213
1314describe ( 'showConnectionPrompt' , function ( ) {
1415 let isBuilderIdConnection : sinon . SinonStub
16+ let useDeviceFlowStub : sinon . SinonStub
1517
1618 beforeEach ( async function ( ) {
1719 await resetCodeWhispererGlobalVariables ( )
1820 isBuilderIdConnection = sinon . stub ( AuthUtil . instance , 'isBuilderIdConnection' )
1921 isBuilderIdConnection . resolves ( )
22+
23+ // Stub useDeviceFlow so we always use DeviceFlow for auth
24+ useDeviceFlowStub = sinon . stub ( SsoAccessTokenProvider , 'useDeviceFlow' ) . returns ( true )
2025 } )
2126
2227 afterEach ( function ( ) {
@@ -36,12 +41,13 @@ describe('showConnectionPrompt', function () {
3641 assert . ok ( isBuilderIdConnection )
3742 } )
3843
39- it ( 'connectToAwsBuilderId logs that AWS ID sign in was selected ' , async function ( ) {
44+ it ( 'connectToAwsBuilderId calls AuthUtil login with builderIdStartUrl ' , async function ( ) {
4045 sinon . stub ( vscode . commands , 'executeCommand' )
46+ const loginStub = sinon . stub ( AuthUtil . instance , 'login' ) . resolves ( )
4147
4248 await awsIdSignIn ( )
4349
44- const loggedEntries = getTestLogger ( ) . getLoggedEntries ( )
45- assert . ok ( loggedEntries . find ( ( entry ) => entry === 'selected AWS ID sign in' ) )
50+ assert . strictEqual ( loginStub . called , true )
51+ assert . strictEqual ( loginStub . firstCall . args [ 0 ] , constants . builderIdStartUrl )
4652 } )
4753} )
0 commit comments