File tree Expand file tree Collapse file tree
test/KK.AspNetCore.EasyAuthAuthentication.Test/Services Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -96,5 +96,21 @@ public void IfAValidJwtTokenWithoutIdpAndIssPropertyIsInTheHeaderItsThrowsAnErro
9696 // Act && Arrange
9797 Assert . Throws < ArgumentException > ( ( ) => handler . AuthUser ( httpcontext ) ) ;
9898 }
99+
100+ [ Fact ]
101+ public void IfAValidJwtTokenWithoutTheClaimPropertyIsInTheHeaderItsNotThrowAnError ( )
102+ {
103+ // Arrange
104+ var handler = new EasyAuthForAuthorizationTokenService ( this . loggerFactory . CreateLogger < EasyAuthForAuthorizationTokenService > ( ) ) ;
105+ var httpcontext = new DefaultHttpContext ( ) ;
106+ var jwtWithoutIdpProperty = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiIwN2Q2ZDE1YS1jZTg5LTQ4MmMtOTcxYi01NDMxYjc1MTkxNjciLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC9lOTgxZGNhZi05MTk3LTQ3N2YtYmQwNi0wZTU3MmIwYjMzNDcvIiwiaWF0IjoxNTYyNjk4ODc2LCJuYmYiOjE1NjI2OTg4NzYsImV4cCI6MTU2MjcwMjc3NiwiYWlvIjoiNDJaZ1lPQmZzRzd0ZEg1ZVBpSHZvNU9QdDdyT0J3QT0iLCJhcHBpZCI6ImQzMTViZmFmLTYzMDQtNGY5Zi04MjFjLTU0NmJkYzAwYjViMCIsImFwcGlkYWNyIjoiMSIsIm9pZCI6ImY1ZjlmYTg2LTQ0MTQtNDRjNy04MGY4LWY3ODBhZTBhYmYyMSIsInN1YiI6ImY1ZjlmYTg2LTQ0MTQtNDRjNy04MGY4LWY3ODBhZTBhYmYyMSIsInRpZCI6ImU5ODFkY2FmLTkxOTctNDc3Zi1iZDA2LTBlNTcyYjBiMzM0NyIsInV0aSI6ImhDSnUzb2g3d1VlWmFpNVFKT1lBQUEiLCJ2ZXIiOiIxLjAifQ.HFVt3Moojs3G7J5CoqfJ8lDtxUf3SsO1bGb8_9O-314" ;
107+ httpcontext . Request . Headers . Add ( "Authorization" , jwtWithoutIdpProperty ) ;
108+
109+ // Act
110+ var result = handler . AuthUser ( httpcontext ) ;
111+ // Arrange
112+ Assert . True ( result . Succeeded ) ;
113+ Assert . Equal ( this . testJwtAppId , result . Principal . Identity . Name ) ;
114+ }
99115 }
100116}
You can’t perform that action at this time.
0 commit comments