Update config tests

Signed-off-by: Liviu Gheorghe <liviu.gheorghe.ro@gmail.com>
This commit is contained in:
1livv 2024-03-04 17:28:46 +02:00 committed by Josh Cummings
parent eaf8184142
commit 358f6c96b5
2 changed files with 10 additions and 10 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2022 the original author or authors. * Copyright 2002-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -371,7 +371,7 @@ public class Saml2LogoutConfigurerTests {
} }
@Test @Test
public void saml2LogoutRequestWhenNoRegistrationThen400() throws Exception { public void saml2LogoutRequestWhenNoRegistrationThen401() throws Exception {
this.spring.register(Saml2LogoutDefaultsConfig.class).autowire(); this.spring.register(Saml2LogoutDefaultsConfig.class).autowire();
DefaultSaml2AuthenticatedPrincipal principal = new DefaultSaml2AuthenticatedPrincipal("user", DefaultSaml2AuthenticatedPrincipal principal = new DefaultSaml2AuthenticatedPrincipal("user",
Collections.emptyMap()); Collections.emptyMap());
@ -384,19 +384,19 @@ public class Saml2LogoutConfigurerTests {
.param("SigAlg", this.apLogoutRequestSigAlg) .param("SigAlg", this.apLogoutRequestSigAlg)
.param("Signature", this.apLogoutRequestSignature) .param("Signature", this.apLogoutRequestSignature)
.with(authentication(user))) .with(authentication(user)))
.andExpect(status().isBadRequest()); .andExpect(status().isUnauthorized());
verifyNoInteractions(getBean(LogoutHandler.class)); verifyNoInteractions(getBean(LogoutHandler.class));
} }
@Test @Test
public void saml2LogoutRequestWhenInvalidSamlRequestThen401() throws Exception { public void saml2LogoutRequestWhenInvalidSamlRequestThen302Redirect() throws Exception {
this.spring.register(Saml2LogoutDefaultsConfig.class).autowire(); this.spring.register(Saml2LogoutDefaultsConfig.class).autowire();
this.mvc this.mvc
.perform(get("/logout/saml2/slo").param("SAMLRequest", this.apLogoutRequest) .perform(get("/logout/saml2/slo").param("SAMLRequest", this.apLogoutRequest)
.param("RelayState", this.apLogoutRequestRelayState) .param("RelayState", this.apLogoutRequestRelayState)
.param("SigAlg", this.apLogoutRequestSigAlg) .param("SigAlg", this.apLogoutRequestSigAlg)
.with(authentication(this.user))) .with(authentication(this.user)))
.andExpect(status().isUnauthorized()); .andExpect(status().isFound());
verifyNoInteractions(getBean(LogoutHandler.class)); verifyNoInteractions(getBean(LogoutHandler.class));
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2022 the original author or authors. * Copyright 2002-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -271,7 +271,7 @@ public class Saml2LogoutBeanDefinitionParserTests {
} }
@Test @Test
public void saml2LogoutRequestWhenNoRegistrationThen400() throws Exception { public void saml2LogoutRequestWhenNoRegistrationThen401() throws Exception {
this.spring.configLocations(this.xml("Default")).autowire(); this.spring.configLocations(this.xml("Default")).autowire();
DefaultSaml2AuthenticatedPrincipal principal = new DefaultSaml2AuthenticatedPrincipal("user", DefaultSaml2AuthenticatedPrincipal principal = new DefaultSaml2AuthenticatedPrincipal("user",
Collections.emptyMap()); Collections.emptyMap());
@ -284,18 +284,18 @@ public class Saml2LogoutBeanDefinitionParserTests {
.param("SigAlg", this.apLogoutRequestSigAlg) .param("SigAlg", this.apLogoutRequestSigAlg)
.param("Signature", this.apLogoutRequestSignature) .param("Signature", this.apLogoutRequestSignature)
.with(authentication(user))) .with(authentication(user)))
.andExpect(status().isBadRequest()); .andExpect(status().isUnauthorized());
} }
@Test @Test
public void saml2LogoutRequestWhenInvalidSamlRequestThen401() throws Exception { public void saml2LogoutRequestWhenInvalidSamlRequestThen302Redirect() throws Exception {
this.spring.configLocations(this.xml("Default")).autowire(); this.spring.configLocations(this.xml("Default")).autowire();
this.mvc this.mvc
.perform(get("/logout/saml2/slo").param("SAMLRequest", this.apLogoutRequest) .perform(get("/logout/saml2/slo").param("SAMLRequest", this.apLogoutRequest)
.param("RelayState", this.apLogoutRequestRelayState) .param("RelayState", this.apLogoutRequestRelayState)
.param("SigAlg", this.apLogoutRequestSigAlg) .param("SigAlg", this.apLogoutRequestSigAlg)
.with(authentication(this.saml2User))) .with(authentication(this.saml2User)))
.andExpect(status().isUnauthorized()); .andExpect(status().isFound());
} }
@Test @Test