use of org.springframework.security.oauth2.core.endpoint.OAuth2AuthorizationRequest in project spring-security by spring-projects.
the class HttpSessionOAuth2AuthorizationRequestRepositoryTests method saveAuthorizationRequestWhenExistingSessionAndDistributedSessionThenSaved.
@Test
public void saveAuthorizationRequestWhenExistingSessionAndDistributedSessionThenSaved() {
MockHttpServletRequest request = new MockHttpServletRequest();
request.setSession(new MockDistributedHttpSession());
OAuth2AuthorizationRequest authorizationRequest1 = createAuthorizationRequest().build();
this.authorizationRequestRepository.saveAuthorizationRequest(authorizationRequest1, request, new MockHttpServletResponse());
OAuth2AuthorizationRequest authorizationRequest2 = createAuthorizationRequest().build();
this.authorizationRequestRepository.saveAuthorizationRequest(authorizationRequest2, request, new MockHttpServletResponse());
request.addParameter(OAuth2ParameterNames.STATE, authorizationRequest2.getState());
OAuth2AuthorizationRequest loadedAuthorizationRequest = this.authorizationRequestRepository.loadAuthorizationRequest(request);
assertThat(loadedAuthorizationRequest).isEqualTo(authorizationRequest2);
}
use of org.springframework.security.oauth2.core.endpoint.OAuth2AuthorizationRequest in project spring-security by spring-projects.
the class HttpSessionOAuth2AuthorizationRequestRepositoryTests method saveAuthorizationRequestWhenHttpServletResponseIsNullThenThrowIllegalArgumentException.
@Test
public void saveAuthorizationRequestWhenHttpServletResponseIsNullThenThrowIllegalArgumentException() {
OAuth2AuthorizationRequest authorizationRequest = createAuthorizationRequest().build();
assertThatIllegalArgumentException().isThrownBy(() -> this.authorizationRequestRepository.saveAuthorizationRequest(authorizationRequest, new MockHttpServletRequest(), null));
}
use of org.springframework.security.oauth2.core.endpoint.OAuth2AuthorizationRequest in project spring-security by spring-projects.
the class HttpSessionOAuth2AuthorizationRequestRepositoryTests method saveAuthorizationRequestWhenStateNullThenThrowIllegalArgumentException.
@Test
public void saveAuthorizationRequestWhenStateNullThenThrowIllegalArgumentException() {
OAuth2AuthorizationRequest authorizationRequest = createAuthorizationRequest().state(null).build();
assertThatIllegalArgumentException().isThrownBy(() -> this.authorizationRequestRepository.saveAuthorizationRequest(authorizationRequest, new MockHttpServletRequest(), new MockHttpServletResponse()));
}
use of org.springframework.security.oauth2.core.endpoint.OAuth2AuthorizationRequest in project spring-security by spring-projects.
the class HttpSessionOAuth2AuthorizationRequestRepositoryTests method removeAuthorizationRequestWhenNotSavedThenNotRemoved.
@Test
public void removeAuthorizationRequestWhenNotSavedThenNotRemoved() {
MockHttpServletRequest request = new MockHttpServletRequest();
request.addParameter(OAuth2ParameterNames.STATE, "state-1234");
MockHttpServletResponse response = new MockHttpServletResponse();
OAuth2AuthorizationRequest removedAuthorizationRequest = this.authorizationRequestRepository.removeAuthorizationRequest(request, response);
assertThat(removedAuthorizationRequest).isNull();
}
use of org.springframework.security.oauth2.core.endpoint.OAuth2AuthorizationRequest in project spring-security by spring-projects.
the class HttpSessionOAuth2AuthorizationRequestRepositoryTests method saveAuthorizationRequestWhenNoExistingSessionAndDistributedSessionThenSaved.
@Test
public void saveAuthorizationRequestWhenNoExistingSessionAndDistributedSessionThenSaved() {
MockHttpServletRequest request = new MockHttpServletRequest();
request.setSession(new MockDistributedHttpSession());
OAuth2AuthorizationRequest authorizationRequest = createAuthorizationRequest().build();
this.authorizationRequestRepository.saveAuthorizationRequest(authorizationRequest, request, new MockHttpServletResponse());
request.addParameter(OAuth2ParameterNames.STATE, authorizationRequest.getState());
OAuth2AuthorizationRequest loadedAuthorizationRequest = this.authorizationRequestRepository.loadAuthorizationRequest(request);
assertThat(loadedAuthorizationRequest).isEqualTo(authorizationRequest);
}
Aggregations