[java-shib-attribute] branch main updated: Move filter service test down.

Scott Cantor cantor.2 at osu.edu
Wed Jun 29 16:09:44 UTC 2022


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch main
in repository java-shib-attribute.

View the commit online:
http://git.shibboleth.net/view/?p=java-shib-attribute.git;a=commit;h=590c4f43559af6d56d598ffe9b09f6c25a018aed

The following commit(s) were added to refs/heads/main by this push:
     new 590c4f435 Move filter service test down.
590c4f435 is described below

commit 590c4f43559af6d56d598ffe9b09f6c25a018aed
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Jun 29 12:09:41 2022 -0400

    Move filter service test down.
---
 shib-attribute-filter-spring/pom.xml               |  8 ++
 .../filter/spring/AttributeFilterFailFastTest.java | 98 ++++++++++++++++++++++
 .../filter/failfast/attributeFilterBad.xml         | 15 ++++
 .../filter/failfast/attributeFilterBadScript.xml   | 19 +++++
 .../filter/failfast/attributeFilterGood.xml        | 15 ++++
 .../idp/attribute/filter/failfast/filterBeans.xml  | 53 ++++++++++++
 .../filter/failfast/filterBeansDefaultFF.xml       | 52 ++++++++++++
 7 files changed, 260 insertions(+)

diff --git a/shib-attribute-filter-spring/pom.xml b/shib-attribute-filter-spring/pom.xml
index 42b232140..718b01889 100644
--- a/shib-attribute-filter-spring/pom.xml
+++ b/shib-attribute-filter-spring/pom.xml
@@ -115,6 +115,14 @@
             <scope>test</scope>
         </dependency>
 
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>shib-metadata-spring</artifactId>
+            <version>${shib-metadata.version}</version>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+
         <dependency>
             <groupId>${opensaml.groupId}</groupId>
             <artifactId>opensaml-core</artifactId>
diff --git a/shib-attribute-filter-spring/src/test/java/net/shibboleth/idp/attribute/filter/spring/AttributeFilterFailFastTest.java b/shib-attribute-filter-spring/src/test/java/net/shibboleth/idp/attribute/filter/spring/AttributeFilterFailFastTest.java
new file mode 100644
index 000000000..0cadcd7cd
--- /dev/null
+++ b/shib-attribute-filter-spring/src/test/java/net/shibboleth/idp/attribute/filter/spring/AttributeFilterFailFastTest.java
@@ -0,0 +1,98 @@
+/*
+ * 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.attribute.filter.spring;
+
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
+
+import java.io.IOException;
+
+import org.testng.annotations.Test;
+
+import net.shibboleth.idp.attribute.filter.AttributeFilter;
+import net.shibboleth.spring.testing.AbstractFailFastTest;
+import net.shibboleth.utilities.java.support.service.ReloadableService;
+import net.shibboleth.utilities.java.support.service.ServiceableComponent;
+
+ at SuppressWarnings({"unchecked", "javadoc"})
+public class AttributeFilterFailFastTest extends AbstractFailFastTest {
+    
+    protected String getPath() {
+        return "/net/shibboleth/idp/attribute/filter/failfast/";
+    }
+    
+    @Test public void workingFilter() throws IOException {
+        
+        final Object bean = getBean(propertySource("ServiceConfiguration", makePath("attributeFilterGood.xml")), "filterBeansDefaultFF.xml");
+        final ReloadableService<AttributeFilter > service = (ReloadableService<AttributeFilter>) bean;
+        assertNotNull(service);
+        final AttributeFilter resolver = service.getServiceableComponent().getComponent();
+        assertNotNull(resolver);
+    }
+
+    private void badFilter(final Boolean failFast, String filterFile) throws IOException {
+        final String beanPath;
+        if (failFast == null) {
+            beanPath = "filterBeansDefaultFF.xml";
+        } else {
+            beanPath = "filterBeans.xml";
+        }
+
+        final Object bean = getBean(propertySource("ServiceConfiguration", makePath(filterFile)), failFast, beanPath);
+        final ReloadableService<AttributeFilter > service = (ReloadableService<AttributeFilter>) bean;
+        if (null != failFast && failFast) {
+            assertNull(service);
+            return;
+        }
+        assertNotNull(service);
+        final ServiceableComponent<AttributeFilter> component = service.getServiceableComponent();
+        assertNull(component);
+    }
+    private void badFilter(final Boolean failFast) throws IOException {
+        badFilter(failFast, "attributeFilterBad.xml");
+    }
+    
+    @Test public void badFilterFailFast() throws IOException {
+        badFilter(true);
+    }
+
+    @Test public void badFilterNoFailFast() throws IOException {
+        badFilter(false);
+    }
+
+    @Test public void badFilterDefaultFailFast() throws IOException {
+        badFilter(null);
+    }
+
+    private void badScript(final Boolean failFast) throws IOException {
+        badFilter(failFast, "attributeFilterBadScript.xml");
+    }
+    
+    @Test public void badScriptFailFast() throws IOException {
+        badScript(true);
+    }
+
+    @Test public void badScriptNoFailFast() throws IOException {
+        badScript(false);
+    }
+
+    @Test public void badScriptDefaultFailFast() throws IOException {
+        badScript(null);
+    }
+
+}
diff --git a/shib-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/failfast/attributeFilterBad.xml b/shib-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/failfast/attributeFilterBad.xml
new file mode 100644
index 000000000..b8aa67d7b
--- /dev/null
+++ b/shib-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/failfast/attributeFilterBad.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<AttributeFilterPolicyGroup id="PolicyExample3"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
+        xmlns="urn:mace:shibboleth:2.0:afp"
+        xsi:schemaLocation="urn:mace:shibboleth:2.0:afp http://shibboleth.net/schema/idp/shibboleth-afp.xsd">
+
+    <AttributeFilterPolicy id="MostBasicExample">
+        <PolicyRequirementRule xsi:type="ANY"/>
+        
+        <AttributeRule attributeID="email">
+            <PermitValueRule xsi:type="Elephant"/>
+        </AttributeRule>
+    </AttributeFilterPolicy>
+    
+</AttributeFilterPolicyGroup>
diff --git a/shib-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/failfast/attributeFilterBadScript.xml b/shib-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/failfast/attributeFilterBadScript.xml
new file mode 100644
index 000000000..1af943a04
--- /dev/null
+++ b/shib-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/failfast/attributeFilterBadScript.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<AttributeFilterPolicyGroup id="PolicyExample3"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
+        xmlns="urn:mace:shibboleth:2.0:afp"
+        xsi:schemaLocation="urn:mace:shibboleth:2.0:afp http://shibboleth.net/schema/idp/shibboleth-afp.xsd">
+
+    <AttributeFilterPolicy id="MostBasicExample">
+        <PolicyRequirementRule xsi:type="ANY"/>
+        
+        <AttributeRule attributeID="email">
+    <PermitValueRule xsi:type="Script">
+        <Script>
+        <![CDATA[@@@!@"%£^$*I!P£_XJDU£K]]>
+        </Script>
+    </PermitValueRule>
+        </AttributeRule>
+    </AttributeFilterPolicy>
+    
+</AttributeFilterPolicyGroup>
diff --git a/shib-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/failfast/attributeFilterGood.xml b/shib-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/failfast/attributeFilterGood.xml
new file mode 100644
index 000000000..4441bca92
--- /dev/null
+++ b/shib-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/failfast/attributeFilterGood.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<AttributeFilterPolicyGroup id="PolicyExample3"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
+        xmlns="urn:mace:shibboleth:2.0:afp"
+        xsi:schemaLocation="urn:mace:shibboleth:2.0:afp http://shibboleth.net/schema/idp/shibboleth-afp.xsd">
+
+    <AttributeFilterPolicy id="MostBasicExample">
+        <PolicyRequirementRule xsi:type="ANY"/>
+        
+        <AttributeRule attributeID="email">
+            <PermitValueRule xsi:type="ANY"/>
+        </AttributeRule>
+    </AttributeFilterPolicy>
+    
+</AttributeFilterPolicyGroup>
diff --git a/shib-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/failfast/filterBeans.xml b/shib-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/failfast/filterBeans.xml
new file mode 100644
index 000000000..ea01c4fde
--- /dev/null
+++ b/shib-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/failfast/filterBeans.xml
@@ -0,0 +1,53 @@
+<?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">
+
+    <bean id="shibboleth.PropertySourcesPlaceholderConfigurer" destroy-method=""
+        class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer"
+        p:placeholderPrefix="%{" p:placeholderSuffix="}" />
+
+    <bean id="shibboleth.IdentifiableBeanPostProcessor" destroy-method=""
+        class="net.shibboleth.ext.spring.config.IdentifiableBeanPostProcessor" />
+
+    <!-- This bean MUST be called "conversionService" to work properly. -->
+    <bean id="conversionService" destroy-method=""
+            class="org.springframework.context.support.ConversionServiceFactoryBean">
+        <property name="converters">
+            <set>
+                <bean class="net.shibboleth.ext.spring.config.StringToIPRangeConverter" destroy-method=""/>
+                <bean class="net.shibboleth.ext.spring.config.BooleanToPredicateConverter" destroy-method=""/>
+                <bean class="net.shibboleth.ext.spring.config.StringBooleanToPredicateConverter" destroy-method=""/>
+                <bean class="net.shibboleth.ext.spring.config.StringToResourceConverter" destroy-method=""/>
+                <bean class="net.shibboleth.ext.spring.config.FunctionToFunctionConverter" destroy-method=""/>
+                <bean class="net.shibboleth.ext.spring.config.PredicateToPredicateConverter" destroy-method=""/>
+                <bean class="net.shibboleth.ext.spring.config.StringToDurationConverter" destroy-method=""/>
+            </set>
+        </property>
+    </bean>
+
+    <bean id="myParserPool"
+        class="net.shibboleth.utilities.java.support.xml.BasicParserPool"
+        p:maxPoolSize="1000"
+        p:coalescing="true" p:ignoreComments="true"
+        p:ignoreElementContentWhitespace="true" p:namespaceAware="true" />
+        
+    <bean id="shibboleth.AttributeFilterService" class="net.shibboleth.ext.spring.service.ReloadableSpringService"
+        p:serviceConfigurations="%{ServiceConfiguration}"
+        p:beanFactoryPostProcessors-ref="shibboleth.PropertySourcesPlaceholderConfigurer"
+        p:beanPostProcessors-ref="shibboleth.IdentifiableBeanPostProcessor"
+        p:reloadCheckDelay="0"
+        p:failFast="%{failFast}">
+        <constructor-arg name="claz" value="net.shibboleth.idp.attribute.filter.AttributeFilter" />
+        <constructor-arg name="strategy">
+            <bean class="net.shibboleth.idp.attribute.filter.spring.impl.AttributeFilterServiceStrategy"
+                id="ShibbolethAttributeFilter"/>
+        </constructor-arg>
+    </bean>
+</beans>
\ No newline at end of file
diff --git a/shib-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/failfast/filterBeansDefaultFF.xml b/shib-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/failfast/filterBeansDefaultFF.xml
new file mode 100644
index 000000000..9393bee71
--- /dev/null
+++ b/shib-attribute-filter-spring/src/test/resources/net/shibboleth/idp/attribute/filter/failfast/filterBeansDefaultFF.xml
@@ -0,0 +1,52 @@
+<?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">
+
+    <bean id="shibboleth.PropertySourcesPlaceholderConfigurer" destroy-method=""
+        class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer"
+        p:placeholderPrefix="%{" p:placeholderSuffix="}" />
+
+    <bean id="shibboleth.IdentifiableBeanPostProcessor" destroy-method=""
+        class="net.shibboleth.ext.spring.config.IdentifiableBeanPostProcessor" />
+
+    <!-- This bean MUST be called "conversionService" to work properly. -->
+    <bean id="conversionService" destroy-method="" 
+            class="org.springframework.context.support.ConversionServiceFactoryBean">
+        <property name="converters">
+            <set>
+                <bean class="net.shibboleth.ext.spring.config.StringToIPRangeConverter" destroy-method=""/>
+                <bean class="net.shibboleth.ext.spring.config.BooleanToPredicateConverter" destroy-method=""/>
+                <bean class="net.shibboleth.ext.spring.config.StringBooleanToPredicateConverter" destroy-method=""/>
+                <bean class="net.shibboleth.ext.spring.config.StringToResourceConverter" destroy-method=""/>
+                <bean class="net.shibboleth.ext.spring.config.FunctionToFunctionConverter" destroy-method=""/>
+                <bean class="net.shibboleth.ext.spring.config.PredicateToPredicateConverter" destroy-method=""/>
+                <bean class="net.shibboleth.ext.spring.config.StringToDurationConverter" destroy-method=""/>
+            </set>
+        </property>
+    </bean>
+
+    <bean id="myParserPool"
+        class="net.shibboleth.utilities.java.support.xml.BasicParserPool"
+        p:maxPoolSize="1000"
+        p:coalescing="true" p:ignoreComments="true"
+        p:ignoreElementContentWhitespace="true" p:namespaceAware="true" />
+        
+    <bean id="shibboleth.AttributeFilterService" class="net.shibboleth.ext.spring.service.ReloadableSpringService"
+        p:serviceConfigurations="%{ServiceConfiguration}"
+        p:beanFactoryPostProcessors-ref="shibboleth.PropertySourcesPlaceholderConfigurer"
+        p:beanPostProcessors-ref="shibboleth.IdentifiableBeanPostProcessor"
+        p:reloadCheckDelay="0">
+        <constructor-arg name="claz" value="net.shibboleth.idp.attribute.filter.AttributeFilter" />
+        <constructor-arg name="strategy">
+            <bean class="net.shibboleth.idp.attribute.filter.spring.impl.AttributeFilterServiceStrategy"
+                id="ShibbolethAttributeFilter"/>
+        </constructor-arg>
+    </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