[java-identity-provider] branch main updated: IDP-1840 - Add a test for the FlowRelativeResourceLoader to detect IDP-1833

Phil Smart philip.smart at jisc.ac.uk
Mon Jul 26 14:54:28 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=8203760467a90a3a2f6b2756b88ea37d133619a7

The following commit(s) were added to refs/heads/main by this push:
       new  820376046 IDP-1840 - Add a test for the FlowRelativeResourceLoader to detect IDP-1833
820376046 is described below

commit 8203760467a90a3a2f6b2756b88ea37d133619a7
Author: Phil Smart <philip.smart at jisc.ac.uk>
AuthorDate: Mon Jul 26 15:54:25 2021 +0100

    IDP-1840 - Add a test for the FlowRelativeResourceLoader to detect
    IDP-1833
    
    Add test for IDP-1833.
    
    https://issues.shibboleth.net/jira/browse/IDP-1840
---
 .../factory/FlowRelativeResourceLoaderTest.java    | 72 ++++++++++++++++++++++
 .../idp/profile/spring/factory/idp1833-beans.xml   | 17 +++++
 .../spring/factory/idp1833-flow-example.xml        |  6 ++
 3 files changed, 95 insertions(+)

diff --git a/idp-profile-spring/src/test/java/net/shibboleth/idp/profile/spring/factory/FlowRelativeResourceLoaderTest.java b/idp-profile-spring/src/test/java/net/shibboleth/idp/profile/spring/factory/FlowRelativeResourceLoaderTest.java
new file mode 100644
index 000000000..6e9292800
--- /dev/null
+++ b/idp-profile-spring/src/test/java/net/shibboleth/idp/profile/spring/factory/FlowRelativeResourceLoaderTest.java
@@ -0,0 +1,72 @@
+/*
+ * 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.profile.spring.factory;
+
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+/**
+ * Tests for the {@link FlowRelativeResourceLoader}.
+ */
+public class FlowRelativeResourceLoaderTest {
+    
+    /** The resource loader to test.*/
+    private FlowRelativeResourceLoader loader;
+    
+    
+    /**
+     * Test the getResourcesByPath method runs and correctly produces a classpath resource
+     * for a wildcard classpath. Without the fix in IDP-1833, on Windows, this would throw 
+     * a runtime exception (e.g. an InvalidFilePathException). 
+     */
+    @Test
+    public void testClasspathWildcard_GetResourceByPath_IDP1833() {
+        
+        //the 'flow' resource from which other lookups are relative.
+        Resource baseFlowResource = 
+                new ClassPathResource("classpath:/net/shibboleth/idp/profile/spring/factory/idp1833-flow-example.xml");
+        loader = new FlowRelativeResourceLoader(baseFlowResource);
+        //there is only one of these resources, but we just need to check it does not throw an RT exception.
+        final Resource resolved = 
+                loader.getResourceByPath("classpath*://net/shibboleth/idp/profile/spring/factory/idp1833-beans.xml");
+        //should result in a classpath resource
+        Assert.assertTrue(resolved instanceof ClassPathResource);
+    }
+    
+    /**
+     * Test the getResources method runs and correctly produces a classpath resource
+     * for a wildcard classpath. Without the fix in IDP-1833, on Windows, this would throw 
+     * a runtime exception (e.g. an InvalidFilePathException). 
+     */
+    @Test
+    public void testClasspathWildcard_GetResource_IDP1833() {
+        
+        //the 'flow' resource from which other lookups are relative.
+        Resource baseFlowResource = 
+                new ClassPathResource("classpath:/net/shibboleth/idp/profile/spring/factory/idp1833-flow-example.xml");
+        loader = new FlowRelativeResourceLoader(baseFlowResource);
+        //there is only one of these resources, but we just need to check it does not throw an RT exception.
+        final Resource resolved = 
+                loader.getResource("classpath*://net/shibboleth/idp/profile/spring/factory/idp1833-beans.xml");
+        //should result in a classpath resource
+        Assert.assertTrue(resolved instanceof ClassPathResource);
+    }
+
+}
diff --git a/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/factory/idp1833-beans.xml b/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/factory/idp1833-beans.xml
new file mode 100644
index 000000000..d5486ad60
--- /dev/null
+++ b/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/factory/idp1833-beans.xml
@@ -0,0 +1,17 @@
+<?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: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/util http://www.springframework.org/schema/util/spring-util.xsd"
+                           
+       default-init-method="initialize"
+       default-destroy-method="destroy">
+
+   <!-- A resource relative to idp1833-flow-example.xml. To test IDP-1833 -->
+        
+</beans>
\ No newline at end of file
diff --git a/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/factory/idp1833-flow-example.xml b/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/factory/idp1833-flow-example.xml
new file mode 100644
index 000000000..951d7052f
--- /dev/null
+++ b/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/factory/idp1833-flow-example.xml
@@ -0,0 +1,6 @@
+<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"
+      >
+      <!-- A blank flow, to serve as a relative resource location for IDP-1833 -->
+ </flow>

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list