@@ -8,19 +8,37 @@ import { AWSError, Request, Service } from 'aws-sdk'
88import { version } from 'vscode'
99import { AWSClientBuilder , DefaultAWSClientBuilder } from '../../shared/awsClientBuilder'
1010import { DevSettings } from '../../shared/settings'
11- import { getClientId } from '../../shared/telemetry/util'
11+ import { getClientId , getUserAgent } from '../../shared/telemetry/util'
1212import { FakeMemento } from '../fakeExtensionContext'
1313import { FakeAwsContext } from '../utilities/fakeAwsContext'
1414import { TestSettings } from '../utilities/testSettingsConfiguration'
1515import { GlobalState } from '../../shared/globalState'
16+ import { createCodeWhispererChatStreamingClient } from '../../shared/clients/codewhispererChatClient'
17+ import { OidcClient , SsoClient } from '../../auth/sso/clients'
1618
17- describe ( 'DefaultAwsClientBuilder ' , function ( ) {
19+ describe ( 'AwsClientBuilder ' , function ( ) {
1820 let builder : AWSClientBuilder
1921
2022 beforeEach ( function ( ) {
2123 builder = new DefaultAWSClientBuilder ( new FakeAwsContext ( ) )
2224 } )
2325
26+ it ( 'service clients set user agent' , async function ( ) {
27+ const userAgent = getUserAgent ( { includePlatform : true , includeClientId : true } )
28+
29+ const cwclient = await createCodeWhispererChatStreamingClient ( 'fake-token' )
30+ assert . deepStrictEqual ( cwclient . config . customUserAgent , [ [ userAgent ] ] )
31+
32+ const oidcClient = OidcClient . create ( 'us-east-2' )
33+ assert . deepStrictEqual ( oidcClient . client . config . customUserAgent , [ [ userAgent ] ] )
34+
35+ const ssoClient = SsoClient . create ( 'us-east-2' , { } as any )
36+ assert . deepStrictEqual ( ssoClient . client . config . customUserAgent , [ [ userAgent ] ] )
37+
38+ const awsService = await builder . createAwsService ( Service )
39+ assert . deepStrictEqual ( awsService . config . customUserAgent , userAgent )
40+ } )
41+
2442 describe ( 'createAndConfigureSdkClient' , function ( ) {
2543 it ( 'includes Toolkit user-agent if no options are specified' , async function ( ) {
2644 const service = await builder . createAwsService ( Service )
0 commit comments