[java-identity-provider] 03/04: IDP-1181 Test FastFail behavior - Attribute Resolver Service

Rod Widdowson rdw at steadingsoftware.com
Fri Sep 6 06:20:19 EDT 2019


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

rdw pushed a commit to branch master
in repository java-identity-provider.

View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=873ccf1b633ca9df0d814d13c2e627b4c0263587

commit 873ccf1b633ca9df0d814d13c2e627b4c0263587
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Wed Sep 4 13:59:48 2019 +0100

    IDP-1181 Test FastFail behavior - Attribute Resolver Service
    
    https://issues.shibboleth.net/jira/browse/IDP-1181
    
    Because of depenency issues this needs to go into attribute-resolver-spring which
    complicates the base class slightly.
---
 idp-attribute-resolver-spring/pom.xml              |   7 +
 .../dc/rdbms/RDBMSDataConnectorParserTest.java     |   4 +-
 .../failfast/AttributeResolverFailFastTest.java    | 181 +++++++++++++++++++++
 .../resolver/failfast/attributeResolverBad.xml     |  20 +++
 .../resolver/failfast/attributeResolverBeans.xml   |  66 ++++++++
 .../failfast/attributeResolverBeansDefaultFF.xml   |  65 ++++++++
 .../resolver/failfast/attributeResolverGood.xml    |  20 +++
 .../resolver/failfast/attributeResolverLDAP.xml    |  22 +++
 .../resolver/failfast/attributeResolverRDBMS.xml   |  26 +++
 .../spring/failfast/AbstractFailFastTest.java      |  32 ++--
 10 files changed, 431 insertions(+), 12 deletions(-)

diff --git a/idp-attribute-resolver-spring/pom.xml b/idp-attribute-resolver-spring/pom.xml
index 66b8a7a..0ff653d 100644
--- a/idp-attribute-resolver-spring/pom.xml
+++ b/idp-attribute-resolver-spring/pom.xml
@@ -150,6 +150,13 @@
             <type>test-jar</type>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>idp-profile-spring</artifactId>
+            <version>${project.version}</version>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
 
         <dependency>
             <groupId>${opensaml.groupId}</groupId>
diff --git a/idp-attribute-resolver-spring/src/test/java/net/shibboleth/idp/attribute/resolver/spring/dc/rdbms/RDBMSDataConnectorParserTest.java b/idp-attribute-resolver-spring/src/test/java/net/shibboleth/idp/attribute/resolver/spring/dc/rdbms/RDBMSDataConnectorParserTest.java
index e351ed0..2442ffc 100644
--- a/idp-attribute-resolver-spring/src/test/java/net/shibboleth/idp/attribute/resolver/spring/dc/rdbms/RDBMSDataConnectorParserTest.java
+++ b/idp-attribute-resolver-spring/src/test/java/net/shibboleth/idp/attribute/resolver/spring/dc/rdbms/RDBMSDataConnectorParserTest.java
@@ -61,9 +61,9 @@ import net.shibboleth.idp.testing.DatabaseTestingSupport;
 /** Test for {@link RDBMSDataConnectorParser}. */
 public class RDBMSDataConnectorParserTest {
 
-    private static final String INIT_FILE = "/net/shibboleth/idp/attribute/resolver/spring/dc/rdbms/RdbmsStore.sql";
+    public static final String INIT_FILE = "/net/shibboleth/idp/attribute/resolver/spring/dc/rdbms/RdbmsStore.sql";
 
-    private static final String DATA_FILE = "/net/shibboleth/idp/attribute/resolver/spring/dc/rdbms/RdbmsData.sql";
+    public static final String DATA_FILE = "/net/shibboleth/idp/attribute/resolver/spring/dc/rdbms/RdbmsData.sql";
 
     private DataSource datasource;
 
diff --git a/idp-attribute-resolver-spring/src/test/java/net/shibboleth/idp/attribute/resolver/spring/failfast/AttributeResolverFailFastTest.java b/idp-attribute-resolver-spring/src/test/java/net/shibboleth/idp/attribute/resolver/spring/failfast/AttributeResolverFailFastTest.java
new file mode 100644
index 0000000..4e87bee
--- /dev/null
+++ b/idp-attribute-resolver-spring/src/test/java/net/shibboleth/idp/attribute/resolver/spring/failfast/AttributeResolverFailFastTest.java
@@ -0,0 +1,181 @@
+/*
+ * 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.resolver.spring.failfast;
+
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
+
+import java.io.IOException;
+import java.security.GeneralSecurityException;
+
+import javax.sql.DataSource;
+
+import org.springframework.mock.env.MockPropertySource;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+import com.unboundid.ldap.listener.InMemoryDirectoryServer;
+import com.unboundid.ldap.listener.InMemoryDirectoryServerConfig;
+import com.unboundid.ldap.listener.InMemoryListenerConfig;
+import com.unboundid.ldap.sdk.LDAPException;
+import com.unboundid.util.ssl.KeyStoreKeyManager;
+import com.unboundid.util.ssl.SSLUtil;
+import com.unboundid.util.ssl.TrustStoreTrustManager;
+
+import net.shibboleth.idp.attribute.resolver.AttributeResolver;
+import net.shibboleth.idp.attribute.resolver.spring.dc.rdbms.RDBMSDataConnectorParserTest;
+import net.shibboleth.idp.profile.spring.failfast.AbstractFailFastTest;
+import net.shibboleth.idp.testing.DatabaseTestingSupport;
+import net.shibboleth.utilities.java.support.service.ReloadableService;
+import net.shibboleth.utilities.java.support.service.ServiceableComponent;
+
+ at SuppressWarnings("unchecked")
+public class AttributeResolverFailFastTest extends AbstractFailFastTest {
+    
+    protected String getPath() {
+        return "/net/shibboleth/idp/attribute/resolver/failfast/";
+    }
+    
+    private InMemoryDirectoryServer directoryServer;
+    private DataSource datasource;
+
+    @BeforeTest public void setupDirectoryServer() throws LDAPException, GeneralSecurityException {
+        //
+        // LDAP
+        //
+        System.setProperty("org.ldaptive.provider", "org.ldaptive.provider.unboundid.UnboundIDProvider");
+        
+        final InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig("dc=shibboleth,dc=net");
+        final SSLUtil sslUtil =
+                new SSLUtil(new KeyStoreKeyManager(
+                        "src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/ldap/server.keystore",
+                        "changeit".toCharArray()), new TrustStoreTrustManager(
+                        "src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/ldap/client.keystore",
+                        "changeit".toCharArray(), "JKS", false));
+        config.setListenerConfigs(InMemoryListenerConfig.createLDAPConfig("default", null, 10389,
+                sslUtil.createSSLSocketFactory()));
+        config.addAdditionalBindCredentials("cn=Directory Manager", "password");
+        directoryServer = new InMemoryDirectoryServer(config);
+        directoryServer.importFromLDIF(true,
+                "src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/ldap/ldapDataConnectorTest.ldif");
+        directoryServer.startListening();
+        
+        //
+        // RDBMS
+        //
+        datasource = DatabaseTestingSupport.GetMockDataSource(RDBMSDataConnectorParserTest.INIT_FILE, "RDBMSDataConnectorStore");
+        DatabaseTestingSupport.InitializeDataSourceFromFile(RDBMSDataConnectorParserTest.DATA_FILE, datasource);
+
+    }
+    
+    @AfterTest public void teardownDirectoryServer() {
+        directoryServer.shutDown(true);
+        System.clearProperty("org.ldaptive.provider");
+    }
+    
+   public void workingAttributeResolver(String file) throws IOException {
+        
+        final Object bean = getBean(propertySource("ServiceConfiguration", makePath(file)), "attributeResolverBeansDefaultFF.xml");
+        final ReloadableService<AttributeResolver > service = (ReloadableService<AttributeResolver>) bean;
+        assertNotNull(service);
+        final AttributeResolver resolver = service.getServiceableComponent().getComponent();
+        assertNotNull(resolver);
+    }
+
+    @Test public void workingAttributeResolver() throws IOException {
+        workingAttributeResolver("attributeResolverGood.xml");
+    }
+
+    private void badResolver(final Boolean failFast, String resolverFile) throws IOException {
+        badResolver(new MockPropertySource("localProperties"), failFast, resolverFile);
+    }
+    
+    private void badResolver(final MockPropertySource propertySource, final Boolean failFast, final String resolverFile) throws IOException {
+        final String beanPath;
+        if (failFast == null) {
+            beanPath = "attributeResolverBeansDefaultFF.xml";
+        } else {
+            beanPath = "attributeResolverBeans.xml";
+        }
+
+        propertySource.setProperty("ServiceConfiguration", makePath(resolverFile));
+        
+        final Object bean = getBean(propertySource, failFast, beanPath);
+        final ReloadableService<AttributeResolver > service = (ReloadableService<AttributeResolver>) bean;
+        if (null != failFast && failFast) {
+            assertNull(service);
+            return;
+        }
+        assertNotNull(service);
+        final ServiceableComponent<AttributeResolver> component = service.getServiceableComponent();
+        assertNull(component);
+    }
+    
+    @Test public void badAttributeFF()  throws IOException {
+        badResolver(true, "attributeResolverBad.xml");        
+    }
+    
+    @Test public void badAttributeDefaultFF() throws IOException {
+        badResolver(null, "attributeResolverBad.xml");
+    }
+
+    @Test public void badAttributeNoFF()  throws IOException {
+        badResolver(false, "attributeResolverBad.xml");        
+    }
+
+    @Test public void workingLDAPResolver() throws IOException {
+        workingAttributeResolver("attributeResolverLDAP.xml");
+    }
+
+    private void failingLDAPResolver(final Boolean failFast) throws IOException {
+        badResolver(propertySource("port", "10390"), failFast, "attributeResolverLDAP.xml");
+    }
+    
+    @Test public void badLDAPFF() throws IOException {
+        failingLDAPResolver(true);
+    }
+    
+    @Test public void badLDAPDefault() throws IOException {
+        failingLDAPResolver(null);
+    }
+
+    @Test public void badLDAPNoFF() throws IOException {
+        failingLDAPResolver(false);
+    }
+    
+    @Test public void workingRDBMSResolver() throws IOException {
+        workingAttributeResolver("attributeResolverRDBMS.xml");
+    }
+    
+    private void failingRDBMSResolver(final Boolean failFast) throws IOException {
+        badResolver(propertySource("jdbcUserName", "SAD"), failFast, "attributeResolverRDBMS.xml");
+    }
+
+    @Test public void failingRDBMSResolverFF() throws IOException {
+        failingRDBMSResolver(true);
+    }
+
+    @Test public void failingRDBMSResolverDefault() throws IOException {
+        failingRDBMSResolver(null);
+    }
+
+    @Test public void failingRDBMSResolverNoFF() throws IOException {
+        failingRDBMSResolver(false);
+    }
+}
diff --git a/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/failfast/attributeResolverBad.xml b/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/failfast/attributeResolverBad.xml
new file mode 100644
index 0000000..7d5dec8
--- /dev/null
+++ b/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/failfast/attributeResolverBad.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<AttributeResolver
+        xmlns="urn:mace:shibboleth:2.0:resolver" 
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
+        xsi:schemaLocation="urn:mace:shibboleth:2.0:resolver http://shibboleth.net/schema/idp/shibboleth-attribute-resolver.xsd">
+
+    <AttributeDefinition id="Uid" xsi:type="Simple">
+        <InputDataConnector ref="dataConnector" attributeNames="uid" />
+    </AttributeDefinition>
+
+    <DataConnector id="dataConnector" xsi:type="Static">
+        <Attribute id="affiliation">
+            <Value>member</Value>
+        </Attribute>
+        <Attribute id="uid">
+            <Value>diu</Value>
+        </FlibbyFlobby>
+    </DataConnector>
+
+</AttributeResolver>
diff --git a/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/failfast/attributeResolverBeans.xml b/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/failfast/attributeResolverBeans.xml
new file mode 100644
index 0000000..9c1782e
--- /dev/null
+++ b/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/failfast/attributeResolverBeans.xml
@@ -0,0 +1,66 @@
+<?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"
+        class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer"
+        p:placeholderPrefix="%{" p:placeholderSuffix="}" />
+
+   <bean id="shibboleth.IdentifiableBeanPostProcessor" class="net.shibboleth.ext.spring.config.IdentifiableBeanPostProcessor" />
+
+    <!-- This bean MUST be called "conversionService" to work properly. -->
+    <bean id="conversionService" class="org.springframework.context.support.ConversionServiceFactoryBean">
+        <property name="converters">
+            <set>
+                <bean class="net.shibboleth.ext.spring.config.StringToIPRangeConverter" />
+                <bean class="net.shibboleth.ext.spring.config.BooleanToPredicateConverter" />
+                <bean class="net.shibboleth.ext.spring.config.StringBooleanToPredicateConverter" />
+                <bean class="net.shibboleth.ext.spring.config.StringToResourceConverter" />
+                <bean class="net.shibboleth.ext.spring.config.FunctionToFunctionConverter" />
+                <bean class="net.shibboleth.ext.spring.config.PredicateToPredicateConverter" />
+                <bean class="net.shibboleth.ext.spring.config.StringToDurationConverter" />
+            </set>
+        </property>
+    </bean>
+    
+    <bean id="shibboleth.VelocityEngine" class="net.shibboleth.ext.spring.velocity.VelocityEngineFactoryBean">
+        <property name="velocityProperties">
+            <props>
+                <prop key="resource.loader">classpath, string</prop>
+                <prop key="classpath.resource.loader.class">
+                    org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
+                </prop>
+                <prop key="string.resource.loader.class">
+                    org.apache.velocity.runtime.resource.loader.StringResourceLoader
+                </prop>
+            </props>
+        </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.AttributeResolverService" class="net.shibboleth.ext.spring.service.ReloadableSpringService" 
+        p:serviceConfigurations="%{ServiceConfiguration}"
+        p:beanFactoryPostProcessors-ref="shibboleth.PropertySourcesPlaceholderConfigurer"
+        p:beanPostProcessors-ref="shibboleth.IdentifiableBeanPostProcessor"
+        p:failFast="%{failFast}" 
+        p:reloadCheckDelay="0">
+        <constructor-arg name="claz" value="net.shibboleth.idp.attribute.resolver.AttributeResolver" />
+        <constructor-arg name="strategy">
+            <bean class="net.shibboleth.idp.attribute.resolver.spring.impl.AttributeResolverServiceStrategy"
+                p:stripNulls="%{idp.service.attribute.resolver.stripNulls:false}"
+                id="ShibbolethAttributeResolver"/>
+        </constructor-arg>
+    </bean>
+</beans>
\ No newline at end of file
diff --git a/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/failfast/attributeResolverBeansDefaultFF.xml b/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/failfast/attributeResolverBeansDefaultFF.xml
new file mode 100644
index 0000000..734f3bb
--- /dev/null
+++ b/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/failfast/attributeResolverBeansDefaultFF.xml
@@ -0,0 +1,65 @@
+<?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"
+        class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer"
+        p:placeholderPrefix="%{" p:placeholderSuffix="}" />
+
+   <bean id="shibboleth.IdentifiableBeanPostProcessor" class="net.shibboleth.ext.spring.config.IdentifiableBeanPostProcessor" />
+
+    <!-- This bean MUST be called "conversionService" to work properly. -->
+    <bean id="conversionService" class="org.springframework.context.support.ConversionServiceFactoryBean">
+        <property name="converters">
+            <set>
+                <bean class="net.shibboleth.ext.spring.config.StringToIPRangeConverter" />
+                <bean class="net.shibboleth.ext.spring.config.BooleanToPredicateConverter" />
+                <bean class="net.shibboleth.ext.spring.config.StringBooleanToPredicateConverter" />
+                <bean class="net.shibboleth.ext.spring.config.StringToResourceConverter" />
+                <bean class="net.shibboleth.ext.spring.config.FunctionToFunctionConverter" />
+                <bean class="net.shibboleth.ext.spring.config.PredicateToPredicateConverter" />
+                <bean class="net.shibboleth.ext.spring.config.StringToDurationConverter" />
+            </set>
+        </property>
+    </bean>
+
+    <bean id="shibboleth.VelocityEngine" class="net.shibboleth.ext.spring.velocity.VelocityEngineFactoryBean">
+        <property name="velocityProperties">
+            <props>
+                <prop key="resource.loader">classpath, string</prop>
+                <prop key="classpath.resource.loader.class">
+                    org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
+                </prop>
+                <prop key="string.resource.loader.class">
+                    org.apache.velocity.runtime.resource.loader.StringResourceLoader
+                </prop>
+            </props>
+        </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.AttributeResolverService" 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.resolver.AttributeResolver" />
+        <constructor-arg name="strategy">
+            <bean class="net.shibboleth.idp.attribute.resolver.spring.impl.AttributeResolverServiceStrategy"
+                p:stripNulls="%{idp.service.attribute.resolver.stripNulls:false}"
+                id="ShibbolethAttributeResolver"/>
+        </constructor-arg>
+    </bean>
+</beans>
\ No newline at end of file
diff --git a/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/failfast/attributeResolverGood.xml b/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/failfast/attributeResolverGood.xml
new file mode 100644
index 0000000..e228fd8
--- /dev/null
+++ b/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/failfast/attributeResolverGood.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<AttributeResolver
+        xmlns="urn:mace:shibboleth:2.0:resolver" 
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
+        xsi:schemaLocation="urn:mace:shibboleth:2.0:resolver http://shibboleth.net/schema/idp/shibboleth-attribute-resolver.xsd">
+
+    <AttributeDefinition id="Uid" xsi:type="Simple">
+        <InputDataConnector ref="dataConnector" attributeNames="uid" />
+    </AttributeDefinition>
+
+    <DataConnector id="dataConnector" xsi:type="Static">
+        <Attribute id="affiliation">
+            <Value>member</Value>
+        </Attribute>
+        <Attribute id="uid">
+            <Value>diu</Value>
+        </Attribute>
+    </DataConnector>
+
+</AttributeResolver>
diff --git a/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/failfast/attributeResolverLDAP.xml b/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/failfast/attributeResolverLDAP.xml
new file mode 100644
index 0000000..7e6b6ec
--- /dev/null
+++ b/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/failfast/attributeResolverLDAP.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<AttributeResolver
+        xmlns="urn:mace:shibboleth:2.0:resolver" 
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
+        xsi:schemaLocation="urn:mace:shibboleth:2.0:resolver http://shibboleth.net/schema/idp/shibboleth-attribute-resolver.xsd">
+
+    <AttributeDefinition id="Uid" xsi:type="Simple">
+        <InputDataConnector ref="dataConnector" attributeNames="uid" />
+    </AttributeDefinition>
+    
+    <DataConnector id="dataConnector" xsi:type="LDAPDirectory"
+        ldapURL="ldap://localhost:%{port:10389}"
+        principal="cn=Directory Manager"
+        principalCredential="password">
+        <FilterTemplate>
+            <![CDATA[
+                (uid=${resolutionContext.principal})
+            ]]>
+        </FilterTemplate>
+    </DataConnector>
+    
+</AttributeResolver>
diff --git a/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/failfast/attributeResolverRDBMS.xml b/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/failfast/attributeResolverRDBMS.xml
new file mode 100644
index 0000000..b5696a7
--- /dev/null
+++ b/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/failfast/attributeResolverRDBMS.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<AttributeResolver
+        xmlns="urn:mace:shibboleth:2.0:resolver" 
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
+        xsi:schemaLocation="urn:mace:shibboleth:2.0:resolver http://shibboleth.net/schema/idp/shibboleth-attribute-resolver.xsd">
+
+    <AttributeDefinition id="Uid" xsi:type="Simple">
+        <InputDataConnector ref="dataConnector" attributeNames="uid" />
+    </AttributeDefinition>
+    
+    <DataConnector id="dataConnector" xsi:type="RelationalDatabase"
+        noResultIsError="true"
+        multipleResultsIsError="true"
+        readOnlyConnection="false"
+        noRetryDelay="PT5M">
+      <SimpleManagedConnection
+        jdbcDriver="org.hsqldb.jdbc.JDBCDriver"
+        jdbcURL="jdbc:hsqldb:mem:RDBMSDataConnectorStore"
+        jdbcUserName="%{jdbcUserName:SA}"
+        jdbcPassword=""/>
+        <QueryTemplate><![CDATA[SELECT * FROM people WHERE userid='%s']]></QueryTemplate>
+        <Column columnName="homephone" attributeID="phonenumber" />
+        <ResultCache expireAfterAccess="PT10S"/>
+    </DataConnector>
+    
+</AttributeResolver>
diff --git a/idp-profile-spring/src/test/java/net/shibboleth/idp/profile/spring/failfast/AbstractFailFastTest.java b/idp-profile-spring/src/test/java/net/shibboleth/idp/profile/spring/failfast/AbstractFailFastTest.java
index e099796..0b97066 100644
--- a/idp-profile-spring/src/test/java/net/shibboleth/idp/profile/spring/failfast/AbstractFailFastTest.java
+++ b/idp-profile-spring/src/test/java/net/shibboleth/idp/profile/spring/failfast/AbstractFailFastTest.java
@@ -26,12 +26,14 @@ import java.util.Iterator;
 import java.util.List;
 
 import org.opensaml.core.OpenSAMLInitBaseTestCase;
+import org.slf4j.LoggerFactory;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.support.GenericApplicationContext;
 import org.springframework.core.io.ClassPathResource;
 import org.springframework.core.io.Resource;
 import org.springframework.mock.env.MockPropertySource;
 import org.testng.annotations.AfterSuite;
+import org.testng.annotations.BeforeClass;
 import org.testng.annotations.BeforeSuite;
 
 import net.shibboleth.ext.spring.util.ApplicationContextBuilder;
@@ -45,9 +47,7 @@ import net.shibboleth.utilities.java.support.service.ReloadableService;
  */
 public class AbstractFailFastTest extends OpenSAMLInitBaseTestCase {
 
-    private static final String PATH = "/net/shibboleth/idp/profile/spring/failfast/";
-
-    static private String workspaceDirName;
+    private String workspaceDirName;
 
     static List<GenericApplicationContext> contexts;
 
@@ -56,12 +56,23 @@ public class AbstractFailFastTest extends OpenSAMLInitBaseTestCase {
             contexts.add(context);
         }        
     }
-    
+
+    protected String getPath() {
+        return "/net/shibboleth/idp/profile/spring/failfast/";
+    }
+
+    protected String getWorkspaceDirName() {
+        return workspaceDirName;
+    }
+
     @BeforeSuite public void beforeSuite() throws IOException {
+        contexts = new ArrayList<>();
+    }
+
+    @BeforeClass public void beforeClass() throws IOException {
         final ClassPathResource resource =
-                new ClassPathResource(PATH);
+                new ClassPathResource(getPath());
         workspaceDirName = resource.getFile().getAbsolutePath() + "/";
-        contexts = new ArrayList<>();
     }
 
     @SuppressWarnings("resource")
@@ -81,7 +92,7 @@ public class AbstractFailFastTest extends OpenSAMLInitBaseTestCase {
         final Resource[] resources = new Resource[files.length];
 
         for (int i = 0; i < files.length; i++) {
-            resources[i] = new ClassPathResource(PATH + files[i]);
+            resources[i] = new ClassPathResource(getPath() + files[i]);
         }
 
         final ApplicationContextBuilder builder = new ApplicationContextBuilder();
@@ -122,6 +133,7 @@ public class AbstractFailFastTest extends OpenSAMLInitBaseTestCase {
             final ApplicationContext context = getApplicationContext(claz.getCanonicalName(), propSource, files);
             return SpringSupport.getBean(context, claz);
         } catch (Exception e) {
+            LoggerFactory.getLogger(AbstractFailFastTest.class).debug("GetAppContext failed",e);
             return null;
         }
     }
@@ -145,16 +157,16 @@ public class AbstractFailFastTest extends OpenSAMLInitBaseTestCase {
     }
 
     protected String makePath(final String filePart) {
-        return workspaceDirName +  filePart;
+        return getWorkspaceDirName()  +  filePart;
     }
 
     protected String makeTempPath(final String filePart) {
-        return workspaceDirName +  filePart;
+        return getWorkspaceDirName()  +  filePart;
     }
 
     protected String makeURLPath(final String filePart) {
         return RepositorySupport.buildHTTPResourceURL("java-identity-provider", 
-                "idp-profile-spring/src/test/resources" + PATH + filePart,
+                "idp-profile-spring/src/test/resources" + getPath() + filePart,
                 false);
     }
 }

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


More information about the commits mailing list