/** * @since 4.0 */ @Test(expected = IllegalStateException.class) public void putValueOnInvalidatedSession() { session.invalidate(); session.putValue("name", "value"); }
@Test void testAccessConfirmationPage( @Autowired JdbcScimUserProvisioning jdbcScimUserProvisioning ) throws Exception { ScimUser marissa = jdbcScimUserProvisioning.query("username eq \"marissa\" and origin eq \"uaa\"", IdentityZoneHolder.get().getId()).get(0); UaaPrincipal uaaPrincipal = new UaaPrincipal(marissa.getId(), marissa.getUserName(), marissa.getPrimaryEmail(), marissa.getOrigin(), marissa.getExternalId(), IdentityZoneHolder.get().getId()); UaaAuthentication principal = new UaaAuthentication(uaaPrincipal, singletonList(UaaAuthority.fromAuthorities("uaa.user")), null); MockHttpSession session = new MockHttpSession(); SecurityContext securityContext = new SecurityContextImpl(); securityContext.setAuthentication(principal); session.putValue("SPRING_SECURITY_CONTEXT", securityContext); MockHttpServletRequestBuilder get = get("/oauth/authorize") .accept(TEXT_HTML) .param("response_type", "code") .param("client_id", "app") .param("state", "somestate") .param("redirect_uri", "http://localhost:8080/app/") .session(session) .principal(principal); mockMvc.perform(get) .andExpect(status().isOk()) .andExpect(forwardedUrl("/oauth/confirm_access")); }
SavedRequest savedRequest = mock(DefaultSavedRequest.class); when(savedRequest.getParameterValues("login_hint")).thenReturn(new String[]{"example.com"}); session.putValue(SAVED_REQUEST_SESSION_ATTRIBUTE, savedRequest);
MockHttpSession session = new MockHttpSession(); session.putValue("TTL", Instant.now().minusSeconds(60).toEpochMilli()); mockMvc.perform(get("/rest/message").session(session)) .andExpect(status().isOk()); assertThat((Long) session.getAttribute("TTL"), Matchers.greaterThan(Instant.now().toEpochMilli()));