[opensaml2] 24/38: SSPCPP-684 Add test for http[s] access metadata data.

Ferenc Wágner wferi at moszumanska.debian.org
Tue Aug 30 20:53:56 UTC 2016


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

wferi pushed a commit to branch master
in repository opensaml2.

commit c66a000e5569d1477fb9b738aa49390cf504dbe0
Author: Rod Widdowson <rdw at steadingsoftware.com>
Date:   Sun Jun 5 15:14:14 2016 +0100

    SSPCPP-684 Add test for http[s] access metadata data.
    
    https://issues.shibboleth.net/jira/browse/SSPCPP-684
---
 .gitignore                                         |  1 +
 .../data/saml2/metadata/HTTPMetadataProvider.xml   | 10 +++++
 samltest/saml2/metadata/XMLMetadataProviderTest.h  | 44 ++++++++++++++++++++++
 3 files changed, 55 insertions(+)

diff --git a/.gitignore b/.gitignore
index 7df0319..7880de8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -73,3 +73,4 @@ x64
 /samltest/*.cpp
 /samltest/*/*.cpp
 /samltest/**/*.cpp
+/samltest/**/*.xml.bck*
diff --git a/samltest/data/saml2/metadata/HTTPMetadataProvider.xml b/samltest/data/saml2/metadata/HTTPMetadataProvider.xml
new file mode 100644
index 0000000..9eba9a3
--- /dev/null
+++ b/samltest/data/saml2/metadata/HTTPMetadataProvider.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<MetadataProvider type="XML" url="http://URL.TO.EXAMPLE/ORG/InCommon-metadata.xml" backingFilePath="../../../samltest/data/saml2/metadata/InCommon-metadata.xml.bck" validate="0">
+    <SignatureMetadataFilter>
+        <CredentialResolver type="File">
+            <Certificate>
+                <Path>../../../samltest/data/incommon.pem</Path>
+            </Certificate>
+        </CredentialResolver>
+    </SignatureMetadataFilter>
+</MetadataProvider>
diff --git a/samltest/saml2/metadata/XMLMetadataProviderTest.h b/samltest/saml2/metadata/XMLMetadataProviderTest.h
index a666732..e98ef4d 100644
--- a/samltest/saml2/metadata/XMLMetadataProviderTest.h
+++ b/samltest/saml2/metadata/XMLMetadataProviderTest.h
@@ -93,6 +93,50 @@ public:
         assertEquals("Entity's ID does not match requested ID", entityID, descriptor->getEntityID());
     }
 
+    void testHTTPProvider()
+    {
+        string config = data_path + "saml2/metadata/HTTPMetadataProvider.xml";
+        ifstream in(config.c_str());
+        DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in);
+        XercesJanitor<DOMDocument> janitor(doc);
+
+#if 0
+        auto_ptr_XMLCh path("path");
+        string s = data_path + "saml2/metadata/InCommon-metadata.xml";
+        auto_ptr_XMLCh file(s.c_str());
+        doc->getDocumentElement()->setAttributeNS(nullptr, path.get(), file.get());
+#endif
+        auto_ptr<MetadataProvider> metadataProvider(\
+            SAMLConfig::getConfig().MetadataProviderManager.newPlugin(XML_METADATA_PROVIDER, doc->getDocumentElement())
+            );
+        try {
+            metadataProvider->init();
+        } catch (XMLToolingException& ex) {
+            TS_TRACE(ex.what());
+            throw;
+        }
+
+        Locker locker(metadataProvider.get());
+        const EntityDescriptor* descriptor = metadataProvider->getEntityDescriptor(MetadataProvider::Criteria(entityID, nullptr, nullptr, false)).first;
+        TSM_ASSERT("Retrieved entity descriptor was null", descriptor != nullptr);
+        assertEquals("Entity's ID does not match requested ID", entityID, descriptor->getEntityID());
+        TSM_ASSERT_EQUALS("Unexpected number of roles", 1, descriptor->getIDPSSODescriptors().size());
+        TSM_ASSERT("Role lookup failed", find_if(descriptor->getIDPSSODescriptors(), isValidForProtocol(supportedProtocol)) != nullptr);
+        TSM_ASSERT("Role lookup failed", find_if(descriptor->getIDPSSODescriptors(), isValidForProtocol(supportedProtocol2)) != nullptr);
+
+        static const char* providerIdStr = "urn:mace:incommon:washington.edu";
+        auto_ptr<SAML2ArtifactType0004> artifact(
+            new SAML2ArtifactType0004(
+                SecurityHelper::doHash("SHA1", providerIdStr, strlen(providerIdStr), false), 1
+                )
+            );
+        descriptor = metadataProvider->getEntityDescriptor(MetadataProvider::Criteria(artifact.get(), nullptr, nullptr, false)).first;
+        TSM_ASSERT("Retrieved entity descriptor was null", descriptor != nullptr);
+        assertEquals("Entity's ID does not match requested ID", entityID, descriptor->getEntityID());
+    }
+
+
+
     void testXMLWithBlacklists() {
         string config = data_path + "saml2/metadata/XMLWithBlacklists.xml";
         ifstream in(config.c_str());

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-shibboleth/opensaml2.git



More information about the Pkg-shibboleth-devel mailing list