Skip to content

Commit 7bf0a28

Browse files
authored
Mark API as experimental (#5551)
mark api as experimnental
1 parent 7632792 commit 7bf0a28

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

src/client/Microsoft.Identity.Client/AppConfig/ConfidentialClientApplicationBuilder.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ public ConfidentialClientApplicationBuilder WithClientAssertion(Func<string> cli
228228
throw new ArgumentNullException(nameof(clientAssertionDelegate));
229229
}
230230

231-
return WithClientAssertion(
231+
return WithClientAssertionInternal(
232232
(opts, ct) =>
233233
Task.FromResult(new ClientSignedAssertion
234234
{
@@ -251,7 +251,7 @@ public ConfidentialClientApplicationBuilder WithClientAssertion(Func<Cancellatio
251251
throw new ArgumentNullException(nameof(clientAssertionAsyncDelegate));
252252
}
253253

254-
return WithClientAssertion(
254+
return WithClientAssertionInternal(
255255
async (opts, ct) =>
256256
{
257257
string jwt = await clientAssertionAsyncDelegate(ct).ConfigureAwait(false);
@@ -273,7 +273,7 @@ public ConfidentialClientApplicationBuilder WithClientAssertion(Func<AssertionRe
273273
throw new ArgumentNullException(nameof(clientAssertionAsyncDelegate));
274274
}
275275

276-
return WithClientAssertion(
276+
return WithClientAssertionInternal(
277277
async (opts, _) =>
278278
{
279279
string jwt = await clientAssertionAsyncDelegate(opts).ConfigureAwait(false);
@@ -295,6 +295,18 @@ public ConfidentialClientApplicationBuilder WithClientAssertion(Func<AssertionRe
295295
/// <exception cref="MsalClientException">Thrown if <paramref name="clientSignedAssertionProvider"/> is <see langword="null"/>.</exception>
296296
public ConfidentialClientApplicationBuilder WithClientAssertion(Func<AssertionRequestOptions,
297297
CancellationToken, Task<ClientSignedAssertion>> clientSignedAssertionProvider)
298+
{
299+
ValidateUseOfExperimentalFeature();
300+
return WithClientAssertionInternal(clientSignedAssertionProvider);
301+
}
302+
303+
/// <summary>
304+
/// Internal helper to set the client assertion provider.
305+
/// </summary>
306+
/// <param name="clientSignedAssertionProvider"></param>
307+
/// <returns></returns>
308+
internal ConfidentialClientApplicationBuilder WithClientAssertionInternal(
309+
Func<AssertionRequestOptions, CancellationToken, Task<ClientSignedAssertion>> clientSignedAssertionProvider)
298310
{
299311
Config.ClientCredential = new ClientAssertionDelegateCredential(clientSignedAssertionProvider);
300312
return this;

tests/Microsoft.Identity.Test.Unit/PublicApiTests/ClientAssertionTests.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ public async Task ClientAssertion_BearerAsync()
345345

346346
var handler = http.AddMockHandlerSuccessfulClientCredentialTokenResponseMessage();
347347
var cca = ConfidentialClientApplicationBuilder.Create(TestConstants.ClientId)
348+
.WithExperimentalFeatures(true)
348349
.WithClientSecret(TestConstants.ClientSecret)
349350
.WithHttpManager(http)
350351
.WithClientAssertion(BearerDelegate())
@@ -373,6 +374,7 @@ public async Task ClientAssertion_WithPoPDelegate_No_Mtls_Api_SendsBearer_Async(
373374
http.AddInstanceDiscoveryMockHandler();
374375
var handler = http.AddMockHandlerSuccessfulClientCredentialTokenResponseMessage();
375376
var cca = ConfidentialClientApplicationBuilder.Create(TestConstants.ClientId)
377+
.WithExperimentalFeatures(true)
376378
.WithClientSecret(TestConstants.ClientSecret)
377379
.WithHttpManager(http)
378380
.WithClientAssertion(PopDelegate())
@@ -399,6 +401,7 @@ public async Task ClientAssertion_ReceivesClientCapabilitiesAsync()
399401

400402
bool checkedCaps = false;
401403
var cca = ConfidentialClientApplicationBuilder.Create(TestConstants.ClientId)
404+
.WithExperimentalFeatures(true)
402405
.WithClientSecret(TestConstants.ClientSecret)
403406
.WithClientCapabilities(TestConstants.ClientCapabilities)
404407
.WithHttpManager(http)
@@ -427,6 +430,7 @@ public async Task ClientAssertion_ReceivesClientCapabilitiesAsync()
427430
public async Task ClientAssertion_EmptyJwt_ThrowsAsync()
428431
{
429432
var cca = ConfidentialClientApplicationBuilder.Create(TestConstants.ClientId)
433+
.WithExperimentalFeatures(true)
430434
.WithClientSecret(TestConstants.ClientSecret)
431435
.WithClientAssertion((o, c) =>
432436
Task.FromResult(new ClientSignedAssertion { Assertion = string.Empty }))
@@ -443,6 +447,7 @@ public async Task ClientAssertion_CancellationTokenPropagatesAsync()
443447
using var cts = new CancellationTokenSource();
444448

445449
var cca = ConfidentialClientApplicationBuilder.Create(TestConstants.ClientId)
450+
.WithExperimentalFeatures(true)
446451
.WithClientSecret(TestConstants.ClientSecret)
447452
.WithClientAssertion((o, ct) =>
448453
{
@@ -481,6 +486,7 @@ public async Task WithMtlsPop_AfterPoPDelegate_Works()
481486
var cert = CertHelper.GetOrCreateTestCert();
482487

483488
var app = ConfidentialClientApplicationBuilder.Create(TestConstants.ClientId)
489+
.WithExperimentalFeatures(true)
484490
.WithClientAssertion(PopDelegate())
485491
.WithAuthority($"https://login.microsoftonline.com/123456-1234-2345-1234561234")
486492
.WithAzureRegion(ConfidentialClientApplication.AttemptRegionDiscovery)
@@ -559,6 +565,7 @@ public async Task PoP_CachedTokenWithDifferentCertificate_IsBypassedAsync()
559565

560566
// ─────────── Build the app ───────────
561567
var cca = ConfidentialClientApplicationBuilder.Create(TestConstants.ClientId)
568+
.WithExperimentalFeatures(true)
562569
.WithClientSecret(TestConstants.ClientSecret)
563570
.WithClientAssertion(popDelegate)
564571
.WithAuthority($"https://login.microsoftonline.com/123456-1234-2345-1234561234")
@@ -591,7 +598,8 @@ public async Task PoP_CachedTokenWithDifferentCertificate_IsBypassedAsync()
591598
public async Task WithMtlsPop_AfterBearerDelegate_Throws()
592599
{
593600
var cca = ConfidentialClientApplicationBuilder.Create(TestConstants.ClientId)
594-
.WithClientSecret(TestConstants.ClientSecret)
601+
.WithExperimentalFeatures(true)
602+
.WithClientSecret(TestConstants.ClientSecret)
595603
.WithClientAssertion(BearerDelegate())
596604
.BuildConcrete();
597605

@@ -614,6 +622,7 @@ public async Task ClientAssertion_NotCalledWhenTokenFromCacheAsync()
614622
http.AddMockHandlerSuccessfulClientCredentialTokenResponseMessage(); // first call => network
615623

616624
var cca = ConfidentialClientApplicationBuilder.Create(TestConstants.ClientId)
625+
.WithExperimentalFeatures(true)
617626
.WithClientSecret(TestConstants.ClientSecret)
618627
.WithHttpManager(http)
619628
.WithClientAssertion((o, c) =>
@@ -644,6 +653,7 @@ public async Task WithMtlsPop_AfterPoPDelegate_NoRegion_ThrowsAsync()
644653
// Arrange – CCA with PoP delegate (returns JWT + cert) but **no AzureRegion configured**
645654
var cert = CertHelper.GetOrCreateTestCert();
646655
var cca = ConfidentialClientApplicationBuilder.Create(TestConstants.ClientId)
656+
.WithExperimentalFeatures(true)
647657
.WithClientAssertion(PopDelegate())
648658
.WithHttpManager(http)
649659
.BuildConcrete();

tests/Microsoft.Identity.Test.Unit/PublicApiTests/ConfidentialClientApplicationTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,7 @@ public async Task AcquireTokenForClient_EmptyAssertion_ThrowsArgumentExceptionAs
898898
{
899899
// Build a CCA whose assertion‑delegate returns NO JWT (error case)
900900
var cca = ConfidentialClientApplicationBuilder.Create(TestConstants.ClientId)
901+
.WithExperimentalFeatures(true)
901902
.WithClientSecret(TestConstants.ClientSecret)
902903
.WithClientAssertion(
903904
(opts, ct) => Task.FromResult(new ClientSignedAssertion

0 commit comments

Comments
 (0)