@Override public MockHttpServletRequest postProcessRequest(MockHttpServletRequest request) { // TestSecurityContextHolder is only a default value SecurityContext existingContext = TestSecurityContextRepository .getContext(request); if (existingContext != null) { return request; } SecurityContext context = TestSecurityContextHolder.getContext(); if (!this.EMPTY.equals(context)) { save(context, request); } return request; } }
@Override public MockHttpServletRequest postProcessRequest(MockHttpServletRequest request) { // TestSecurityContextHolder is only a default value SecurityContext existingContext = TestSecurityContextRepository .getContext(request); if (existingContext != null) { return request; } SecurityContext context = TestSecurityContextHolder.getContext(); if (!this.EMPTY.equals(context)) { save(context, request); } return request; } }
/** * Creates a {@link RequestPostProcessor} that can be used to ensure that the * resulting request is ran with the user in the {@link TestSecurityContextHolder}. * * @return the {@link RequestPostProcessor} to sue */ public static RequestPostProcessor testSecurityContext() { return new TestSecurityContextHolderPostProcessor(); }
/** * Creates a {@link RequestPostProcessor} that can be used to ensure that the * resulting request is ran with the user in the {@link TestSecurityContextHolder}. * * @return the {@link RequestPostProcessor} to sue */ public static RequestPostProcessor testSecurityContext() { return new TestSecurityContextHolderPostProcessor(); }