2929using static Microsoft . Identity . Client . TelemetryCore . Internal . Events . ApiEvent ;
3030using System . Collections . Generic ;
3131using Microsoft . Identity . Client . Internal ;
32+ using Microsoft . Identity . Client . OAuth2 ;
3233
3334namespace Microsoft . Identity . Test . Unit . TelemetryTests
3435{
@@ -373,16 +374,16 @@ public async Task CallerSdkDetailsTestAsync()
373374 var cca = CreateConfidentialClientApp ( ) ;
374375
375376 await cca . AcquireTokenForClient ( TestConstants . s_scope )
376- . WithExtraQueryParameters ( new Dictionary < string , string > {
377+ . WithExtraQueryParameters ( new Dictionary < string , string > {
377378 { "caller-sdk-id" , "testApiId" } ,
378379 { "caller-sdk-ver" , "testSdkVersion" } } )
379380 . ExecuteAsync ( ) . ConfigureAwait ( false ) ;
380381
381382 AssertCurrentTelemetry (
382- requestHandler . ActualRequestMessage ,
383- ApiIds . AcquireTokenForClient ,
383+ requestHandler . ActualRequestMessage ,
384+ ApiIds . AcquireTokenForClient ,
384385 CacheRefreshReason . NoCachedAccessToken ,
385- callerSdkId : "testApiId" ,
386+ callerSdkId : "testApiId" ,
386387 callerSdkVersion : "testSdkVersion" ) ;
387388 }
388389 }
@@ -429,6 +430,7 @@ public async Task CallerSdkDetailsWithClientNameTestAsync()
429430 . WithClientVersion ( "testSdkVersion" )
430431 . WithAuthority ( TestConstants . AuthorityCommonTenant )
431432 . WithHttpManager ( _harness . HttpManager )
433+ . WithLogging ( ( a , b , c ) => { } )
432434 . BuildConcrete ( ) ;
433435
434436 await cca . AcquireTokenForClient ( TestConstants . s_scope )
@@ -443,6 +445,34 @@ await cca.AcquireTokenForClient(TestConstants.s_scope)
443445 }
444446 }
445447
448+ [ TestMethod ]
449+ public async Task ClientNameVersionNotInHeaders ( )
450+ {
451+ using ( _harness = CreateTestHarness ( ) )
452+ {
453+ _harness . HttpManager . AddInstanceDiscoveryMockHandler ( ) ;
454+ var requestHandler = _harness . HttpManager . AddMockHandlerSuccessfulClientCredentialTokenResponseMessage ( ) ;
455+
456+ var cca = ConfidentialClientApplicationBuilder . Create ( TestConstants . ClientId )
457+ . WithClientSecret ( TestConstants . ClientSecret )
458+ . WithClientName ( "testApiId" )
459+ . WithClientVersion ( "testSdkVersion" )
460+ . WithAuthority ( TestConstants . AuthorityCommonTenant )
461+ . WithHttpManager ( _harness . HttpManager )
462+ . WithLogging ( ( a , b , c ) => { } )
463+ . BuildConcrete ( ) ;
464+
465+ await cca . AcquireTokenForClient ( TestConstants . s_scope )
466+ . ExecuteAsync ( ) . ConfigureAwait ( false ) ;
467+
468+ requestHandler . ActualRequestHeaders . TryGetValues ( OAuth2Header . AppName , out var appName ) ;
469+ requestHandler . ActualRequestHeaders . TryGetValues ( OAuth2Header . AppVer , out var appVer ) ;
470+
471+ Assert . IsNull ( appName ) ;
472+ Assert . IsNull ( appVer ) ;
473+ }
474+ }
475+
446476 [ TestMethod ]
447477 public async Task CallerSdkDetailsWithNullClientNameTestAsync ( )
448478 {
@@ -698,8 +728,8 @@ private void AssertCurrentTelemetry(
698728 ApiIds apiId ,
699729 CacheRefreshReason cacheInfo ,
700730 bool isCacheSerialized = false ,
701- bool isLegacyCacheEnabled = true ,
702- string callerSdkId = "" ,
731+ bool isLegacyCacheEnabled = true ,
732+ string callerSdkId = "" ,
703733 string callerSdkVersion = "" )
704734 {
705735 string [ ] telemetryCategories = requestMessage . Headers . GetValues (
@@ -727,6 +757,6 @@ private void AssertCurrentTelemetry(
727757 Assert . AreEqual ( callerSdkId , telemetryCategories [ 2 ] . Split ( ',' ) [ 3 ] ) ;
728758
729759 Assert . AreEqual ( callerSdkVersion , telemetryCategories [ 2 ] . Split ( ',' ) [ 4 ] ) ;
730- }
760+ }
731761 }
732762}
0 commit comments