File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed
src/AzureFunctions.Extensions.OpenIDConnect.Tests Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change 1+ namespace AzureFunctions . Extensions . OpenIDConnect . Tests
2+ {
3+ using Configuration ;
4+ using FluentAssertions ;
5+ using Microsoft . Extensions . DependencyInjection ;
6+ using Microsoft . IdentityModel . Tokens ;
7+ using NUnit . Framework ;
8+
9+ public class TokenValidationShould
10+ {
11+ [ Test ]
12+ public void BeSecure_When_Using_Audience_And_Issuer ( )
13+ {
14+ // Arrange
15+ var collection = ServiceCollectionFixture . MinimalAzFunctionsServices ( ) ;
16+
17+ var audience = "my_audience" ;
18+ var issuer = "https://me.secure.com" ;
19+
20+ collection . AddOpenIDConnect ( builder =>
21+ {
22+ builder . SetIssuerBaseUrlConfiguration ( "http://anyurl.com" ) ;
23+ builder . SetTokenValidation ( audience , issuer ) ;
24+ } ) ;
25+
26+ var provider = collection . BuildServiceProvider ( ) ;
27+
28+ var expected = new TokenValidationParameters
29+ {
30+ RequireSignedTokens = true ,
31+ ValidateIssuerSigningKey = true ,
32+ ValidateLifetime = true ,
33+
34+ ValidateAudience = true ,
35+ ValidAudience = audience ,
36+
37+ ValidateIssuer = true ,
38+ ValidIssuer = issuer
39+ } ;
40+
41+ // Act
42+ var tokenValidationParameters = provider . GetService < TokenValidationParameters > ( ) ;
43+
44+ // Assert
45+ tokenValidationParameters . Should ( ) . BeEquivalentTo ( expected ) ;
46+ }
47+ }
48+ }
You can’t perform that action at this time.
0 commit comments