13
13
14
14
namespace Microsoft . AspNetCore . Server . HttpSys ;
15
15
16
- public class AuthenticationTests
16
+ public class AuthenticationTests : LoggedTest
17
17
{
18
18
private static bool AllowAnoymous = true ;
19
19
private static bool DenyAnoymous = false ;
@@ -33,7 +33,7 @@ public async Task AuthTypes_AllowAnonymous_NoChallenge(AuthenticationSchemes aut
33
33
Assert . NotNull ( httpContext . User . Identity ) ;
34
34
Assert . False ( httpContext . User . Identity . IsAuthenticated ) ;
35
35
return Task . FromResult ( 0 ) ;
36
- } ) )
36
+ } , LoggerFactory ) )
37
37
{
38
38
var response = await SendRequestAsync ( address ) ;
39
39
Assert . Equal ( HttpStatusCode . OK , response . StatusCode ) ;
@@ -51,7 +51,7 @@ public async Task AuthType_RequireAuth_ChallengesAdded(AuthenticationSchemes aut
51
51
using ( var server = Utilities . CreateDynamicHost ( authType , DenyAnoymous , out var address , httpContext =>
52
52
{
53
53
throw new NotImplementedException ( ) ;
54
- } ) )
54
+ } , LoggerFactory ) )
55
55
{
56
56
var response = await SendRequestAsync ( address ) ;
57
57
Assert . Equal ( HttpStatusCode . Unauthorized , response . StatusCode ) ;
@@ -73,7 +73,7 @@ public async Task AuthType_AllowAnonymousButSpecify401_ChallengesAdded(Authentic
73
73
Assert . False ( httpContext . User . Identity . IsAuthenticated ) ;
74
74
httpContext . Response . StatusCode = 401 ;
75
75
return Task . FromResult ( 0 ) ;
76
- } ) )
76
+ } , LoggerFactory ) )
77
77
{
78
78
var response = await SendRequestAsync ( address ) ;
79
79
Assert . Equal ( HttpStatusCode . Unauthorized , response . StatusCode ) ;
@@ -99,7 +99,7 @@ public async Task MultipleAuthTypes_AllowAnonymousButSpecify401_ChallengesAdded(
99
99
Assert . False ( httpContext . User . Identity . IsAuthenticated ) ;
100
100
httpContext . Response . StatusCode = 401 ;
101
101
return Task . FromResult ( 0 ) ;
102
- } ) )
102
+ } , LoggerFactory ) )
103
103
{
104
104
var response = await SendRequestAsync ( address ) ;
105
105
Assert . Equal ( HttpStatusCode . Unauthorized , response . StatusCode ) ;
@@ -135,7 +135,7 @@ public async Task AuthTypes_AllowAnonymousButSpecify401_Success(AuthenticationSc
135
135
}
136
136
requestId ++ ;
137
137
return Task . FromResult ( 0 ) ;
138
- } ) )
138
+ } , LoggerFactory ) )
139
139
{
140
140
var response = await SendRequestAsync ( address , useDefaultCredentials : true ) ;
141
141
Assert . Equal ( HttpStatusCode . OK , response . StatusCode ) ;
@@ -156,7 +156,7 @@ public async Task AuthTypes_RequireAuth_Success(AuthenticationSchemes authType)
156
156
Assert . NotNull ( httpContext . User . Identity ) ;
157
157
Assert . True ( httpContext . User . Identity . IsAuthenticated ) ;
158
158
return Task . FromResult ( 0 ) ;
159
- } ) )
159
+ } , LoggerFactory ) )
160
160
{
161
161
var response = await SendRequestAsync ( address , useDefaultCredentials : true ) ;
162
162
Assert . Equal ( HttpStatusCode . OK , response . StatusCode ) ;
@@ -182,7 +182,7 @@ public async Task AuthTypes_AccessUserInOnCompleted_Success()
182
182
return Task . CompletedTask ;
183
183
} ) ;
184
184
return Task . FromResult ( 0 ) ;
185
- } ) )
185
+ } , LoggerFactory ) )
186
186
{
187
187
var response = await SendRequestAsync ( address , useDefaultCredentials : true ) ;
188
188
Assert . Equal ( HttpStatusCode . OK , response . StatusCode ) ;
@@ -208,7 +208,7 @@ public async Task AuthTypes_AuthenticateWithNoUser_NoResults(AuthenticationSchem
208
208
var authResults = await httpContext . AuthenticateAsync ( HttpSysDefaults . AuthenticationScheme ) ;
209
209
Assert . False ( authResults . Succeeded ) ;
210
210
Assert . True ( authResults . None ) ;
211
- } ) )
211
+ } , LoggerFactory ) )
212
212
{
213
213
var response = await SendRequestAsync ( address ) ;
214
214
Assert . Equal ( HttpStatusCode . OK , response . StatusCode ) ;
@@ -231,7 +231,7 @@ public async Task AuthTypes_AuthenticateWithUser_OneResult(AuthenticationSchemes
231
231
Assert . True ( httpContext . User . Identity . IsAuthenticated ) ;
232
232
var authResults = await httpContext . AuthenticateAsync ( HttpSysDefaults . AuthenticationScheme ) ;
233
233
Assert . True ( authResults . Succeeded ) ;
234
- } ) )
234
+ } , LoggerFactory ) )
235
235
{
236
236
var response = await SendRequestAsync ( address , useDefaultCredentials : true ) ;
237
237
Assert . Equal ( HttpStatusCode . OK , response . StatusCode ) ;
@@ -253,7 +253,7 @@ public async Task AuthTypes_ChallengeWithoutAuthTypes_AllChallengesSent(Authenti
253
253
Assert . NotNull ( httpContext . User . Identity ) ;
254
254
Assert . False ( httpContext . User . Identity . IsAuthenticated ) ;
255
255
return httpContext . ChallengeAsync ( HttpSysDefaults . AuthenticationScheme ) ;
256
- } ) )
256
+ } , LoggerFactory ) )
257
257
{
258
258
var response = await SendRequestAsync ( address ) ;
259
259
Assert . Equal ( HttpStatusCode . Unauthorized , response . StatusCode ) ;
@@ -276,7 +276,7 @@ public async Task AuthTypes_ChallengeWithAllAuthTypes_AllChallengesSent(Authenti
276
276
Assert . NotNull ( httpContext . User . Identity ) ;
277
277
Assert . False ( httpContext . User . Identity . IsAuthenticated ) ;
278
278
await httpContext . ChallengeAsync ( HttpSysDefaults . AuthenticationScheme ) ;
279
- } ) )
279
+ } , LoggerFactory ) )
280
280
{
281
281
var response = await SendRequestAsync ( address ) ;
282
282
Assert . Equal ( HttpStatusCode . Unauthorized , response . StatusCode ) ;
@@ -294,7 +294,7 @@ public async Task AuthTypes_OneChallengeSent()
294
294
Assert . NotNull ( httpContext . User . Identity ) ;
295
295
Assert . False ( httpContext . User . Identity . IsAuthenticated ) ;
296
296
return httpContext . ChallengeAsync ( HttpSysDefaults . AuthenticationScheme ) ;
297
- } ) )
297
+ } , LoggerFactory ) )
298
298
{
299
299
var response = await SendRequestAsync ( address ) ;
300
300
Assert . Equal ( HttpStatusCode . Unauthorized , response . StatusCode ) ;
@@ -320,7 +320,7 @@ public async Task AuthTypes_ChallengeWillAskForAllEnabledSchemes(AuthenticationS
320
320
Assert . NotNull ( httpContext . User . Identity ) ;
321
321
Assert . False ( httpContext . User . Identity . IsAuthenticated ) ;
322
322
return httpContext . ChallengeAsync ( HttpSysDefaults . AuthenticationScheme ) ;
323
- } ) )
323
+ } , LoggerFactory ) )
324
324
{
325
325
var response = await SendRequestAsync ( address ) ;
326
326
Assert . Equal ( HttpStatusCode . Unauthorized , response . StatusCode ) ;
@@ -338,7 +338,7 @@ public async Task AuthTypes_Forbid_Forbidden()
338
338
Assert . NotNull ( httpContext . User . Identity ) ;
339
339
Assert . False ( httpContext . User . Identity . IsAuthenticated ) ;
340
340
return httpContext . ForbidAsync ( HttpSysDefaults . AuthenticationScheme ) ;
341
- } ) )
341
+ } , LoggerFactory ) )
342
342
{
343
343
var response = await SendRequestAsync ( address ) ;
344
344
Assert . Equal ( HttpStatusCode . Forbidden , response . StatusCode ) ;
@@ -359,7 +359,7 @@ public async Task AuthTypes_UnathorizedAuthenticatedAuthType_Unauthorized(Authen
359
359
Assert . NotNull ( httpContext . User . Identity ) ;
360
360
Assert . True ( httpContext . User . Identity . IsAuthenticated ) ;
361
361
return httpContext . ChallengeAsync ( HttpSysDefaults . AuthenticationScheme , null ) ;
362
- } ) )
362
+ } , LoggerFactory ) )
363
363
{
364
364
var response = await SendRequestAsync ( address , useDefaultCredentials : true ) ;
365
365
Assert . Equal ( HttpStatusCode . Unauthorized , response . StatusCode ) ;
@@ -393,7 +393,7 @@ public async Task AuthTypes_DisableAutomaticAuthentication(AuthenticationSchemes
393
393
Assert . NotNull ( authenticateResult . Principal ) ;
394
394
Assert . NotNull ( authenticateResult . Principal . Identity ) ;
395
395
Assert . True ( authenticateResult . Principal . Identity . IsAuthenticated ) ;
396
- } ) )
396
+ } , LoggerFactory ) )
397
397
{
398
398
var response = await SendRequestAsync ( address , useDefaultCredentials : true ) ;
399
399
Assert . Equal ( HttpStatusCode . OK , response . StatusCode ) ;
0 commit comments