Skip to content

Commit dc75f69

Browse files
committed
Merge branch 'main' into 4.0.x
2 parents 01a8d75 + c0135a0 commit dc75f69

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed

spring-boot-project/spring-boot-test-autoconfigure/build.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,19 @@ dependencies {
109109
testImplementation("org.junit.platform:junit-platform-launcher")
110110
testImplementation("org.mockito:mockito-core")
111111
testImplementation("org.mockito:mockito-junit-jupiter")
112+
testImplementation("org.opensaml:opensaml-core:4.0.1")
113+
testImplementation("org.opensaml:opensaml-saml-api:4.0.1")
114+
testImplementation("org.opensaml:opensaml-saml-impl:4.0.1")
112115
testImplementation("org.skyscreamer:jsonassert")
113116
testImplementation("org.springframework:spring-core-test")
114117
testImplementation("org.springframework.boot:spring-boot-starter-oauth2-client")
115118
testImplementation("org.springframework.hateoas:spring-hateoas")
116119
testImplementation("org.springframework.plugin:spring-plugin-core")
120+
testImplementation("org.springframework.security:spring-security-saml2-service-provider") {
121+
exclude group: "org.opensaml", module: "opensaml-core"
122+
exclude group: "org.opensaml", module: "opensaml-saml-api"
123+
exclude group: "org.opensaml", module: "opensaml-saml-impl"
124+
}
117125
testImplementation("org.thymeleaf:thymeleaf")
118126
}
119127

spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc.imports

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ org.springframework.boot.test.autoconfigure.web.servlet.MockMvcWebDriverAutoConf
55
org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientAutoConfiguration
66
org.springframework.boot.autoconfigure.security.oauth2.resource.servlet.OAuth2ResourceServerAutoConfiguration
77
org.springframework.boot.autoconfigure.security.oauth2.client.servlet.OAuth2ClientWebSecurityAutoConfiguration
8+
org.springframework.boot.autoconfigure.security.saml2.Saml2RelyingPartyAutoConfiguration
89
org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration
910
org.springframework.boot.autoconfigure.security.servlet.SecurityFilterAutoConfiguration
1011
org.springframework.boot.autoconfigure.security.servlet.UserDetailsServiceAutoConfiguration
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright 2012-2025 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc;
18+
19+
import org.junit.jupiter.api.Test;
20+
21+
import org.springframework.beans.factory.annotation.Autowired;
22+
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
23+
import org.springframework.test.web.servlet.MockMvc;
24+
25+
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get;
26+
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.redirectedUrlPattern;
27+
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
28+
29+
/**
30+
* Tests for {@link WebMvcTest @WebMvcTest} with SAML2.
31+
*
32+
* @author Dmytro Nosan
33+
*/
34+
@WebMvcTest(controllers = ExampleController1.class, properties = {
35+
"spring.security.saml2.relyingparty.registration.test.entity-id=relyingparty",
36+
"spring.security.saml2.relyingparty.registration.test.assertingparty.entity-id=assertingparty",
37+
"spring.security.saml2.relyingparty.registration.test.assertingparty.singlesignon.url=https://example.com",
38+
"spring.security.saml2.relyingparty.registration.test.assertingparty.singlesignon.sign-request=false" })
39+
class WebMvcTestSaml2Tests {
40+
41+
@Autowired
42+
private MockMvc mockMvc;
43+
44+
@Test
45+
void shouldRedirectToLogin() throws Exception {
46+
this.mockMvc.perform(get("/one"))
47+
.andExpect(status().isFound())
48+
.andExpect(redirectedUrlPattern("**/saml2/authenticate?registrationId=test"));
49+
}
50+
51+
}

0 commit comments

Comments
 (0)