[java-plugin-shibd] branch main updated: Adjust test classpath to avoid duplicate global.xml file.
Scott Cantor
cantor.2 at osu.edu
Tue Jul 2 18:27:01 UTC 2024
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch main
in repository java-plugin-shibd.
View the commit online:
http://git.shibboleth.net/view/?p=java-plugin-shibd.git;a=commit;h=c84d7aa6625f4daf105f6e20197c56d2fa9be09e
The following commit(s) were added to refs/heads/main by this push:
new c84d7aa Adjust test classpath to avoid duplicate global.xml file.
c84d7aa is described below
commit c84d7aa6625f4daf105f6e20197c56d2fa9be09e
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue Jul 2 14:26:59 2024 -0400
Adjust test classpath to avoid duplicate global.xml file.
---
sp-conf-impl/pom.xml | 17 ++++-
.../shibboleth/sp/flows/AbstractSPFlowTest.java | 34 +++++++---
.../java/net/shibboleth/sp/flows/PingFlowTest.java | 20 +++++-
sp-conf-impl/src/test/resources/logback-test.xml | 17 +++++
.../net/shibboleth/idp/module/conf/global.xml | 72 ----------------------
5 files changed, 76 insertions(+), 84 deletions(-)
diff --git a/sp-conf-impl/pom.xml b/sp-conf-impl/pom.xml
index 0c8c06e..f98d0db 100644
--- a/sp-conf-impl/pom.xml
+++ b/sp-conf-impl/pom.xml
@@ -39,6 +39,7 @@
<scope>runtime</scope>
</dependency>
+ <!-- For plugin/module classes. -->
<dependency>
<groupId>${idp.groupId}</groupId>
<artifactId>idp-admin-impl</artifactId>
@@ -157,13 +158,18 @@
<dependency>
<groupId>${idp.groupId}</groupId>
<artifactId>idp-conf-impl</artifactId>
+ <version>${idp.version}</version>
+ <type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${idp.groupId}</groupId>
<artifactId>idp-conf-impl</artifactId>
- <version>${idp.version}</version>
- <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${idp.groupId}</groupId>
+ <artifactId>idp-schema</artifactId>
<scope>test</scope>
</dependency>
<dependency>
@@ -206,7 +212,7 @@
</dependency>
<dependency>
<groupId>${spring.groupId}</groupId>
- <artifactId>spring-test</artifactId>
+ <artifactId>spring-jdbc</artifactId>
<scope>test</scope>
</dependency>
<dependency>
@@ -219,6 +225,11 @@
<artifactId>spring-webmvc</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>${spring.groupId}</groupId>
+ <artifactId>spring-test</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.codehaus.janino</groupId>
diff --git a/sp-conf-impl/src/test/java/net/shibboleth/sp/flows/AbstractSPFlowTest.java b/sp-conf-impl/src/test/java/net/shibboleth/sp/flows/AbstractSPFlowTest.java
index 28b5a00..9829569 100644
--- a/sp-conf-impl/src/test/java/net/shibboleth/sp/flows/AbstractSPFlowTest.java
+++ b/sp-conf-impl/src/test/java/net/shibboleth/sp/flows/AbstractSPFlowTest.java
@@ -20,6 +20,7 @@ import java.io.InputStream;
import java.util.Map;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import org.apache.commons.codec.binary.Base64;
import org.opensaml.profile.context.ProfileRequestContext;
@@ -82,6 +83,7 @@ public abstract class AbstractSPFlowTest extends AbstractFlowTest {
overrideEndStateOutput(flowId, endStateId);
request = new MockHttpServletRequest();
+ request.setMethod("GET");
response = new MockHttpServletResponse();
externalContext = new MockExternalContext();
externalContext.setNativeRequest(request);
@@ -114,12 +116,16 @@ public abstract class AbstractSPFlowTest extends AbstractFlowTest {
request.setParameters(parameters);
}
- protected void setBasicAuth(final String username, final String password) {
+ protected void setBasicAuth(@Nonnull final String username, @Nonnull final String password) {
request.removeHeader("Authorization");
request.addHeader("Authorization",
"Basic " + new String(Base64.encodeBase64(new String(username + ":" + password).getBytes())));
}
-
+
+ protected void setDefaultAuth() {
+ setBasicAuth("sp.example.org", "foo");
+ }
+
protected void setRequest(final String method, final String body, final String contentType) {
setRequest(request, method, body, contentType);
}
@@ -137,22 +143,34 @@ public abstract class AbstractSPFlowTest extends AbstractFlowTest {
* @param result flow result
* @param eventId value to check for
*
+ * @return output object
+ *
* @throws IOException on error
*/
- protected void assertOutputMessageEvent(@Nonnull final FlowExecutionResult result, @Nonnull final String eventId)
+ @Nullable protected DDF assertOutputMessageEvent(@Nonnull final FlowExecutionResult result, @Nullable final String eventId)
throws IOException {
final ProfileRequestContext prc = retrieveProfileRequestContext(result);
final AgentRequestContext arc = prc.ensureSubcontext(AgentRequestContext.class);
final DDF output = arc.getOutput();
- assert output != null;
- Assert.assertTrue(output.isstruct());
- Assert.assertEquals(output.getmember(EVENT_MEMBER_NAME).string(), eventId);
+
+ if (eventId != null) {
+ Assert.assertTrue(output.isstruct());
+ Assert.assertEquals(output.getmember(EVENT_MEMBER_NAME).string(), eventId);
+ } else {
+ Assert.assertTrue(!output.isstruct() || output.getmember(EVENT_MEMBER_NAME).isnull());
+ }
Assert.assertEquals(response.getContentType(), "text/plain");
+
try (final InputStream in = new ByteArrayInputStream(response.getContentAsByteArray())) {
final DDF body = DDF.deserialize(in);
- Assert.assertTrue(body.isstruct());
- Assert.assertEquals(body.getmember(EVENT_MEMBER_NAME).string(), eventId);
+ if (eventId != null) {
+ Assert.assertTrue(body.isstruct());
+ Assert.assertEquals(body.getmember(EVENT_MEMBER_NAME).string(), eventId);
+ } else {
+ Assert.assertTrue(!body.isstruct() || body.getmember(EVENT_MEMBER_NAME).isnull());
+ }
+ return body;
}
}
diff --git a/sp-conf-impl/src/test/java/net/shibboleth/sp/flows/PingFlowTest.java b/sp-conf-impl/src/test/java/net/shibboleth/sp/flows/PingFlowTest.java
index 6d9d603..bb654bf 100644
--- a/sp-conf-impl/src/test/java/net/shibboleth/sp/flows/PingFlowTest.java
+++ b/sp-conf-impl/src/test/java/net/shibboleth/sp/flows/PingFlowTest.java
@@ -15,11 +15,14 @@
package net.shibboleth.sp.flows;
import java.io.IOException;
+import java.time.Instant;
import org.springframework.webflow.executor.FlowExecutionResult;
+import org.testng.Assert;
import org.testng.annotations.Test;
import net.shibboleth.idp.authn.AuthnEventIds;
+import net.shibboleth.sp.ddf.DDF;
/**
* Unit test for the OP discovery flow.
@@ -34,7 +37,7 @@ public class PingFlowTest extends AbstractSPFlowTest {
}
/**
- * Ping flow test.
+ * Test flow without authentication.
*
* @throws IOException
*/
@@ -46,4 +49,19 @@ public class PingFlowTest extends AbstractSPFlowTest {
assertOutputMessageEvent(result, AuthnEventIds.NO_CREDENTIALS);
}
+ /**
+ * Test flow success.
+ *
+ * @throws IOException
+ */
+ @Test
+ public void testSuccess() throws IOException {
+ setDefaultAuth();
+ final FlowExecutionResult result = flowExecutor.launchExecution(FLOW_ID, null, externalContext);
+ assertFlowExecutionResult(result, FLOW_ID);
+ assertFlowExecutionOutcome(result.getOutcome());
+ final DDF obj = assertOutputMessageEvent(result, null);
+ Assert.assertTrue(obj.longinteger() <= Instant.now().toEpochMilli() / 1000);
+ }
+
}
\ No newline at end of file
diff --git a/sp-conf-impl/src/test/resources/logback-test.xml b/sp-conf-impl/src/test/resources/logback-test.xml
new file mode 100644
index 0000000..acf56c0
--- /dev/null
+++ b/sp-conf-impl/src/test/resources/logback-test.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<configuration>
+
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+ <pattern>%level [%logger:%line] - %msg%n</pattern>
+ <charset>UTF-8</charset>
+ </encoder>
+ </appender>
+
+ <root>
+ <level value="WARN" />
+ <appender-ref ref="STDOUT" />
+ </root>
+
+</configuration>
\ No newline at end of file
diff --git a/sp-conf-impl/src/test/resources/net/shibboleth/idp/module/conf/global.xml b/sp-conf-impl/src/test/resources/net/shibboleth/idp/module/conf/global.xml
deleted file mode 100644
index cfe3329..0000000
--- a/sp-conf-impl/src/test/resources/net/shibboleth/idp/module/conf/global.xml
+++ /dev/null
@@ -1,72 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:context="http://www.springframework.org/schema/context"
- xmlns:util="http://www.springframework.org/schema/util"
- xmlns:jdbc="http://www.springframework.org/schema/jdbc"
- xmlns:p="http://www.springframework.org/schema/p"
- xmlns:c="http://www.springframework.org/schema/c"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
- http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
- http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"
-
- default-init-method="initialize"
- default-destroy-method="destroy">
-
- <!-- Use this file to define any custom beans needed globally. -->
-
- <!--
- Algorithm include/exclude sets that override or merge with library defaults. Normally you can leave these
- empty or commented and use the system defaults, but you can override those defaults using these beans.
- Each <value> element is an algorithm URI; you can also use <util:constant> elements in place of literal values.
- -->
-
- <!--
- <util:set id="shibboleth.IncludedSignatureAlgorithms">
- </util:set>
-
- <util:set id="shibboleth.ExcludedSignatureAlgorithms">
- </util:set>
-
- <util:set id="shibboleth.IncludedEncryptionAlgorithms">
- </util:set>
-
- <util:set id="shibboleth.ExcludedEncryptionAlgorithms">
- </util:set>
- -->
-
- <!--
- If you need to define and inject custom Java object(s) into the various views used throughout the
- system (errors, login, logout, etc.), you can uncomment and define the bean below to be of any
- type required. It will appear in the view scope as a variable named "custom".
-
- The example below defines the bean as a map, which allows you to inject multiple objects under
- named keys to expand the feature to support multiple injected objects.
- -->
-
- <!--
- <util:map id="shibboleth.CustomViewContext">
- <entry key="foo" value="bar"/>
- </util:map>
- -->
-
- <util:set id="testbed.MetadataIndexes">
- <bean class="org.opensaml.saml.metadata.resolver.index.impl.SAMLArtifactMetadataIndex" />
- <ref bean="shibboleth.CASMetadataIndices" />
- </util:set>
-
- <bean id="exampleMetadata" class="org.springframework.core.io.ClassPathResource">
- <constructor-arg value="/metadata/example-metadata.xml"/>
- </bean>
-
- <bean id="exampleMetadata-sp123" class="org.springframework.core.io.ClassPathResource">
- <constructor-arg value="/metadata/example-sp123-metadata.xml"/>
- </bean>
-
- <util:list id="testbed.MetadataResolverResources">
- <value>%{idp.home}/conf/metadata-providers.xml</value>
- <value>%{idp.home}/conf/metadata-filters.xml</value>
- </util:list>
-
-</beans>
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list