Skip to content

Commit 6636881

Browse files
Add test for SuperOffice token validation
Add a test that validates that token validity is checked by the SuperOffice provider.
1 parent 3abb3eb commit 6636881

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/AspNet.Security.OAuth.Providers.Tests/SuperOffice/SuperOfficeTests.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,27 @@ static void ConfigureServices(IServiceCollection services)
9292
// Assert
9393
AssertClaim(claims, claimType, claimValue);
9494
}
95+
96+
[Fact]
97+
public async Task Cannot_Sign_In_Using_SuperOffice_With_Invalid_Token_Audience()
98+
{
99+
// Arrange
100+
static void ConfigureServices(IServiceCollection services)
101+
{
102+
services.AddSingleton<JwtSecurityTokenHandler, FrozenJwtSecurityTokenHandler>();
103+
services.PostConfigureAll<SuperOfficeAuthenticationOptions>((options) =>
104+
{
105+
options.TokenValidationParameters.ValidAudience = "not-the-right-audience";
106+
});
107+
}
108+
109+
using var server = CreateTestServer(ConfigureServices);
110+
111+
// Act
112+
var exception = await Assert.ThrowsAsync<Exception>(() => AuthenticateUserAsync(server));
113+
114+
// Assert
115+
exception.InnerException.ShouldBeOfType<SecurityTokenValidationException>();
116+
}
95117
}
96118
}

0 commit comments

Comments
 (0)