@@ -265,6 +265,50 @@ describe('SsoAccessTokenProvider', function () {
265265 assert . notDeepStrictEqual ( await sut . getToken ( ) , cachedToken )
266266 } )
267267
268+ it ( `emits session duration between logins of the same startUrl` , async function ( ) {
269+ setupFlow ( )
270+ stubOpen ( )
271+
272+ await sut . createToken ( )
273+ clock . tick ( 5000 )
274+ await sut . createToken ( )
275+ clock . tick ( 10_000 )
276+ await sut . createToken ( )
277+
278+ // Mimic when we sign out then in again with the same region+startUrl. The ID is the only thing different.
279+ sut = SsoAccessTokenProvider . create (
280+ { region, startUrl, identifier : 'bbb' } ,
281+ cache ,
282+ oidcClient ,
283+ reAuthState ,
284+ ( ) => true
285+ )
286+ await sut . createToken ( )
287+
288+ assertTelemetry ( 'aws_loginWithBrowser' , [
289+ {
290+ credentialStartUrl : startUrl ,
291+ awsRegion : region ,
292+ sessionDuration : undefined , // A new login.
293+ } ,
294+ {
295+ credentialStartUrl : startUrl ,
296+ awsRegion : region ,
297+ sessionDuration : 5000 , // A reauth. 5000 - 0, is the diff between this and previous login
298+ } ,
299+ {
300+ credentialStartUrl : startUrl ,
301+ awsRegion : region ,
302+ sessionDuration : 10000 , // A reauth. 15_000 - 5000 is the diff between this and previous login
303+ } ,
304+ {
305+ credentialStartUrl : startUrl ,
306+ awsRegion : region ,
307+ sessionDuration : undefined , // A new login, since we signed out of the last.
308+ } ,
309+ ] )
310+ } )
311+
268312 it ( 'respects the device authorization expiration time' , async function ( ) {
269313 // XXX: Don't know how to fix this "unhandled rejection" caused by this test:
270314 // rejected promise not handled within 1 second: Error: Timed-out waiting for browser login flow to complete
0 commit comments