1313
1414namespace Microsoft . AspNetCore . Server . HttpSys ;
1515
16- public class AuthenticationTests
16+ public class AuthenticationTests : LoggedTest
1717{
1818 private static bool AllowAnoymous = true ;
1919 private static bool DenyAnoymous = false ;
@@ -33,7 +33,7 @@ public async Task AuthTypes_AllowAnonymous_NoChallenge(AuthenticationSchemes aut
3333 Assert . NotNull ( httpContext . User . Identity ) ;
3434 Assert . False ( httpContext . User . Identity . IsAuthenticated ) ;
3535 return Task . FromResult ( 0 ) ;
36- } ) )
36+ } , LoggerFactory ) )
3737 {
3838 var response = await SendRequestAsync ( address ) ;
3939 Assert . Equal ( HttpStatusCode . OK , response . StatusCode ) ;
@@ -51,7 +51,7 @@ public async Task AuthType_RequireAuth_ChallengesAdded(AuthenticationSchemes aut
5151 using ( var server = Utilities . CreateDynamicHost ( authType , DenyAnoymous , out var address , httpContext =>
5252 {
5353 throw new NotImplementedException ( ) ;
54- } ) )
54+ } , LoggerFactory ) )
5555 {
5656 var response = await SendRequestAsync ( address ) ;
5757 Assert . Equal ( HttpStatusCode . Unauthorized , response . StatusCode ) ;
@@ -73,7 +73,7 @@ public async Task AuthType_AllowAnonymousButSpecify401_ChallengesAdded(Authentic
7373 Assert . False ( httpContext . User . Identity . IsAuthenticated ) ;
7474 httpContext . Response . StatusCode = 401 ;
7575 return Task . FromResult ( 0 ) ;
76- } ) )
76+ } , LoggerFactory ) )
7777 {
7878 var response = await SendRequestAsync ( address ) ;
7979 Assert . Equal ( HttpStatusCode . Unauthorized , response . StatusCode ) ;
@@ -99,7 +99,7 @@ public async Task MultipleAuthTypes_AllowAnonymousButSpecify401_ChallengesAdded(
9999 Assert . False ( httpContext . User . Identity . IsAuthenticated ) ;
100100 httpContext . Response . StatusCode = 401 ;
101101 return Task . FromResult ( 0 ) ;
102- } ) )
102+ } , LoggerFactory ) )
103103 {
104104 var response = await SendRequestAsync ( address ) ;
105105 Assert . Equal ( HttpStatusCode . Unauthorized , response . StatusCode ) ;
@@ -135,7 +135,7 @@ public async Task AuthTypes_AllowAnonymousButSpecify401_Success(AuthenticationSc
135135 }
136136 requestId ++ ;
137137 return Task . FromResult ( 0 ) ;
138- } ) )
138+ } , LoggerFactory ) )
139139 {
140140 var response = await SendRequestAsync ( address , useDefaultCredentials : true ) ;
141141 Assert . Equal ( HttpStatusCode . OK , response . StatusCode ) ;
@@ -156,7 +156,7 @@ public async Task AuthTypes_RequireAuth_Success(AuthenticationSchemes authType)
156156 Assert . NotNull ( httpContext . User . Identity ) ;
157157 Assert . True ( httpContext . User . Identity . IsAuthenticated ) ;
158158 return Task . FromResult ( 0 ) ;
159- } ) )
159+ } , LoggerFactory ) )
160160 {
161161 var response = await SendRequestAsync ( address , useDefaultCredentials : true ) ;
162162 Assert . Equal ( HttpStatusCode . OK , response . StatusCode ) ;
@@ -182,7 +182,7 @@ public async Task AuthTypes_AccessUserInOnCompleted_Success()
182182 return Task . CompletedTask ;
183183 } ) ;
184184 return Task . FromResult ( 0 ) ;
185- } ) )
185+ } , LoggerFactory ) )
186186 {
187187 var response = await SendRequestAsync ( address , useDefaultCredentials : true ) ;
188188 Assert . Equal ( HttpStatusCode . OK , response . StatusCode ) ;
@@ -208,7 +208,7 @@ public async Task AuthTypes_AuthenticateWithNoUser_NoResults(AuthenticationSchem
208208 var authResults = await httpContext . AuthenticateAsync ( HttpSysDefaults . AuthenticationScheme ) ;
209209 Assert . False ( authResults . Succeeded ) ;
210210 Assert . True ( authResults . None ) ;
211- } ) )
211+ } , LoggerFactory ) )
212212 {
213213 var response = await SendRequestAsync ( address ) ;
214214 Assert . Equal ( HttpStatusCode . OK , response . StatusCode ) ;
@@ -231,7 +231,7 @@ public async Task AuthTypes_AuthenticateWithUser_OneResult(AuthenticationSchemes
231231 Assert . True ( httpContext . User . Identity . IsAuthenticated ) ;
232232 var authResults = await httpContext . AuthenticateAsync ( HttpSysDefaults . AuthenticationScheme ) ;
233233 Assert . True ( authResults . Succeeded ) ;
234- } ) )
234+ } , LoggerFactory ) )
235235 {
236236 var response = await SendRequestAsync ( address , useDefaultCredentials : true ) ;
237237 Assert . Equal ( HttpStatusCode . OK , response . StatusCode ) ;
@@ -253,7 +253,7 @@ public async Task AuthTypes_ChallengeWithoutAuthTypes_AllChallengesSent(Authenti
253253 Assert . NotNull ( httpContext . User . Identity ) ;
254254 Assert . False ( httpContext . User . Identity . IsAuthenticated ) ;
255255 return httpContext . ChallengeAsync ( HttpSysDefaults . AuthenticationScheme ) ;
256- } ) )
256+ } , LoggerFactory ) )
257257 {
258258 var response = await SendRequestAsync ( address ) ;
259259 Assert . Equal ( HttpStatusCode . Unauthorized , response . StatusCode ) ;
@@ -276,7 +276,7 @@ public async Task AuthTypes_ChallengeWithAllAuthTypes_AllChallengesSent(Authenti
276276 Assert . NotNull ( httpContext . User . Identity ) ;
277277 Assert . False ( httpContext . User . Identity . IsAuthenticated ) ;
278278 await httpContext . ChallengeAsync ( HttpSysDefaults . AuthenticationScheme ) ;
279- } ) )
279+ } , LoggerFactory ) )
280280 {
281281 var response = await SendRequestAsync ( address ) ;
282282 Assert . Equal ( HttpStatusCode . Unauthorized , response . StatusCode ) ;
@@ -294,7 +294,7 @@ public async Task AuthTypes_OneChallengeSent()
294294 Assert . NotNull ( httpContext . User . Identity ) ;
295295 Assert . False ( httpContext . User . Identity . IsAuthenticated ) ;
296296 return httpContext . ChallengeAsync ( HttpSysDefaults . AuthenticationScheme ) ;
297- } ) )
297+ } , LoggerFactory ) )
298298 {
299299 var response = await SendRequestAsync ( address ) ;
300300 Assert . Equal ( HttpStatusCode . Unauthorized , response . StatusCode ) ;
@@ -320,7 +320,7 @@ public async Task AuthTypes_ChallengeWillAskForAllEnabledSchemes(AuthenticationS
320320 Assert . NotNull ( httpContext . User . Identity ) ;
321321 Assert . False ( httpContext . User . Identity . IsAuthenticated ) ;
322322 return httpContext . ChallengeAsync ( HttpSysDefaults . AuthenticationScheme ) ;
323- } ) )
323+ } , LoggerFactory ) )
324324 {
325325 var response = await SendRequestAsync ( address ) ;
326326 Assert . Equal ( HttpStatusCode . Unauthorized , response . StatusCode ) ;
@@ -338,7 +338,7 @@ public async Task AuthTypes_Forbid_Forbidden()
338338 Assert . NotNull ( httpContext . User . Identity ) ;
339339 Assert . False ( httpContext . User . Identity . IsAuthenticated ) ;
340340 return httpContext . ForbidAsync ( HttpSysDefaults . AuthenticationScheme ) ;
341- } ) )
341+ } , LoggerFactory ) )
342342 {
343343 var response = await SendRequestAsync ( address ) ;
344344 Assert . Equal ( HttpStatusCode . Forbidden , response . StatusCode ) ;
@@ -359,7 +359,7 @@ public async Task AuthTypes_UnathorizedAuthenticatedAuthType_Unauthorized(Authen
359359 Assert . NotNull ( httpContext . User . Identity ) ;
360360 Assert . True ( httpContext . User . Identity . IsAuthenticated ) ;
361361 return httpContext . ChallengeAsync ( HttpSysDefaults . AuthenticationScheme , null ) ;
362- } ) )
362+ } , LoggerFactory ) )
363363 {
364364 var response = await SendRequestAsync ( address , useDefaultCredentials : true ) ;
365365 Assert . Equal ( HttpStatusCode . Unauthorized , response . StatusCode ) ;
@@ -393,7 +393,7 @@ public async Task AuthTypes_DisableAutomaticAuthentication(AuthenticationSchemes
393393 Assert . NotNull ( authenticateResult . Principal ) ;
394394 Assert . NotNull ( authenticateResult . Principal . Identity ) ;
395395 Assert . True ( authenticateResult . Principal . Identity . IsAuthenticated ) ;
396- } ) )
396+ } , LoggerFactory ) )
397397 {
398398 var response = await SendRequestAsync ( address , useDefaultCredentials : true ) ;
399399 Assert . Equal ( HttpStatusCode . OK , response . StatusCode ) ;
0 commit comments