29
29
using static Microsoft . Identity . Client . TelemetryCore . Internal . Events . ApiEvent ;
30
30
using System . Collections . Generic ;
31
31
using Microsoft . Identity . Client . Internal ;
32
+ using Microsoft . Identity . Client . OAuth2 ;
32
33
33
34
namespace Microsoft . Identity . Test . Unit . TelemetryTests
34
35
{
@@ -373,16 +374,16 @@ public async Task CallerSdkDetailsTestAsync()
373
374
var cca = CreateConfidentialClientApp ( ) ;
374
375
375
376
await cca . AcquireTokenForClient ( TestConstants . s_scope )
376
- . WithExtraQueryParameters ( new Dictionary < string , string > {
377
+ . WithExtraQueryParameters ( new Dictionary < string , string > {
377
378
{ "caller-sdk-id" , "testApiId" } ,
378
379
{ "caller-sdk-ver" , "testSdkVersion" } } )
379
380
. ExecuteAsync ( ) . ConfigureAwait ( false ) ;
380
381
381
382
AssertCurrentTelemetry (
382
- requestHandler . ActualRequestMessage ,
383
- ApiIds . AcquireTokenForClient ,
383
+ requestHandler . ActualRequestMessage ,
384
+ ApiIds . AcquireTokenForClient ,
384
385
CacheRefreshReason . NoCachedAccessToken ,
385
- callerSdkId : "testApiId" ,
386
+ callerSdkId : "testApiId" ,
386
387
callerSdkVersion : "testSdkVersion" ) ;
387
388
}
388
389
}
@@ -429,6 +430,7 @@ public async Task CallerSdkDetailsWithClientNameTestAsync()
429
430
. WithClientVersion ( "testSdkVersion" )
430
431
. WithAuthority ( TestConstants . AuthorityCommonTenant )
431
432
. WithHttpManager ( _harness . HttpManager )
433
+ . WithLogging ( ( a , b , c ) => { } )
432
434
. BuildConcrete ( ) ;
433
435
434
436
await cca . AcquireTokenForClient ( TestConstants . s_scope )
@@ -443,6 +445,34 @@ await cca.AcquireTokenForClient(TestConstants.s_scope)
443
445
}
444
446
}
445
447
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
+
446
476
[ TestMethod ]
447
477
public async Task CallerSdkDetailsWithNullClientNameTestAsync ( )
448
478
{
@@ -698,8 +728,8 @@ private void AssertCurrentTelemetry(
698
728
ApiIds apiId ,
699
729
CacheRefreshReason cacheInfo ,
700
730
bool isCacheSerialized = false ,
701
- bool isLegacyCacheEnabled = true ,
702
- string callerSdkId = "" ,
731
+ bool isLegacyCacheEnabled = true ,
732
+ string callerSdkId = "" ,
703
733
string callerSdkVersion = "" )
704
734
{
705
735
string [ ] telemetryCategories = requestMessage . Headers . GetValues (
@@ -727,6 +757,6 @@ private void AssertCurrentTelemetry(
727
757
Assert . AreEqual ( callerSdkId , telemetryCategories [ 2 ] . Split ( ',' ) [ 3 ] ) ;
728
758
729
759
Assert . AreEqual ( callerSdkVersion , telemetryCategories [ 2 ] . Split ( ',' ) [ 4 ] ) ;
730
- }
760
+ }
731
761
}
732
762
}
0 commit comments