Skip to content

Commit eb1e6ce

Browse files
committed
Remove context path /sample-sp
Remove default port spring-projects#7260 (comment) spring-projects#7260 (comment)
1 parent 20172d6 commit eb1e6ce

File tree

4 files changed

+28
-39
lines changed

4 files changed

+28
-39
lines changed

samples/boot/saml2login/src/integration-test/java/org/springframework/security/samples/ServiceProviderMultipleIdpsTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ public static class SpringBootApplicationTestConfig {
5151

5252
@Test
5353
public void redirectToLoginPage() throws Exception {
54-
mockMvc.perform(get("http://localhost:8080/sample-sp/some/url").contextPath("/sample-sp"))
54+
mockMvc.perform(get("http://localhost:8080/some/url"))
5555
.andExpect(status().is3xxRedirection())
56-
.andExpect(redirectedUrl("http://localhost:8080/sample-sp/login"));
56+
.andExpect(redirectedUrl("http://localhost:8080/login"));
5757
}
5858

5959
@Test
6060
public void loginPage() throws Exception {
61-
mockMvc.perform(get("http://localhost:8080/sample-sp/login").contextPath("/sample-sp"))
61+
mockMvc.perform(get("http://localhost:8080/login"))
6262
.andExpect(status().isOk())
6363
.andExpect(content().string(containsString(">simplesamlphp<")))
6464
.andExpect(content().string(containsString(">simplesamlphp2<")))

samples/boot/saml2login/src/integration-test/java/org/springframework/security/samples/ServiceProviderSampleTests.java

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
*/
1616
package org.springframework.security.samples;
1717

18+
import java.security.KeyException;
19+
import java.security.PrivateKey;
20+
import java.security.PublicKey;
21+
import java.security.cert.CertificateException;
22+
import java.util.UUID;
23+
1824
import org.springframework.beans.factory.annotation.Autowired;
1925
import org.springframework.boot.SpringBootConfiguration;
2026
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@@ -54,12 +60,6 @@
5460
import org.opensaml.xmlsec.signature.support.SignatureSupport;
5561
import org.w3c.dom.Element;
5662

57-
import java.security.KeyException;
58-
import java.security.PrivateKey;
59-
import java.security.PublicKey;
60-
import java.security.cert.CertificateException;
61-
import java.util.UUID;
62-
6363
import static java.nio.charset.StandardCharsets.UTF_8;
6464
import static org.hamcrest.Matchers.containsString;
6565
import static org.hamcrest.Matchers.startsWith;
@@ -82,7 +82,7 @@
8282
@AutoConfigureMockMvc
8383
public class ServiceProviderSampleTests {
8484

85-
static final String LOCAL_SP_ENTITY_ID = "http://localhost:8080/sample-sp";
85+
static final String LOCAL_SP_ENTITY_ID = "http://localhost:8080/saml2/service-provider-metadata/simplesamlphp";
8686

8787
@Autowired
8888
MockMvc mockMvc;
@@ -95,23 +95,22 @@ public static class SpringBootApplicationTestConfig {
9595

9696
@Test
9797
public void redirectToLoginPageSingleProvider() throws Exception {
98-
mockMvc.perform(get("http://localhost:8080/sample-sp/some/url").contextPath("/sample-sp"))
98+
mockMvc.perform(get("http://localhost:8080/some/url"))
9999
.andExpect(status().is3xxRedirection())
100-
.andExpect(redirectedUrl("http://localhost:8080/sample-sp/saml2/authenticate/simplesamlphp"));
100+
.andExpect(redirectedUrl("http://localhost:8080/saml2/authenticate/simplesamlphp"));
101101
}
102102

103103
@Test
104104
public void testAuthNRequest() throws Exception {
105-
mockMvc.perform(get("http://localhost:8080/sample-sp/saml2/authenticate/simplesamlphp").contextPath("/sample-sp"))
105+
mockMvc.perform(get("http://localhost:8080/saml2/authenticate/simplesamlphp"))
106106
.andExpect(status().is3xxRedirection())
107107
.andExpect(header().string("Location", startsWith("https://simplesaml-for-spring-saml.cfapps.io/saml2/idp/SSOService.php?SAMLRequest=")));
108108
}
109109

110110
@Test
111111
public void testRelayState() throws Exception {
112112
mockMvc.perform(
113-
get("http://localhost:8080/sample-sp/saml2/authenticate/simplesamlphp")
114-
.contextPath("/sample-sp")
113+
get("http://localhost:8080/saml2/authenticate/simplesamlphp")
115114
.param("RelayState", "relay state value with spaces")
116115
)
117116
.andExpect(status().is3xxRedirection())
@@ -126,10 +125,10 @@ public void signedResponse() throws Exception {
126125
Response response = buildResponse(assertion);
127126
signXmlObject(response, getSigningCredential(idpCertificate, idpPrivateKey, UsageType.SIGNING));
128127
String xml = toXml(response);
129-
mockMvc.perform(post("http://localhost:8080/sample-sp/saml2/SSO/simplesamlphp").contextPath("/sample-sp")
128+
mockMvc.perform(post("http://localhost:8080/saml2/SSO/simplesamlphp")
130129
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
131130
.param("SAMLResponse", OpenSamlActionTestingSupport.encode(xml.getBytes(UTF_8))))
132-
.andExpect(status().is3xxRedirection()).andExpect(redirectedUrl("/sample-sp/"))
131+
.andExpect(status().is3xxRedirection()).andExpect(redirectedUrl("/"))
133132
.andExpect(authenticated().withUsername(username));
134133
}
135134

@@ -141,10 +140,10 @@ public void signedAssertion() throws Exception {
141140
signXmlObject(assertion, getSigningCredential(idpCertificate, idpPrivateKey, UsageType.SIGNING));
142141
String xml = toXml(response);
143142
final ResultActions actions = mockMvc
144-
.perform(post("http://localhost:8080/sample-sp/saml2/SSO/simplesamlphp").contextPath("/sample-sp")
143+
.perform(post("http://localhost:8080/saml2/SSO/simplesamlphp")
145144
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
146145
.param("SAMLResponse", OpenSamlActionTestingSupport.encode(xml.getBytes(UTF_8))))
147-
.andExpect(status().is3xxRedirection()).andExpect(redirectedUrl("/sample-sp/"))
146+
.andExpect(status().is3xxRedirection()).andExpect(redirectedUrl("/"))
148147
.andExpect(authenticated().withUsername(username));
149148
}
150149

@@ -153,11 +152,11 @@ public void unsigned() throws Exception {
153152
Assertion assertion = buildAssertion("[email protected]");
154153
Response response = buildResponse(assertion);
155154
String xml = toXml(response);
156-
mockMvc.perform(post("http://localhost:8080/sample-sp/saml2/SSO/simplesamlphp").contextPath("/sample-sp")
155+
mockMvc.perform(post("http://localhost:8080/saml2/SSO/simplesamlphp")
157156
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
158157
.param("SAMLResponse", OpenSamlActionTestingSupport.encode(xml.getBytes(UTF_8))))
159158
.andExpect(status().is3xxRedirection())
160-
.andExpect(redirectedUrl("/sample-sp/login?error=saml2-error"))
159+
.andExpect(redirectedUrl("/login?error=saml2-error"))
161160
.andExpect(unauthenticated());
162161
}
163162

@@ -171,10 +170,10 @@ public void signedResponseEncryptedAssertion() throws Exception {
171170
signXmlObject(assertion, getSigningCredential(idpCertificate, idpPrivateKey, UsageType.SIGNING));
172171
String xml = toXml(response);
173172
final ResultActions actions = mockMvc
174-
.perform(post("http://localhost:8080/sample-sp/saml2/SSO/simplesamlphp").contextPath("/sample-sp")
173+
.perform(post("http://localhost:8080/saml2/SSO/simplesamlphp")
175174
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
176175
.param("SAMLResponse", OpenSamlActionTestingSupport.encode(xml.getBytes(UTF_8))))
177-
.andExpect(status().is3xxRedirection()).andExpect(redirectedUrl("/sample-sp/"))
176+
.andExpect(status().is3xxRedirection()).andExpect(redirectedUrl("/"))
178177
.andExpect(authenticated().withUsername(username));
179178
}
180179

@@ -187,10 +186,10 @@ public void unsignedResponseEncryptedAssertion() throws Exception {
187186
Response response = buildResponse(encryptedAssertion);
188187
String xml = toXml(response);
189188
final ResultActions actions = mockMvc
190-
.perform(post("http://localhost:8080/sample-sp/saml2/SSO/simplesamlphp").contextPath("/sample-sp")
189+
.perform(post("http://localhost:8080/saml2/SSO/simplesamlphp")
191190
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
192191
.param("SAMLResponse", OpenSamlActionTestingSupport.encode(xml.getBytes(UTF_8))))
193-
.andExpect(status().is3xxRedirection()).andExpect(redirectedUrl("/sample-sp/"))
192+
.andExpect(status().is3xxRedirection()).andExpect(redirectedUrl("/"))
194193
.andExpect(authenticated().withUsername(username));
195194
}
196195

@@ -206,10 +205,10 @@ public void signedResponseEncryptedNameId() throws Exception {
206205
signXmlObject(assertion, getSigningCredential(idpCertificate, idpPrivateKey, UsageType.SIGNING));
207206
String xml = toXml(response);
208207
final ResultActions actions = mockMvc
209-
.perform(post("http://localhost:8080/sample-sp/saml2/SSO/simplesamlphp").contextPath("/sample-sp")
208+
.perform(post("http://localhost:8080/saml2/SSO/simplesamlphp")
210209
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
211210
.param("SAMLResponse", OpenSamlActionTestingSupport.encode(xml.getBytes(UTF_8))))
212-
.andExpect(status().is3xxRedirection()).andExpect(redirectedUrl("/sample-sp/"))
211+
.andExpect(status().is3xxRedirection()).andExpect(redirectedUrl("/"))
213212
.andExpect(authenticated().withUsername(username));
214213
}
215214

@@ -228,7 +227,7 @@ private Response buildResponse(EncryptedAssertion assertion) {
228227
private Response buildResponse() {
229228
Response response = OpenSamlActionTestingSupport.buildResponse();
230229
response.setID("_" + UUID.randomUUID().toString());
231-
response.setDestination("http://localhost:8080/sample-sp/saml2/SSO/simplesamlphp");
230+
response.setDestination("http://localhost:8080/saml2/SSO/simplesamlphp");
232231
response.setIssuer(buildIssuer("https://simplesaml-for-spring-saml.cfapps.io/saml2/idp/metadata.php"));
233232
return response;
234233
}
@@ -246,7 +245,7 @@ private Assertion buildAssertion(String username) {
246245
// as appropriate
247246
subjectConfirmation.setMethod(SubjectConfirmation.METHOD_BEARER);
248247
final SubjectConfirmationData confirmationData = buildSubjectConfirmationData(LOCAL_SP_ENTITY_ID);
249-
confirmationData.setRecipient("http://localhost:8080/sample-sp/saml2/SSO/simplesamlphp");
248+
confirmationData.setRecipient("http://localhost:8080/saml2/SSO/simplesamlphp");
250249
subjectConfirmation.setSubjectConfirmationData(confirmationData);
251250
assertion.getSubject().getSubjectConfirmations().add(subjectConfirmation);
252251
return assertion;

samples/boot/saml2login/src/main/resources/application-multipleidps.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
server:
2-
port: 8080
3-
servlet:
4-
context-path: /sample-sp
5-
61
logging:
72
level:
83
root: INFO

samples/boot/saml2login/src/main/resources/application.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
server:
2-
port: 8080
3-
servlet:
4-
context-path: /sample-sp
5-
61
logging:
72
level:
83
root: INFO

0 commit comments

Comments
 (0)