Restore Format and CheckFormat for saml2 Projects

- Update the way that the saml2 projects were dependent
on identity-provider resource files.
- Use TestContainers to simplify runtime dependencies
- Update compose.yml to use Docker-standard interpolation

Closes gh-335
This commit is contained in:
Josh Cummings
2024-11-05 12:32:36 -07:00
parent 2e39e5eea6
commit d1630a6032
23 changed files with 80 additions and 337 deletions

View File

@@ -13,9 +13,6 @@ repositories {
maven { url "https://build.shibboleth.net/nexus/content/repositories/releases/" }
}
sourceSets.main.java.srcDirs += "$projectDir/../identity-provider/src/main/java"
sourceSets.main.resources.srcDirs += "$projectDir/../identity-provider/src/main/resources"
dependencies {
constraints {
implementation "org.opensaml:opensaml-saml-api:5.1.2"
@@ -27,6 +24,9 @@ dependencies {
implementation 'org.springframework.security:spring-security-saml2-service-provider'
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6'
runtimeOnly files("$projectDir/../identity-provider/build/resources/main")
testImplementation project(':servlet:spring-boot:java:saml2:identity-provider')
testImplementation 'org.htmlunit:htmlunit'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'

View File

@@ -6,3 +6,6 @@ pluginManagement {
maven { url "https://repo.spring.io/snapshot" }
}
}
include ":servlet:spring-boot:java:saml2:identity-provider"
project(":servlet:spring-boot:java:saml2:identity-provider").projectDir = file("../identity-provider")

View File

@@ -1,70 +0,0 @@
/*
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package example;
import java.io.IOException;
import java.net.ServerSocket;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.env.EnvironmentPostProcessor;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.PropertySource;
/**
* Spring Boot doesn't determine the port before the docker containers are loaded, so
* we'll decide the test port here and override the associated properties.
*
* @author Josh Cummings
*/
public class PreDockerComposeServerPortInitializer implements EnvironmentPostProcessor {
private static final Integer port = getPort();
@Override
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
environment.getPropertySources().addFirst(new ServerPortPropertySource(port));
}
private static Integer getPort() {
try (ServerSocket serverSocket = new ServerSocket(0)) {
return serverSocket.getLocalPort();
}
catch (IOException ex) {
throw new RuntimeException(ex);
}
}
private static class ServerPortPropertySource extends PropertySource<Integer> {
ServerPortPropertySource(Integer port) {
super("server.port.override", port);
}
@Override
public Object getProperty(String name) {
if ("server.port".equals(name)) {
return getSource();
}
if ("SERVER_PORT".equals(name)) {
return getSource();
}
return null;
}
}
}

View File

@@ -41,7 +41,6 @@ import static org.assertj.core.api.Assertions.assertThat;
@AutoConfigureMockMvc
public class Saml2LoginApplicationITests {
@LocalServerPort
int port;

View File

@@ -1 +0,0 @@
org.springframework.boot.env.EnvironmentPostProcessor=example.PreDockerComposeServerPortInitializer

View File

@@ -1,11 +1,9 @@
spring:
docker:
compose:
file: docker:docker/compose.yml
file: classpath:docker/compose.yml
readiness:
wait: never
skip:
in-tests: false
security:
saml2:
relyingparty: