HttpSessionSecurityContextRepository support null HttpServletResponse
Closes gh-11029
This commit is contained in:
parent
759d983d62
commit
1e3106f3a2
|
@ -122,10 +122,12 @@ public class HttpSessionSecurityContextRepository implements SecurityContextRepo
|
||||||
this.logger.trace(LogMessage.format("Created %s", context));
|
this.logger.trace(LogMessage.format("Created %s", context));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SaveToSessionResponseWrapper wrappedResponse = new SaveToSessionResponseWrapper(response, request,
|
if (response != null) {
|
||||||
httpSession != null, context);
|
SaveToSessionResponseWrapper wrappedResponse = new SaveToSessionResponseWrapper(response, request,
|
||||||
requestResponseHolder.setResponse(wrappedResponse);
|
httpSession != null, context);
|
||||||
requestResponseHolder.setRequest(new SaveToSessionRequestWrapper(request, wrappedResponse));
|
requestResponseHolder.setResponse(wrappedResponse);
|
||||||
|
requestResponseHolder.setRequest(new SaveToSessionRequestWrapper(request, wrappedResponse));
|
||||||
|
}
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -133,6 +133,14 @@ public class HttpSessionSecurityContextRepositoryTests {
|
||||||
assertThat(request.getSession(false)).isNull();
|
assertThat(request.getSession(false)).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void loadContextWhenNullResponse() {
|
||||||
|
HttpSessionSecurityContextRepository repo = new HttpSessionSecurityContextRepository();
|
||||||
|
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||||
|
HttpRequestResponseHolder holder = new HttpRequestResponseHolder(request, null);
|
||||||
|
assertThat(repo.loadContext(holder)).isEqualTo(SecurityContextHolder.createEmptyContext());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void existingContextIsSuccessFullyLoadedFromSessionAndSavedBack() {
|
public void existingContextIsSuccessFullyLoadedFromSessionAndSavedBack() {
|
||||||
HttpSessionSecurityContextRepository repo = new HttpSessionSecurityContextRepository();
|
HttpSessionSecurityContextRepository repo = new HttpSessionSecurityContextRepository();
|
||||||
|
|
Loading…
Reference in New Issue