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 @@ -85,6 +85,22 @@ public void IfAValidJwtTokenWithoutIdpPropertyIsInTheHeaderTheResultIsSuccsess()
8585 Assert . Equal ( this . testJwtAppId , result . Principal . Identity . Name ) ;
8686 }
8787
88+ [ Fact ]
89+ public void IfAValidJwtTokenWithAnUpnPropertyIsInTheHeaderTheResultContainsTheUpnAsIdentity ( )
90+ {
91+ // Arrange
92+ var handler = new EasyAuthForAuthorizationTokenService ( this . loggerFactory . CreateLogger < EasyAuthForAuthorizationTokenService > ( ) ) ;
93+ var httpcontext = new DefaultHttpContext ( ) ;
94+ var jwtWithoutIdpProperty = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiIwN2Q2ZDE1YS1jZTg5LTQ4MmMtOTcxYi01NDMxYjc1MTkxNjciLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC9lOTgxZGNhZi05MTk3LTQ3N2YtYmQwNi0wZTU3MmIwYjMzNDcvIiwiaWF0IjoxNTYyNjk4ODc2LCJuYmYiOjE1NjI2OTg4NzYsImV4cCI6MTU2MjcwMjc3NiwiYWlvIjoiNDJaZ1lPQmZzRzd0ZEg1ZVBpSHZvNU9QdDdyT0J3QT0iLCJhcHBpZCI6ImQzMTViZmFmLTYzMDQtNGY5Zi04MjFjLTU0NmJkYzAwYjViMCIsInVwbiI6InRlc3R1c2VyQHRlc3QuZGUiLCJhcHBpZGFjciI6IjEiLCJpZHAiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC9lOTgxZGNhZi05MTk3LTQ3N2YtYmQwNi0wZTU3MmIwYjMzNDcvIiwib2lkIjoiZjVmOWZhODYtNDQxNC00NGM3LTgwZjgtZjc4MGFlMGFiZjIxIiwicm9sZXMiOlsiU3lzdGVtQWRtaW4iXSwic3ViIjoiZjVmOWZhODYtNDQxNC00NGM3LTgwZjgtZjc4MGFlMGFiZjIxIiwidGlkIjoiZTk4MWRjYWYtOTE5Ny00NzdmLWJkMDYtMGU1NzJiMGIzMzQ3IiwidXRpIjoiaENKdTNvaDd3VWVaYWk1UUpPWUFBQSIsInZlciI6IjEuMCJ9.T2vYwRaOFtISgoaMgg6XJ-pZEA5SOhqW09mF7TsGDBY" ;
95+ httpcontext . Request . Headers . Add ( "Authorization" , jwtWithoutIdpProperty ) ;
96+ // Act
97+ var result = handler . AuthUser ( httpcontext ) ;
98+ // Arrange
99+ Assert . True ( result . Succeeded ) ;
100+ Assert . True ( result . Principal . HasClaim ( ClaimTypes . Role , "SystemAdmin" ) ) ;
101+ Assert . Equal ( "testuser@test.de" , result . Principal . Identity . Name ) ;
102+ }
103+
88104 [ Fact ]
89105 public void IfAValidJwtTokenWithoutIdpAndIssPropertyIsInTheHeaderItsThrowsAnError ( )
90106 {
You can’t perform that action at this time.
0 commit comments