Search in sources :

Example 16 with AssertingPartyDetails

use of org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistration.AssertingPartyDetails in project spring-security by spring-projects.

the class Saml2LoginConfigurerTests method authenticateWhenCustomAuthenticationConverterThenUses.

@Test
public void authenticateWhenCustomAuthenticationConverterThenUses() throws Exception {
    this.spring.register(CustomAuthenticationConverter.class).autowire();
    RelyingPartyRegistration relyingPartyRegistration = TestRelyingPartyRegistrations.noCredentials().assertingPartyDetails((party) -> party.verificationX509Credentials((c) -> c.add(TestSaml2X509Credentials.relyingPartyVerifyingCredential()))).build();
    String response = new String(Saml2Utils.samlDecode(SIGNED_RESPONSE));
    given(CustomAuthenticationConverter.authenticationConverter.convert(any(HttpServletRequest.class))).willReturn(new Saml2AuthenticationToken(relyingPartyRegistration, response));
    // @formatter:off
    MockHttpServletRequestBuilder request = post("/login/saml2/sso/" + relyingPartyRegistration.getRegistrationId()).param("SAMLResponse", SIGNED_RESPONSE);
    // @formatter:on
    this.mvc.perform(request).andExpect(redirectedUrl("/"));
    verify(CustomAuthenticationConverter.authenticationConverter).convert(any(HttpServletRequest.class));
}
Also used : RelyingPartyRegistration(org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistration) Saml2AuthenticationRequestRepository(org.springframework.security.saml2.provider.service.web.Saml2AuthenticationRequestRepository) BeforeEach(org.junit.jupiter.api.BeforeEach) UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder) URLDecoder(java.net.URLDecoder) FilterChainProxy(org.springframework.security.web.FilterChainProxy) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Saml2AuthenticationRequestResolver(org.springframework.security.saml2.provider.service.web.authentication.Saml2AuthenticationRequestResolver) AuthnRequest(org.opensaml.saml.saml2.core.AuthnRequest) Autowired(org.springframework.beans.factory.annotation.Autowired) AuthenticationProvider(org.springframework.security.authentication.AuthenticationProvider) ObjectPostProcessor(org.springframework.security.config.annotation.ObjectPostProcessor) HttpSecurity(org.springframework.security.config.annotation.web.builders.HttpSecurity) HttpSessionSecurityContextRepository(org.springframework.security.web.context.HttpSessionSecurityContextRepository) ServletException(jakarta.servlet.ServletException) RelyingPartyRegistration(org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistration) MockHttpServletRequestBuilder(org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder) Mockito.verifyNoInteractions(org.mockito.Mockito.verifyNoInteractions) WebSecurityConfigurerAdapter(org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) BDDMockito.given(org.mockito.BDDMockito.given) Duration(java.time.Duration) ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) Saml2AuthenticationRequestContext(org.springframework.security.saml2.provider.service.authentication.Saml2AuthenticationRequestContext) OpenSamlAuthenticationProvider(org.springframework.security.saml2.provider.service.authentication.OpenSamlAuthenticationProvider) AuthenticationException(org.springframework.security.core.AuthenticationException) DefaultRelyingPartyRegistrationResolver(org.springframework.security.saml2.provider.service.web.DefaultRelyingPartyRegistrationResolver) OpenSaml4AuthenticationRequestResolver(org.springframework.security.saml2.provider.service.web.authentication.OpenSaml4AuthenticationRequestResolver) Saml2Authentication(org.springframework.security.saml2.provider.service.authentication.Saml2Authentication) Collection(java.util.Collection) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) MockMvcResultMatchers.redirectedUrl(org.springframework.test.web.servlet.result.MockMvcResultMatchers.redirectedUrl) Instant(java.time.Instant) GrantedAuthority(org.springframework.security.core.GrantedAuthority) Test(org.junit.jupiter.api.Test) Base64(java.util.Base64) Saml2AuthenticationException(org.springframework.security.saml2.provider.service.authentication.Saml2AuthenticationException) TestSaml2AuthenticationRequestContexts(org.springframework.security.saml2.provider.service.authentication.TestSaml2AuthenticationRequestContexts) Authentication(org.springframework.security.core.Authentication) Mockito.mock(org.mockito.Mockito.mock) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) HttpServletRequest(jakarta.servlet.http.HttpServletRequest) MockFilterChain(org.springframework.mock.web.MockFilterChain) HttpRequestResponseHolder(org.springframework.security.web.context.HttpRequestResponseHolder) RelyingPartyRegistrationRepository(org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistrationRepository) SimpleGrantedAuthority(org.springframework.security.core.authority.SimpleGrantedAuthority) OpenSaml4AuthenticationProvider(org.springframework.security.saml2.provider.service.authentication.OpenSaml4AuthenticationProvider) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) TestOpenSamlObjects(org.springframework.security.saml2.provider.service.authentication.TestOpenSamlObjects) MockMvc(org.springframework.test.web.servlet.MockMvc) ArgumentCaptor(org.mockito.ArgumentCaptor) Saml2AuthenticationRequestContextResolver(org.springframework.security.saml2.provider.service.web.Saml2AuthenticationRequestContextResolver) MockMvcResultMatchers.status(org.springframework.test.web.servlet.result.MockMvcResultMatchers.status) BeanCreationException(org.springframework.beans.factory.BeanCreationException) MockMvcRequestBuilders.post(org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post) AbstractSaml2AuthenticationRequest(org.springframework.security.saml2.provider.service.authentication.AbstractSaml2AuthenticationRequest) MvcResult(org.springframework.test.web.servlet.MvcResult) Assertion(org.opensaml.saml.saml2.core.Assertion) OpenSaml4AuthenticationRequestFactory(org.springframework.security.saml2.provider.service.authentication.OpenSaml4AuthenticationRequestFactory) Assertions.assertThatExceptionOfType(org.assertj.core.api.Assertions.assertThatExceptionOfType) Converter(org.springframework.core.convert.converter.Converter) Saml2ErrorCodes(org.springframework.security.saml2.core.Saml2ErrorCodes) Saml2WebSsoAuthenticationFilter(org.springframework.security.saml2.provider.service.servlet.filter.Saml2WebSsoAuthenticationFilter) Saml2AuthenticationRequestFactory(org.springframework.security.saml2.provider.service.authentication.Saml2AuthenticationRequestFactory) Saml2AuthenticationToken(org.springframework.security.saml2.provider.service.authentication.Saml2AuthenticationToken) AuthenticationManager(org.springframework.security.authentication.AuthenticationManager) RelyingPartyRegistrationResolver(org.springframework.security.saml2.provider.service.web.RelyingPartyRegistrationResolver) AuthenticationServiceException(org.springframework.security.authentication.AuthenticationServiceException) Saml2Utils(org.springframework.security.saml2.core.Saml2Utils) Customizer(org.springframework.security.config.Customizer) Import(org.springframework.context.annotation.Import) ProviderManager(org.springframework.security.authentication.ProviderManager) Saml2AuthenticationTokenConverter(org.springframework.security.saml2.provider.service.web.Saml2AuthenticationTokenConverter) ReflectionTestUtils(org.springframework.test.util.ReflectionTestUtils) IOException(java.io.IOException) TestSaml2X509Credentials(org.springframework.security.saml2.core.TestSaml2X509Credentials) SecurityFilterChain(org.springframework.security.web.SecurityFilterChain) Mockito.verify(org.mockito.Mockito.verify) AfterEach(org.junit.jupiter.api.AfterEach) GrantedAuthoritiesMapper(org.springframework.security.core.authority.mapping.GrantedAuthoritiesMapper) EnableWebSecurity(org.springframework.security.config.annotation.web.configuration.EnableWebSecurity) SpringTestContext(org.springframework.security.config.test.SpringTestContext) Assertions(org.junit.jupiter.api.Assertions) AuthenticationConverter(org.springframework.security.web.authentication.AuthenticationConverter) MockMvcRequestBuilders.get(org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get) SpringTestContextExtension(org.springframework.security.config.test.SpringTestContextExtension) AuthenticationFailureHandler(org.springframework.security.web.authentication.AuthenticationFailureHandler) SecurityContextRepository(org.springframework.security.web.context.SecurityContextRepository) HttpServletResponse(jakarta.servlet.http.HttpServletResponse) Bean(org.springframework.context.annotation.Bean) Customizer.withDefaults(org.springframework.security.config.Customizer.withDefaults) Collections(java.util.Collections) TestRelyingPartyRegistrations(org.springframework.security.saml2.provider.service.registration.TestRelyingPartyRegistrations) UriComponents(org.springframework.web.util.UriComponents) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) HttpServletRequest(jakarta.servlet.http.HttpServletRequest) MockHttpServletRequestBuilder(org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Saml2AuthenticationToken(org.springframework.security.saml2.provider.service.authentication.Saml2AuthenticationToken) Test(org.junit.jupiter.api.Test)

Example 17 with AssertingPartyDetails

use of org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistration.AssertingPartyDetails in project spring-security by spring-projects.

the class OpenSaml3LogoutResponseResolverTests method resolveWhenCustomParametersConsumerThenUses.

@Test
public void resolveWhenCustomParametersConsumerThenUses() {
    OpenSaml3LogoutResponseResolver logoutResponseResolver = new OpenSaml3LogoutResponseResolver(this.relyingPartyRegistrationResolver);
    Consumer<LogoutResponseParameters> parametersConsumer = mock(Consumer.class);
    logoutResponseResolver.setParametersConsumer(parametersConsumer);
    MockHttpServletRequest request = new MockHttpServletRequest();
    RelyingPartyRegistration registration = TestRelyingPartyRegistrations.relyingPartyRegistration().assertingPartyDetails((party) -> party.singleLogoutServiceResponseLocation("https://ap.example.com/logout")).build();
    Authentication authentication = new TestingAuthenticationToken("user", "password");
    LogoutRequest logoutRequest = TestOpenSamlObjects.assertingPartyLogoutRequest(registration);
    request.setParameter(Saml2ParameterNames.SAML_REQUEST, Saml2Utils.samlEncode(OpenSamlSigningUtils.serialize(logoutRequest).getBytes()));
    given(this.relyingPartyRegistrationResolver.resolve(any(), any())).willReturn(registration);
    Saml2LogoutResponse logoutResponse = logoutResponseResolver.resolve(request, authentication);
    assertThat(logoutResponse).isNotNull();
    verify(parametersConsumer).accept(any());
}
Also used : RelyingPartyRegistration(org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistration) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) TestingAuthenticationToken(org.springframework.security.authentication.TestingAuthenticationToken) RelyingPartyRegistrationResolver(org.springframework.security.saml2.provider.service.web.RelyingPartyRegistrationResolver) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Saml2LogoutResponse(org.springframework.security.saml2.provider.service.authentication.logout.Saml2LogoutResponse) RelyingPartyRegistration(org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistration) LogoutResponseParameters(org.springframework.security.saml2.provider.service.web.authentication.logout.OpenSaml3LogoutResponseResolver.LogoutResponseParameters) Mockito.verify(org.mockito.Mockito.verify) Consumer(java.util.function.Consumer) Test(org.junit.jupiter.api.Test) TestOpenSamlObjects(org.springframework.security.saml2.provider.service.authentication.TestOpenSamlObjects) LogoutRequest(org.opensaml.saml.saml2.core.LogoutRequest) Saml2ParameterNames(org.springframework.security.saml2.core.Saml2ParameterNames) BDDMockito.given(org.mockito.BDDMockito.given) Assertions.assertThatExceptionOfType(org.assertj.core.api.Assertions.assertThatExceptionOfType) Authentication(org.springframework.security.core.Authentication) TestRelyingPartyRegistrations(org.springframework.security.saml2.provider.service.registration.TestRelyingPartyRegistrations) Mockito.mock(org.mockito.Mockito.mock) LogoutResponseParameters(org.springframework.security.saml2.provider.service.web.authentication.logout.OpenSaml3LogoutResponseResolver.LogoutResponseParameters) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Authentication(org.springframework.security.core.Authentication) LogoutRequest(org.opensaml.saml.saml2.core.LogoutRequest) Saml2LogoutResponse(org.springframework.security.saml2.provider.service.authentication.logout.Saml2LogoutResponse) TestingAuthenticationToken(org.springframework.security.authentication.TestingAuthenticationToken) Test(org.junit.jupiter.api.Test)

Example 18 with AssertingPartyDetails

use of org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistration.AssertingPartyDetails in project spring-security by spring-projects.

the class Saml2LogoutRequestFilterTests method doFilterWhenSamlRequestThenPosts.

@Test
public void doFilterWhenSamlRequestThenPosts() throws Exception {
    RelyingPartyRegistration registration = TestRelyingPartyRegistrations.full().assertingPartyDetails((party) -> party.singleLogoutServiceBinding(Saml2MessageBinding.POST)).build();
    Authentication authentication = new TestingAuthenticationToken("user", "password");
    SecurityContextHolder.getContext().setAuthentication(authentication);
    MockHttpServletRequest request = new MockHttpServletRequest("POST", "/logout/saml2/slo");
    request.setServletPath("/logout/saml2/slo");
    request.setParameter(Saml2ParameterNames.SAML_REQUEST, "request");
    MockHttpServletResponse response = new MockHttpServletResponse();
    given(this.relyingPartyRegistrationResolver.resolve(any(), any())).willReturn(registration);
    given(this.logoutRequestValidator.validate(any())).willReturn(Saml2LogoutValidatorResult.success());
    Saml2LogoutResponse logoutResponse = Saml2LogoutResponse.withRelyingPartyRegistration(registration).samlResponse("response").build();
    given(this.logoutResponseResolver.resolve(any(), any())).willReturn(logoutResponse);
    this.logoutRequestProcessingFilter.doFilterInternal(request, response, new MockFilterChain());
    verify(this.logoutRequestValidator).validate(any());
    verify(this.logoutHandler).logout(any(), any(), any());
    verify(this.logoutResponseResolver).resolve(any(), any());
    String content = response.getContentAsString();
    assertThat(content).contains(Saml2ParameterNames.SAML_RESPONSE);
    assertThat(content).contains(registration.getAssertingPartyDetails().getSingleLogoutServiceResponseLocation());
}
Also used : RelyingPartyRegistration(org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistration) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) MockFilterChain(org.springframework.mock.web.MockFilterChain) TestingAuthenticationToken(org.springframework.security.authentication.TestingAuthenticationToken) RelyingPartyRegistrationResolver(org.springframework.security.saml2.provider.service.web.RelyingPartyRegistrationResolver) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Saml2Error(org.springframework.security.saml2.core.Saml2Error) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Saml2LogoutResponse(org.springframework.security.saml2.provider.service.authentication.logout.Saml2LogoutResponse) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) RelyingPartyRegistration(org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistration) Saml2MessageBinding(org.springframework.security.saml2.provider.service.registration.Saml2MessageBinding) Mockito.verify(org.mockito.Mockito.verify) Mockito.verifyNoInteractions(org.mockito.Mockito.verifyNoInteractions) Test(org.junit.jupiter.api.Test) Saml2LogoutValidatorResult(org.springframework.security.saml2.provider.service.authentication.logout.Saml2LogoutValidatorResult) AfterEach(org.junit.jupiter.api.AfterEach) Saml2ParameterNames(org.springframework.security.saml2.core.Saml2ParameterNames) BDDMockito.given(org.mockito.BDDMockito.given) Saml2LogoutRequestValidator(org.springframework.security.saml2.provider.service.authentication.logout.Saml2LogoutRequestValidator) LogoutHandler(org.springframework.security.web.authentication.logout.LogoutHandler) BDDMockito.mock(org.mockito.BDDMockito.mock) Authentication(org.springframework.security.core.Authentication) SecurityContextHolder(org.springframework.security.core.context.SecurityContextHolder) TestRelyingPartyRegistrations(org.springframework.security.saml2.provider.service.registration.TestRelyingPartyRegistrations) Authentication(org.springframework.security.core.Authentication) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Saml2LogoutResponse(org.springframework.security.saml2.provider.service.authentication.logout.Saml2LogoutResponse) TestingAuthenticationToken(org.springframework.security.authentication.TestingAuthenticationToken) MockFilterChain(org.springframework.mock.web.MockFilterChain) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.jupiter.api.Test)

Example 19 with AssertingPartyDetails

use of org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistration.AssertingPartyDetails in project spring-security by spring-projects.

the class Saml2MetadataFilterTests method doFilterWhenRelyingPartyRegistrationFoundThenInvokesMetadataResolver.

@Test
public void doFilterWhenRelyingPartyRegistrationFoundThenInvokesMetadataResolver() throws Exception {
    this.request.setPathInfo("/saml2/service-provider-metadata/validRegistration");
    RelyingPartyRegistration validRegistration = TestRelyingPartyRegistrations.noCredentials().assertingPartyDetails((party) -> party.verificationX509Credentials((c) -> c.add(TestSaml2X509Credentials.relyingPartyVerifyingCredential()))).build();
    String generatedMetadata = "<xml>test</xml>";
    given(this.resolver.resolve(validRegistration)).willReturn(generatedMetadata);
    this.filter = new Saml2MetadataFilter((request) -> validRegistration, this.resolver);
    this.filter.doFilter(this.request, this.response, this.chain);
    verifyNoInteractions(this.chain);
    assertThat(this.response.getStatus()).isEqualTo(200);
    assertThat(this.response.getContentAsString()).isEqualTo(generatedMetadata);
    verify(this.resolver).resolve(validRegistration);
}
Also used : RelyingPartyRegistration(org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistration) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) BeforeEach(org.junit.jupiter.api.BeforeEach) Saml2MetadataResolver(org.springframework.security.saml2.provider.service.metadata.Saml2MetadataResolver) MockFilterChain(org.springframework.mock.web.MockFilterChain) HttpHeaders(org.springframework.http.HttpHeaders) RelyingPartyRegistrationRepository(org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistrationRepository) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) FilterChain(jakarta.servlet.FilterChain) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) TestSaml2X509Credentials(org.springframework.security.saml2.core.TestSaml2X509Credentials) StandardCharsets(java.nio.charset.StandardCharsets) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) RelyingPartyRegistration(org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistration) Mockito.verify(org.mockito.Mockito.verify) Mockito.verifyNoInteractions(org.mockito.Mockito.verifyNoInteractions) Test(org.junit.jupiter.api.Test) URLEncoder(java.net.URLEncoder) BDDMockito.given(org.mockito.BDDMockito.given) Assertions.assertThatExceptionOfType(org.assertj.core.api.Assertions.assertThatExceptionOfType) Assertions.assertThatIllegalArgumentException(org.assertj.core.api.Assertions.assertThatIllegalArgumentException) TestRelyingPartyRegistrations(org.springframework.security.saml2.provider.service.registration.TestRelyingPartyRegistrations) AntPathRequestMatcher(org.springframework.security.web.util.matcher.AntPathRequestMatcher) Mockito.mock(org.mockito.Mockito.mock) Test(org.junit.jupiter.api.Test)

Example 20 with AssertingPartyDetails

use of org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistration.AssertingPartyDetails in project spring-security by spring-projects.

the class OpenSamlLogoutResponseValidatorTests method handleWhenRedirectBindingThenValidatesSignatureParameter.

@Test
public void handleWhenRedirectBindingThenValidatesSignatureParameter() {
    RelyingPartyRegistration registration = signing(verifying(registration())).assertingPartyDetails((party) -> party.singleLogoutServiceBinding(Saml2MessageBinding.REDIRECT)).build();
    Saml2LogoutRequest logoutRequest = Saml2LogoutRequest.withRelyingPartyRegistration(registration).id("id").build();
    LogoutResponse logoutResponse = TestOpenSamlObjects.assertingPartyLogoutResponse(registration);
    Saml2LogoutResponse response = redirect(logoutResponse, registration, OpenSamlSigningUtils.sign(registration));
    Saml2LogoutResponseValidatorParameters parameters = new Saml2LogoutResponseValidatorParameters(response, logoutRequest, registration);
    this.manager.validate(parameters);
}
Also used : RelyingPartyRegistration(org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistration) Saml2ErrorCodes(org.springframework.security.saml2.core.Saml2ErrorCodes) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) LogoutResponse(org.opensaml.saml.saml2.core.LogoutResponse) QueryParametersPartial(org.springframework.security.saml2.provider.service.authentication.logout.OpenSamlSigningUtils.QueryParametersPartial) TestSaml2X509Credentials(org.springframework.security.saml2.core.TestSaml2X509Credentials) StandardCharsets(java.nio.charset.StandardCharsets) RelyingPartyRegistration(org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistration) Saml2MessageBinding(org.springframework.security.saml2.provider.service.registration.Saml2MessageBinding) Test(org.junit.jupiter.api.Test) TestOpenSamlObjects(org.springframework.security.saml2.provider.service.authentication.TestOpenSamlObjects) StatusCode(org.opensaml.saml.saml2.core.StatusCode) Saml2ParameterNames(org.springframework.security.saml2.core.Saml2ParameterNames) Map(java.util.Map) XMLObject(org.opensaml.core.xml.XMLObject) TestRelyingPartyRegistrations(org.springframework.security.saml2.provider.service.registration.TestRelyingPartyRegistrations) LogoutResponse(org.opensaml.saml.saml2.core.LogoutResponse) Test(org.junit.jupiter.api.Test)

Aggregations

RelyingPartyRegistration (org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistration)24 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)22 TestRelyingPartyRegistrations (org.springframework.security.saml2.provider.service.registration.TestRelyingPartyRegistrations)22 Test (org.junit.jupiter.api.Test)21 BDDMockito.given (org.mockito.BDDMockito.given)18 Mockito.mock (org.mockito.Mockito.mock)16 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)15 Assertions.assertThatExceptionOfType (org.assertj.core.api.Assertions.assertThatExceptionOfType)14 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)14 Saml2MessageBinding (org.springframework.security.saml2.provider.service.registration.Saml2MessageBinding)14 Mockito.verify (org.mockito.Mockito.verify)13 Authentication (org.springframework.security.core.Authentication)12 RelyingPartyRegistrationResolver (org.springframework.security.saml2.provider.service.web.RelyingPartyRegistrationResolver)12 BeforeEach (org.junit.jupiter.api.BeforeEach)11 StandardCharsets (java.nio.charset.StandardCharsets)10 TestSaml2X509Credentials (org.springframework.security.saml2.core.TestSaml2X509Credentials)9 Assertions (org.junit.jupiter.api.Assertions)8 AuthnRequest (org.opensaml.saml.saml2.core.AuthnRequest)8 Converter (org.springframework.core.convert.converter.Converter)8 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)8