@@ -514,7 +514,8 @@ public async Task Logout_ShouldNotRevokeDeviceChain()
514514 var chainBefore = before ! . Items . Single ( x => x . IsCurrentDevice ) ;
515515 var chainId = chainBefore . ChainId ;
516516
517- await CsrfTestClient . PostAsync ( client , "/auth/logout" , null ) ;
517+ var logout = await CsrfTestClient . PostAsync ( client , "/auth/logout" , null ) ;
518+ logout . StatusCode . Should ( ) . Be ( HttpStatusCode . Found ) ;
518519
519520 using var reloginClient = CreateClient ( device ) ;
520521
@@ -979,46 +980,6 @@ await CsrfTestClient.PostJsonAsync(device2Client,
979980 device2After . IsRevoked . Should ( ) . BeFalse ( ) ;
980981 }
981982
982- [ Fact ]
983- public async Task Logout_WithAlreadyLoggedOutSession_ShouldRemainSafe ( )
984- {
985- _factory . Clock . Reset ( ) ;
986-
987- var user = await _factory . CreateLoginUserAsync ( ) ;
988- var device = $ "logout-idempotent-{ Guid . NewGuid ( ) : N} ";
989-
990- using var client = CreateClient ( device ) ;
991-
992- var login = await LoginAsync (
993- client ,
994- user . Identifier ,
995- user . Secret ) ;
996-
997- login . StatusCode . Should ( ) . Be ( HttpStatusCode . Found ) ;
998-
999- var cookie = GetSessionCookie ( login ) ;
1000-
1001- client . DefaultRequestHeaders . Add ( "Cookie" , cookie ) ;
1002-
1003- var firstLogout = await CsrfTestClient . PostAsync ( client , "/auth/logout" , null ) ;
1004-
1005- firstLogout . StatusCode . Should ( ) . Be ( HttpStatusCode . Found ) ;
1006-
1007- var secondLogout = await CsrfTestClient . PostAsync ( client , "/auth/logout" , null ) ;
1008-
1009- secondLogout . StatusCode . Should ( ) . BeOneOf ( HttpStatusCode . Unauthorized , HttpStatusCode . Found ) ;
1010-
1011- var authenticatedRequest = await CsrfTestClient . PostJsonAsync ( client ,
1012- "/auth/me/sessions/chains" ,
1013- new PageRequest
1014- {
1015- PageNumber = 1 ,
1016- PageSize = 50
1017- } ) ;
1018-
1019- authenticatedRequest . StatusCode . Should ( ) . Be ( HttpStatusCode . Unauthorized ) ;
1020- }
1021-
1022983 [ Fact ]
1023984 public async Task Logout_ShouldNotReturnAuthenticationCredentials ( )
1024985 {
@@ -1276,15 +1237,23 @@ public async Task ConcurrentLogout_WithSameSession_ShouldLeaveSessionInvalid()
12761237 CsrfTestClient . PostAsync ( client1 , "/auth/logout" , null ) ,
12771238 CsrfTestClient . PostAsync ( client2 , "/auth/logout" , null ) ) ;
12781239
1279- //
1280- // Depending on where stale-session rejection occurs,
1281- // one request may observe the session after the other revoked it.
1282- //
1283- // What must never happen is an infrastructure failure.
1284- //
1285- responses . Should ( ) . OnlyContain ( x =>
1286- x . StatusCode == HttpStatusCode . Found ||
1287- x . StatusCode == HttpStatusCode . Unauthorized ) ;
1240+ foreach ( var response in responses )
1241+ {
1242+ if ( response . StatusCode == HttpStatusCode . BadRequest )
1243+ {
1244+ var body = await response . Content . ReadAsStringAsync ( ) ;
1245+
1246+ body . Should ( ) . Contain ( "invalid_antiforgery_token" ) ;
1247+ continue ;
1248+ }
1249+
1250+ response . StatusCode . Should ( ) . BeOneOf (
1251+ HttpStatusCode . Found ,
1252+ HttpStatusCode . Unauthorized ) ;
1253+ }
1254+
1255+ responses . Should ( ) . Contain ( x =>
1256+ x . StatusCode == HttpStatusCode . Found ) ;
12881257
12891258 //
12901259 // Final state is the actual security invariant.
0 commit comments