[java-identity-provider] branch main updated: IDP-1844 - Add idp-conf flow loading integration test to detect IDP-1833
Phil Smart
philip.smart at jisc.ac.uk
Mon Jul 26 15:18:22 UTC 2021
This is an automated email from the git hooks/post-receive script.
philsmart pushed a commit to branch main
in repository java-identity-provider.
View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=5f37f196d425a13a973a23d293388bf89525b12a
The following commit(s) were added to refs/heads/main by this push:
new 5f37f196d IDP-1844 - Add idp-conf flow loading integration test to detect IDP-1833
5f37f196d is described below
commit 5f37f196d425a13a973a23d293388bf89525b12a
Author: Phil Smart <philip.smart at jisc.ac.uk>
AuthorDate: Mon Jul 26 16:18:19 2021 +0100
IDP-1844 - Add idp-conf flow loading integration test to detect IDP-1833
Add idp-conf flow loading test.
https://issues.shibboleth.net/jira/browse/IDP-1844
---
.../idp/test/flows/load/FlowLoadsFlowTest.java | 61 ++++++++++++++++++++++
.../idp/test/flows/load/LoadThisBean.java | 51 ++++++++++++++++++
.../flow-load-test/flows/import-beans.xml | 18 +++++++
.../flow-load-test/flows/test-flow-loads-beans.xml | 21 ++++++++
.../flow-load-test/flows/test-flow-loads-flow.xml | 18 +++++++
.../flow-load-test/test-webflow-config.xml | 27 ++++++++++
6 files changed, 196 insertions(+)
diff --git a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/load/FlowLoadsFlowTest.java b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/load/FlowLoadsFlowTest.java
new file mode 100644
index 000000000..d51fa4912
--- /dev/null
+++ b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/load/FlowLoadsFlowTest.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements. See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You 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
+ *
+ * http://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 net.shibboleth.idp.test.flows.load;
+
+import javax.annotation.Nonnull;
+
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.webflow.engine.Flow;
+import org.springframework.webflow.executor.FlowExecutionResult;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import net.shibboleth.idp.test.flows.AbstractFlowTest;
+
+/**
+ * Ensure a flow loads correctly. Uses the custom IdP
+ * net.shibboleth.idp.profile.spring.factory.FlowDefinitionRegistryFactoryBean.
+ */
+ at ContextConfiguration(locations = {"classpath:/flow-load-test/test-webflow-config.xml",})
+public class FlowLoadsFlowTest extends AbstractFlowTest {
+
+ @Nonnull public final static String TEST_FLOW_LOADS_ID = "test-flow-loads";
+
+ /**
+ * Ensure the flow beans configuration can import another resource using the wildcard classpath
+ * prefix. See IDP-1833.
+ * <p>Unlike many of the other idp-conf tests, this loads the custom IdP
+ * net.shibboleth.idp.profile.spring.factory.FlowDefinitionRegistryFactoryBean, see
+ * flow-load-test/test-webflow-config.xml.</p>
+ */
+ @Test
+ public void testFlowLoads_IDP1833() {
+
+ final FlowExecutionResult result = flowExecutor.launchExecution(TEST_FLOW_LOADS_ID, null, externalContext);
+
+ final Flow loadsFlow = getFlow(TEST_FLOW_LOADS_ID);
+ final LoadThisBean loadedBean = loadsFlow.getApplicationContext().getBean(LoadThisBean.class);
+
+ Assert.assertNotNull(loadedBean);
+ Assert.assertEquals(loadedBean.getMessage(), "loaded");
+ assertFlowExecutionResult(result, TEST_FLOW_LOADS_ID);
+ Assert.assertEquals(result.getOutcome().getId(), "end");
+
+ }
+
+}
diff --git a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/load/LoadThisBean.java b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/load/LoadThisBean.java
new file mode 100644
index 000000000..8fd6353ce
--- /dev/null
+++ b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/load/LoadThisBean.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements. See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You 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
+ *
+ * http://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 net.shibboleth.idp.test.flows.load;
+
+import java.util.Objects;
+
+import javax.annotation.Nonnull;
+
+/**
+ * Simple bean to load and check it was loaded correctly.
+ */
+public class LoadThisBean {
+
+ /** Set a message which can be later verified.*/
+ @Nonnull final private String message;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param msg the message to set.
+ */
+ public LoadThisBean(@Nonnull final String msg) {
+ message = Objects.requireNonNull(msg);
+ }
+
+ /**
+ * Get the message.
+ *
+ * @return Returns the message.
+ */
+ public String getMessage() {
+ return message;
+ }
+
+}
diff --git a/idp-conf/src/test/resources/flow-load-test/flows/import-beans.xml b/idp-conf/src/test/resources/flow-load-test/flows/import-beans.xml
new file mode 100644
index 000000000..9f741996b
--- /dev/null
+++ b/idp-conf/src/test/resources/flow-load-test/flows/import-beans.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:c="http://www.springframework.org/schema/c" xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:p="http://www.springframework.org/schema/p" xmlns:util="http://www.springframework.org/schema/util"
+ 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/util http://www.springframework.org/schema/util/spring-util.xsd"
+ default-init-method="initialize" default-destroy-method="destroy">
+
+ <bean class="net.shibboleth.ext.spring.config.IdentifiableBeanPostProcessor" />
+
+ <!-- ensure this bean gets imported and loaded -->
+ <bean id="LoadThisBean" class="net.shibboleth.idp.test.flows.load.LoadThisBean"
+ c:msg="loaded"/>
+
+
+</beans>
\ No newline at end of file
diff --git a/idp-conf/src/test/resources/flow-load-test/flows/test-flow-loads-beans.xml b/idp-conf/src/test/resources/flow-load-test/flows/test-flow-loads-beans.xml
new file mode 100644
index 000000000..8decf374d
--- /dev/null
+++ b/idp-conf/src/test/resources/flow-load-test/flows/test-flow-loads-beans.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:c="http://www.springframework.org/schema/c" xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:p="http://www.springframework.org/schema/p" xmlns:util="http://www.springframework.org/schema/util"
+ 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/util http://www.springframework.org/schema/util/spring-util.xsd"
+ default-init-method="initialize" default-destroy-method="destroy">
+
+ <bean class="net.shibboleth.ext.spring.config.IdentifiableBeanPostProcessor" />
+
+ <!-- Do something meaningful to make sure beans are wiring properly -->
+ <bean id="InitializeProfileRequestContext"
+ class="net.shibboleth.idp.profile.impl.InitializeProfileRequestContext"
+ scope="prototype" p:profileId="test_flow" />
+
+ <!-- ensure the wildcard classpath resource is imported. See JPAR-1833 -->
+ <import resource="classpath*:/flow-load-test/flows/import-beans.xml" />
+
+</beans>
\ No newline at end of file
diff --git a/idp-conf/src/test/resources/flow-load-test/flows/test-flow-loads-flow.xml b/idp-conf/src/test/resources/flow-load-test/flows/test-flow-loads-flow.xml
new file mode 100644
index 000000000..decf60286
--- /dev/null
+++ b/idp-conf/src/test/resources/flow-load-test/flows/test-flow-loads-flow.xml
@@ -0,0 +1,18 @@
+<flow xmlns="http://www.springframework.org/schema/webflow"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/webflow http://www.springframework.org/schema/webflow/spring-webflow.xsd">
+
+ <on-start>
+ <evaluate expression="InitializeProfileRequestContext" />
+ </on-start>
+
+ <action-state id="GotoEnd">
+ <evaluate expression="'proceed'" />
+ <transition on="proceed" to="end" />
+ </action-state>
+
+ <end-state id="end" />
+
+ <bean-import resource="test-flow-loads-beans.xml" />
+
+</flow>
diff --git a/idp-conf/src/test/resources/flow-load-test/test-webflow-config.xml b/idp-conf/src/test/resources/flow-load-test/test-webflow-config.xml
new file mode 100644
index 000000000..ddf9c3b7a
--- /dev/null
+++ b/idp-conf/src/test/resources/flow-load-test/test-webflow-config.xml
@@ -0,0 +1,27 @@
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:webflow="http://www.springframework.org/schema/webflow-config"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:p="http://www.springframework.org/schema/p"
+ 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/webflow-config http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.3.xsd">
+
+ <webflow:flow-executor id="flowExecutor" flow-registry="testFlowRegistry" />
+
+ <!-- For this test, we must use the IdP customised Flow registry and associated classes -->
+ <bean id="testFlowRegistry"
+ class="net.shibboleth.idp.profile.spring.factory.FlowDefinitionRegistryFactoryBean"
+ p:flowBuilderServices-ref="flowBuilderServices"
+ p:basePath="classpath:/flow-load-test/flows"
+ p:parent="#{getObject('shibboleth.ParentFlowRegistry')}">
+
+ <property name="flowLocations">
+ <map>
+ <entry key="test-flow-loads" value="/test-flow-loads-flow.xml"/>
+ </map>
+ </property>
+ </bean>
+
+
+</beans>
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list