Create JUnit tests
authorgilbert <gilbert@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Fri, 24 Jun 2005 12:55:52 +0000 (12:55 +0000)
committergilbert <gilbert@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Fri, 24 Jun 2005 12:55:52 +0000 (12:55 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@1669 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

data/spconfig.xml [new file with mode: 0644]
tests/edu/internet2/middleware/shibboleth/serviceprovider/TestContextInitializer.java

diff --git a/data/spconfig.xml b/data/spconfig.xml
new file mode 100644 (file)
index 0000000..ad123a4
--- /dev/null
@@ -0,0 +1,119 @@
+<?xml version="1.1" encoding="ISO-8859-1"?>
+
+<SPConfig xmlns="urn:mace:shibboleth:target:config:1.0"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="urn:mace:shibboleth:target:config:1.0 ../src/schemas/shibboleth-targetconfig-1.0.xsd"
+       clockSkew="180">
+
+       <Global logger="file:///usr/local/shibboleth-sp/etc/shibd.logger">
+               <UnixListener address="bogus"/>
+               <MemorySessionCache 
+                       cleanupInterval="300" 
+                       cacheTimeout="3600" 
+                       AATimeout="30" 
+                       AAConnectTimeout="15"
+                       defaultLifetime="1800" 
+                       retryInterval="300" 
+                       strictValidity="false" 
+                       propagateErrors="false"
+                       />
+       </Global>
+    
+       <Local localRelayState="true">
+               <RequestMapProvider type="edu.internet2.middleware.shibboleth.sp.provider.NativeRequestMapProvider">
+                       <RequestMap applicationId="default">
+                               <Host name="sp.example.org">
+                                       <Path name="secure" authType="shibboleth" requireSession="true" exportAssertion="true" />
+                               </Host>
+                       </RequestMap>
+               </RequestMapProvider>
+               
+       </Local>
+
+       <Applications id="default" 
+               providerId="https://sp.example.org/shibboleth"
+               homeURL="https://sp.example.org/index.html"
+               xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion"
+               xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata">
+
+               <Sessions lifetime="7200" timeout="3600" checkAddress="false"
+                       handlerURL="/Shibboleth.sso" handlerSSL="false" idpHistory="true" idpHistoryDays="7">
+                       <SessionInitiator isDefault="true" id="example" Location="/WAYF/idp.example.org"
+                               Binding="urn:mace:shibboleth:sp:1.3:SessionInit"
+                               wayfURL="https://idp.example.org:8443/shibboleth-idp/SSO"
+                               wayfBinding="urn:mace:shibboleth:1.0:profiles:AuthnRequest"/>
+                       <SessionInitiator id="IQ" Location="/WAYF/InQueue"
+                               Binding="urn:mace:shibboleth:sp:1.3:SessionInit"
+                               wayfURL="https://wayf.internet2.edu/InQueue/WAYF"
+                               wayfBinding="urn:mace:shibboleth:1.0:profiles:AuthnRequest"/>
+                       <md:AssertionConsumerService Location="/SAML/POST" isDefault="true" index="1"
+                               Binding="urn:oasis:names:tc:SAML:1.0:profiles:browser-post"/>
+                       <md:AssertionConsumerService Location="/SAML/Artifact" index="2"
+                               Binding="urn:oasis:names:tc:SAML:1.0:profiles:artifact-01"/>
+                       <md:SingleLogoutService Location="/Logout" Binding="urn:mace:shibboleth:sp:1.3:Logout"/>
+
+               </Sessions>
+
+               <Errors session="file:///usr/local/shibboleth-sp/etc/sessionError.html"
+                       metadata="file:///usr/local/shibboleth-sp/etc/metadataError.html"
+                       rm="file:///usr/local/shibboleth-sp/etc/rmError.html"
+                       access="file:///usr/local/shibboleth-sp/etc/accessError.html"
+                       supportContact="root@localhost"
+                       logoLocation="/shibtarget/logo.jpg"
+                       styleSheet="/shibtarget/main.css"/>
+
+               <CredentialUse TLS="defcreds" Signing="defcreds">
+                       <!-- RelyingParty elements can customize credentials for specific IdPs/sets. -->
+                       <!--
+                       <RelyingParty Name="urn:mace:inqueue" TLS="inqueuecreds" Signing="inqueuecreds"/>
+                       -->
+               </CredentialUse>
+                       
+               <!-- Use designators to request specific attributes or none to ask for all -->
+               <!--
+               <saml:AttributeDesignator AttributeName="urn:mace:dir:attribute-def:eduPersonScopedAffiliation"
+                       AttributeNamespace="urn:mace:shibboleth:1.0:attributeNamespace:uri"/>
+               <saml:AttributeDesignator AttributeName="urn:mace:dir:attribute-def:eduPersonTargetedID"
+                       AttributeNamespace="urn:mace:shibboleth:1.0:attributeNamespace:uri"/>
+               -->
+
+               <AAPProvider type="edu.internet2.middleware.shibboleth.aap.provider.XMLAAP" uri="file:///usr/local/shibboleth-sp/etc/AAP.xml"/>
+               
+               <MetadataProvider type="edu.internet2.middleware.shibboleth.metadata.provider.XMLMetadata"
+                       uri="file:///usr/local/shibboleth-sp/etc/example-metadata.xml"/>
+
+               <TrustProvider type="edu.internet2.middleware.shibboleth.common.provider.ShibbolethTrust"/>
+                                       
+               <saml:Audience>urn:mace:inqueue</saml:Audience>
+               
+               <Application id="bogus">
+                       <Sessions lifetime="7200" timeout="3600" checkAddress="true"
+                               handlerURL="/secure/admin/Shibboleth.sso" handlerSSL="true"
+                               cookieProps="; path=/secure/admin; secure"/>
+                       <saml:AttributeDesignator AttributeName="urn:mace:dir:attribute-def:eduPersonPrincipalName"
+                               AttributeNamespace="urn:mace:shibboleth:1.0:attributeNamespace:uri"/>
+               </Application>
+
+       </Applications>
+       
+       <!-- Define all the private keys and certificates here that you reference from <CredentialUse>. -->
+       <CredentialsProvider type="edu.internet2.middleware.shibboleth.common.Credentials">
+               <Credentials xmlns="urn:mace:shibboleth:credentials:1.0">
+                       <FileResolver Id="defcreds">
+                               <Key format="PEM">
+                                       <Path>file:///usr/local/shibboleth-sp/etc/sp-example.key</Path>
+                               </Key>
+                               <Certificate format="PEM">
+                                       <Path>file:///usr/local/shibboleth-sp/etc/sp-example.crt</Path>
+                               </Certificate>
+                       </FileResolver>
+                       
+               </Credentials>
+       </CredentialsProvider>
+
+       <!-- Specialized attribute handling for cases with complex syntax. -->
+       <AttributeFactory AttributeName="urn:oid:1.3.6.1.4.1.5923.1.1.1.10"
+               type="edu.internet2.middleware.shibboleth.common.provider.TargetedIDFactory"/>
+
+</SPConfig>
+
index b52b4d5..27d8a36 100644 (file)
@@ -1,6 +1,10 @@
 package edu.internet2.middleware.shibboleth.serviceprovider;
 
+import java.io.File;
+
+import edu.internet2.middleware.shibboleth.common.Credentials;
 import edu.internet2.middleware.shibboleth.common.ShibbolethConfigurationException;
+import edu.internet2.middleware.shibboleth.serviceprovider.ServiceProviderConfig.ApplicationInfo;
 
 public class TestContextInitializer extends SPTestCase {
        private static ServiceProviderContext context   = ServiceProviderContext.getInstance();
@@ -20,15 +24,19 @@ public class TestContextInitializer extends SPTestCase {
      * Load the typical sample configuration file from the usual place.
      */
        public void testStandardConfiguration() throws ShibbolethConfigurationException {
-               String configFileName = "file:///usr/local/shibboleth-sp/etc/sp.xml";
+               String configFileName = new File("data/spconfig.xml").toURI().toString();
                initServiceProvider(configFileName);
+               ServiceProviderConfig config = context.getServiceProviderConfig();
+               Credentials credentials = config.getCredentials();
+               ApplicationInfo appinfo = config.getApplication("default");
        }
     
+       
     /**
      * Try to load a URL that doesn't point to a file.
      */
        public void testBadConfigurationName() {
-               String configFileName = "file:///usr/local/shibboleth-sp/etc/spp.xml";
+               String configFileName = new File("data/spconfig-bogus.xml").toURI().toString();;
                try {
             initServiceProvider(configFileName);
             fail();