Skip to content

Commit e1a4717

Browse files
jzheauxkwondh5217
authored andcommitted
Test Setting logoutRequestRepository
Issue spring-projectsgh-16093 Signed-off-by: Daeho Kwon <trewq231@naver.com>
1 parent cbcad6e commit e1a4717

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

config/src/test/java/org/springframework/security/config/annotation/web/configurers/saml2/Saml2LogoutConfigurerTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,7 @@ public void saml2LogoutResponseWhenCustomLogoutResponseHandlerThenUses() throws
484484
verify(getBean(Saml2LogoutResponseValidator.class)).validate(any());
485485
}
486486

487+
// gh-11363
487488
@Test
488489
public void saml2LogoutWhenCustomLogoutRequestRepositoryThenUses() throws Exception {
489490
this.spring.register(Saml2LogoutComponentsConfig.class).autowire();

config/src/test/java/org/springframework/security/config/http/Saml2LogoutBeanDefinitionParserTests.java

+17
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
import static org.assertj.core.api.Assertions.assertThat;
6464
import static org.hamcrest.Matchers.containsString;
6565
import static org.mockito.ArgumentMatchers.any;
66+
import static org.mockito.ArgumentMatchers.eq;
6667
import static org.mockito.BDDMockito.given;
6768
import static org.mockito.Mockito.atLeastOnce;
6869
import static org.mockito.Mockito.verify;
@@ -380,6 +381,22 @@ public void saml2LogoutResponseWhenCustomLogoutResponseHandlerThenUses() throws
380381
verify(getBean(Saml2LogoutResponseValidator.class)).validate(any());
381382
}
382383

384+
// gh-11363
385+
@Test
386+
public void saml2LogoutWhenCustomLogoutRequestRepositoryThenUses() throws Exception {
387+
this.spring.configLocations(this.xml("CustomComponents")).autowire();
388+
RelyingPartyRegistration registration = this.repository.findByRegistrationId("get");
389+
Saml2LogoutRequest logoutRequest = Saml2LogoutRequest.withRelyingPartyRegistration(registration)
390+
.samlRequest(this.rpLogoutRequest)
391+
.id(this.rpLogoutRequestId)
392+
.relayState(this.rpLogoutRequestRelayState)
393+
.parameters((params) -> params.put("Signature", this.rpLogoutRequestSignature))
394+
.build();
395+
given(getBean(Saml2LogoutRequestResolver.class).resolve(any(), any())).willReturn(logoutRequest);
396+
this.mvc.perform(post("/logout").with(authentication(this.saml2User)).with(csrf()));
397+
verify(getBean(Saml2LogoutRequestRepository.class)).saveLogoutRequest(eq(logoutRequest), any(), any());
398+
}
399+
383400
private <T> T getBean(Class<T> clazz) {
384401
return this.spring.getContext().getBean(clazz);
385402
}

0 commit comments

Comments
 (0)