-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
85 additions
and
9 deletions.
There are no files selected for viewing
6 changes: 4 additions & 2 deletions
6
src/Microsoft.Identity.Web.Diagnostics/Diagnostics/CallerArgumentExpressionAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6
src/Microsoft.Identity.Web.Diagnostics/Diagnostics/NullableAttributes.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
src/Microsoft.Identity.Web.TokenAcquisition/TokenAcquirerFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using System.Security.Cryptography.X509Certificates; | ||
using Microsoft.Identity.Client; | ||
using Microsoft.Identity.Web.Test.Common; | ||
using Xunit; | ||
|
||
namespace Microsoft.Identity.Web.Test | ||
{ | ||
public class MsAuth10AtPopTests | ||
{ | ||
[Fact] | ||
public void MsAuth10AtPop_WithAtPop_ShouldPopulateBuilderWithProofOfPosessionKeyIdAndOnBeforeTokenRequestTest() | ||
{ | ||
// Arrange | ||
var builder = ConfidentialClientApplicationBuilder.Create(TestConstants.ClientId); | ||
builder.WithExperimentalFeatures(); | ||
builder.WithClientSecret(TestConstants.ClientSecret); | ||
var app = builder.Build(); | ||
var clientCertificate = new X509Certificate2(new byte[0]); | ||
var popPublicKey = "pop_key"; | ||
var jwkClaim = "jwk_claim"; | ||
var clientId = "client_id"; | ||
|
||
// Act | ||
var result = MsAuth10AtPop.WithAtPop(app.AcquireTokenForClient(new[] { TestConstants.Scopes }), clientCertificate, popPublicKey, jwkClaim, clientId); | ||
|
||
// Assert | ||
Assert.NotNull(result); | ||
} | ||
|
||
[Fact] | ||
public void MsAuth10AtPop_ThrowsWithNullPopKeyTest() | ||
{ | ||
// Arrange | ||
IConfidentialClientApplication app = CreateBuilder(); | ||
var clientCertificate = new X509Certificate2(new byte[0]); | ||
var jwkClaim = "jwk_claim"; | ||
var clientId = "client_id"; | ||
|
||
// Act & Assert | ||
Assert.Throws<ArgumentNullException>(() => MsAuth10AtPop.WithAtPop(app.AcquireTokenForClient(new[] { TestConstants.Scopes }), clientCertificate, string.Empty, jwkClaim, clientId)); | ||
} | ||
|
||
[Fact] | ||
public void MsAuth10AtPop_ThrowsWithNullJwkClaimTest() | ||
{ | ||
// Arrange | ||
IConfidentialClientApplication app = CreateBuilder(); | ||
var clientCertificate = new X509Certificate2(new byte[0]); | ||
var popPublicKey = "pop_key"; | ||
var clientId = "client_id"; | ||
|
||
// Act & Assert | ||
Assert.Throws<ArgumentNullException>(() => MsAuth10AtPop.WithAtPop(app.AcquireTokenForClient(new[] { TestConstants.Scopes }), clientCertificate, popPublicKey, null, clientId)); | ||
} | ||
|
||
private static IConfidentialClientApplication CreateBuilder() | ||
{ | ||
var builder = ConfidentialClientApplicationBuilder.Create(TestConstants.ClientId); | ||
builder.WithExperimentalFeatures(); | ||
builder.WithClientSecret(TestConstants.ClientSecret); | ||
return builder.Build(); | ||
} | ||
} | ||
} |