[shibboleth-sp2] 14/23: SSPCPP-756 Add tests for LocalDynamic provider

Ferenc Wágner wferi at moszumanska.debian.org
Wed Feb 21 10:57:07 UTC 2018


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

wferi pushed a commit to branch master
in repository shibboleth-sp2.

commit fd1b4eabd899b15d0ddbf92b3d3ea2b409c04b72
Author: Rod Widdowson <rdw at steadingsoftware.com>
Date:   Fri Dec 1 11:55:09 2017 +0000

    SSPCPP-756  Add tests for LocalDynamic provider
    
    https://issues.shibboleth.net/jira/browse/SSPCPP-756
    
    Also strip out a lot of dead wood around old functional testing.
---
 Projects/vc15/UnitTests/UnitTests.vcxproj         |  4 +-
 Projects/vc15/UnitTests/UnitTests.vcxproj.filters | 12 ++----
 unittests/DynamicMetadataProviderTest.h           | 45 ++++++++---------------
 unittests/data/localDynamic.xml                   |  1 +
 unittests/data/regexFromFile.xml                  |  4 --
 unittests/data/staticFromFile.xml                 |  1 -
 unittests/data/templateFromFile.xml               |  3 --
 7 files changed, 21 insertions(+), 49 deletions(-)

diff --git a/Projects/vc15/UnitTests/UnitTests.vcxproj b/Projects/vc15/UnitTests/UnitTests.vcxproj
index 0f85b1e..3b61856 100644
--- a/Projects/vc15/UnitTests/UnitTests.vcxproj
+++ b/Projects/vc15/UnitTests/UnitTests.vcxproj
@@ -183,11 +183,9 @@
     <Xml Include="..\..\..\unittests\data\df5a20c921bc30c1b76c5a6cec08d074e280de8b.xml" />
     <Xml Include="..\..\..\unittests\data\fromMDQ.xml" />
     <Xml Include="..\..\..\unittests\data\idp.shibboleth.net.xml" />
-    <Xml Include="..\..\..\unittests\data\staticFromFile.xml" />
-    <Xml Include="..\..\..\unittests\data\templateFromFile.xml">
+    <Xml Include="..\..\..\unittests\data\localDynamic.xml">
       <SubType>Designer</SubType>
     </Xml>
-    <Xml Include="..\..\..\unittests\data\regexFromFile.xml" />
     <Xml Include="..\..\..\unittests\data\templateFromRepo.xml" />
   </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
diff --git a/Projects/vc15/UnitTests/UnitTests.vcxproj.filters b/Projects/vc15/UnitTests/UnitTests.vcxproj.filters
index fb59a9b..b261e86 100644
--- a/Projects/vc15/UnitTests/UnitTests.vcxproj.filters
+++ b/Projects/vc15/UnitTests/UnitTests.vcxproj.filters
@@ -41,21 +41,12 @@
     </ClCompile>
   </ItemGroup>
   <ItemGroup>
-    <Xml Include="..\..\..\unittests\data\templateFromFile.xml">
-      <Filter>Data</Filter>
-    </Xml>
     <Xml Include="..\..\..\unittests\data\templateFromRepo.xml">
       <Filter>Data</Filter>
     </Xml>
-    <Xml Include="..\..\..\unittests\data\regexFromFile.xml">
-      <Filter>Data</Filter>
-    </Xml>
     <Xml Include="..\..\..\unittests\data\fromMDQ.xml">
       <Filter>Data</Filter>
     </Xml>
-    <Xml Include="..\..\..\unittests\data\staticFromFile.xml">
-      <Filter>Data</Filter>
-    </Xml>
     <Xml Include="..\..\..\unittests\data\idp.shibboleth.net.xml">
       <Filter>Data\Metadata</Filter>
     </Xml>
@@ -65,6 +56,9 @@
     <Xml Include="..\..\..\unittests\data\chainedFromURL.xml">
       <Filter>Data</Filter>
     </Xml>
+    <Xml Include="..\..\..\unittests\data\localDynamic.xml">
+      <Filter>Data</Filter>
+    </Xml>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\..\unittests\BaseTestCase.h">
diff --git a/unittests/DynamicMetadataProviderTest.h b/unittests/DynamicMetadataProviderTest.h
index 651d461..92d1971 100644
--- a/unittests/DynamicMetadataProviderTest.h
+++ b/unittests/DynamicMetadataProviderTest.h
@@ -53,9 +53,11 @@ extern string data_path;
 class DynamicMetadataTest : public CxxTest::TestSuite {
  private:
     const string m_entityId;
+    const string m_entityIdFail;
     auto_ptr<SAML2ArtifactType0004> m_artifact;
 public:
-    DynamicMetadataTest() : CxxTest::TestSuite(), m_entityId("https://idp.shibboleth.net/idp/shibboleth"), m_artifact(nullptr)
+    DynamicMetadataTest() : CxxTest::TestSuite(), m_entityId("https://idp.shibboleth.net/idp/shibboleth"),
+        m_entityIdFail("https://idp.shibboleth.net/idp/shibboleth/Fail"), m_artifact(nullptr)
     {}
 
     void setUp()
@@ -82,9 +84,12 @@ private:
         try {
             metadataProvider->init();
             if (!artifactOnly) {
-                MetadataProviderCriteria crit(testApp, m_entityId.c_str());
-                pair<const EntityDescriptor*, const RoleDescriptor*>  thePair = metadataProvider->getEntityDescriptor(crit);
+                MetadataProviderCriteria critOK(testApp, m_entityId.c_str());
+                pair<const EntityDescriptor*, const RoleDescriptor*>  thePair = metadataProvider->getEntityDescriptor(critOK);
                 TS_ASSERT(nullptr != thePair.first);
+                MetadataProviderCriteria critFail(testApp, m_entityIdFail.c_str());
+                thePair = metadataProvider->getEntityDescriptor(critFail);
+                TS_ASSERT(nullptr == thePair.first);
             }
 
             MetadataProviderCriteria artifactCrit(testApp, m_artifact.get());
@@ -107,26 +112,16 @@ public:
     }
 
 
-    void testTemplateFromFile()
+    void testLocalDynamic()
     {
-//        performTest("templateFromFile.xml", false); // Currently fails
+        performTest("localDynamic.xml", false, LOCAL_DYNAMIC_METADATA_PROVIDER);
     }
 
-    void testTemplateFromFileArtifactOnly()
+    void testLocalDynamicArtifactOnly()
     {
-        // The template *IGNORES* the input and joint points at /idp.shibboleth.net.xml 
-       // performTest("templateFromFile.xml", true);  // Currently fails
+       performTest("localDynamic.xml", true, LOCAL_DYNAMIC_METADATA_PROVIDER);
     }
 
-    void testRegexFromFile()
-    {
-        //performTest("regexFromFile.xml", false);  // Currently fails
-    }
-
-    void testRegexFromFileArtifactOnly()
-    {
-       // performTest("regexFromFile.xml", true);
-    }
 
     void testChainedFromRepo()
     {
@@ -138,17 +133,6 @@ public:
         performTest("chainedFromURL.xml", true, CHAINING_METADATA_PROVIDER);
     }
 
-    void testTestFromStaticFile()
-    {
-       // performTest("staticFromFile.xml", false, XML_METADATA_PROVIDER);
-    }
-
-    void testTestFromStaticFileArtefactOnly()
-    {
-        //performTest("staticFromFile.xml", true, XML_METADATA_PROVIDER);
-    }
-
-
 private:
     void mdqTest(bool artifactOnly)
     {
@@ -169,6 +153,9 @@ private:
                 MetadataProviderCriteria crit(testApp, testEntity.c_str());
                 pair<const EntityDescriptor*, const RoleDescriptor*>  thePair = metadataProvider->getEntityDescriptor(crit);
                 TS_ASSERT(nullptr != thePair.first);
+                MetadataProviderCriteria critFail(testApp, m_entityIdFail.c_str());
+                thePair = metadataProvider->getEntityDescriptor(critFail);
+                TS_ASSERT(nullptr == thePair.first);
             }
 
             auto_ptr<SAML2ArtifactType0004> testArtifact(new SAML2ArtifactType0004(SecurityHelper::doHash("SHA1", testEntity.data(), testEntity.length(), false), 666));
@@ -189,7 +176,7 @@ public:
 
     void testMDQArtifactOnly ()
     {
-        //mdqTest(true);
+        mdqTest(true);
     }
 
 };
diff --git a/unittests/data/localDynamic.xml b/unittests/data/localDynamic.xml
new file mode 100644
index 0000000..32ee1db
--- /dev/null
+++ b/unittests/data/localDynamic.xml
@@ -0,0 +1 @@
+<MetadataProvider type="LocalDynamic" sourceDirectory="H:/Perforce/VS2017/cpp-sp/unittests/data/" />
\ No newline at end of file
diff --git a/unittests/data/regexFromFile.xml b/unittests/data/regexFromFile.xml
deleted file mode 100644
index 2f0d7d3..0000000
--- a/unittests/data/regexFromFile.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<MetadataProvider type="Dynamic" ignoreTransport="true" >
-    <Regex match="^https?://([a-zA-Z0-9\\.]+).*$">file:///H:/Perforce/VS2017/cpp-sp/unittests/data/$1.xml</Regex>
-</MetadataProvider>
-
diff --git a/unittests/data/staticFromFile.xml b/unittests/data/staticFromFile.xml
deleted file mode 100644
index 58a8483..0000000
--- a/unittests/data/staticFromFile.xml
+++ /dev/null
@@ -1 +0,0 @@
-<MetadataProvider type="XML" path="H:/Perforce/VS2017/cpp-sp/unittests/data/idp.shibboleth.net.xml"/>
\ No newline at end of file
diff --git a/unittests/data/templateFromFile.xml b/unittests/data/templateFromFile.xml
deleted file mode 100644
index 84c3122..0000000
--- a/unittests/data/templateFromFile.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-<MetadataProvider type="Dynamic" ignoreTransport="true" >
-<Subst hashed="SHA1">file:///H:/Perforce/VS2017/cpp-sp/unittests/data/idp.shibboleth.net.xml</Subst>
-</MetadataProvider>

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



More information about the Pkg-shibboleth-devel mailing list