@@ -17,7 +17,7 @@ public async Task Authorize_WithPolicyName_Success()
1717 var meterFactory = new TestMeterFactory ( ) ;
1818 var authorizationService = BuildAuthorizationService ( meterFactory ) ;
1919 var meter = meterFactory . Meters . Single ( ) ;
20- var user = new ClaimsPrincipal ( new ClaimsIdentity ( [ new Claim ( "Permission" , "CanViewPage" ) ] ) ) ;
20+ var user = new ClaimsPrincipal ( new ClaimsIdentity ( [ new Claim ( "Permission" , "CanViewPage" ) ] , authenticationType : "someAuthentication" ) ) ;
2121
2222 using var authorizedRequestsCollector = new MetricCollector < long > ( meterFactory , AuthorizationMetrics . MeterName , "aspnetcore.authorization.requests" ) ;
2323
@@ -32,6 +32,7 @@ public async Task Authorize_WithPolicyName_Success()
3232 Assert . Equal ( 1 , measurement . Value ) ;
3333 Assert . Equal ( "Basic" , ( string ) measurement . Tags [ "aspnetcore.authorization.policy" ] ) ;
3434 Assert . Equal ( "success" , ( string ) measurement . Tags [ "aspnetcore.authorization.result" ] ) ;
35+ Assert . True ( ( bool ) measurement . Tags [ "user.is_authenticated" ] ) ;
3536 }
3637
3738 [ Fact ]
@@ -56,6 +57,7 @@ public async Task Authorize_WithPolicyName_Failure()
5657 Assert . Equal ( 1 , measurement . Value ) ;
5758 Assert . Equal ( "Basic" , ( string ) measurement . Tags [ "aspnetcore.authorization.policy" ] ) ;
5859 Assert . Equal ( "failure" , ( string ) measurement . Tags [ "aspnetcore.authorization.result" ] ) ;
60+ Assert . False ( ( bool ) measurement . Tags [ "user.is_authenticated" ] ) ;
5961 }
6062
6163 [ Fact ]
@@ -80,6 +82,7 @@ public async Task Authorize_WithPolicyName_PolicyNotFound()
8082 Assert . Equal ( 1 , measurement . Value ) ;
8183 Assert . Equal ( "UnknownPolicy" , ( string ) measurement . Tags [ "aspnetcore.authorization.policy" ] ) ;
8284 Assert . Equal ( "System.InvalidOperationException" , ( string ) measurement . Tags [ "error.type" ] ) ;
85+ Assert . False ( ( bool ) measurement . Tags [ "user.is_authenticated" ] ) ;
8386 Assert . False ( measurement . Tags . ContainsKey ( "aspnetcore.authorization.result" ) ) ;
8487 }
8588
@@ -107,6 +110,7 @@ public async Task Authorize_WithoutPolicyName_Success()
107110 var measurement = Assert . Single ( authorizedRequestsCollector . GetMeasurementSnapshot ( ) ) ;
108111 Assert . Equal ( 1 , measurement . Value ) ;
109112 Assert . Equal ( "success" , ( string ) measurement . Tags [ "aspnetcore.authorization.result" ] ) ;
113+ Assert . False ( ( bool ) measurement . Tags [ "user.is_authenticated" ] ) ;
110114 Assert . False ( measurement . Tags . ContainsKey ( "aspnetcore.authorization.policy" ) ) ;
111115 }
112116
@@ -131,6 +135,7 @@ public async Task Authorize_WithoutPolicyName_Failure()
131135 var measurement = Assert . Single ( authorizedRequestsCollector . GetMeasurementSnapshot ( ) ) ;
132136 Assert . Equal ( 1 , measurement . Value ) ;
133137 Assert . Equal ( "failure" , ( string ) measurement . Tags [ "aspnetcore.authorization.result" ] ) ;
138+ Assert . False ( ( bool ) measurement . Tags [ "user.is_authenticated" ] ) ;
134139 Assert . False ( measurement . Tags . ContainsKey ( "aspnetcore.authorization.policy" ) ) ;
135140 }
136141
@@ -159,6 +164,7 @@ public async Task Authorize_WithoutPolicyName_ExceptionThrownInHandler()
159164 var measurement = Assert . Single ( authorizedRequestsCollector . GetMeasurementSnapshot ( ) ) ;
160165 Assert . Equal ( 1 , measurement . Value ) ;
161166 Assert . Equal ( "System.InvalidOperationException" , ( string ) measurement . Tags [ "error.type" ] ) ;
167+ Assert . False ( ( bool ) measurement . Tags [ "user.is_authenticated" ] ) ;
162168 Assert . False ( measurement . Tags . ContainsKey ( "aspnetcore.authorization.policy" ) ) ;
163169 Assert . False ( measurement . Tags . ContainsKey ( "aspnetcore.authorization.result" ) ) ;
164170 }
0 commit comments