[cpp-xmltooling] branch master updated: Unit test for initial DataSealer impl.

Scott Cantor cantor.2 at osu.edu
Mon Feb 26 12:15:02 EST 2018


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

scantor pushed a commit to branch master
in repository cpp-xmltooling.

View the commit online:
http://git.shibboleth.net/view/?p=cpp-xmltooling.git;a=commit;h=a9ed2105e13b1923a2bef791d55654460e6d7161

The following commit(s) were added to refs/heads/master by this push:
       new  a9ed210   Unit test for initial DataSealer impl.
a9ed210 is described below

commit a9ed2105e13b1923a2bef791d55654460e6d7161
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Mon Feb 26 12:14:57 2018 -0500

    Unit test for initial DataSealer impl.
---
 .../vc15/xmltoolingtest/xmltoolingtest.vcxproj     | 13 +++++-
 .../xmltoolingtest/xmltoolingtest.vcxproj.filters  |  6 +++
 xmltooling/util/DataSealer.cpp                     |  2 +-
 xmltoolingtest/DataSealerTest.h                    | 47 ++++++++++++++++++++++
 xmltoolingtest/Makefile.am                         |  1 +
 5 files changed, 67 insertions(+), 2 deletions(-)

diff --git a/Projects/vc15/xmltoolingtest/xmltoolingtest.vcxproj b/Projects/vc15/xmltoolingtest/xmltoolingtest.vcxproj
index 7822bc4..76402b3 100644
--- a/Projects/vc15/xmltoolingtest/xmltoolingtest.vcxproj
+++ b/Projects/vc15/xmltoolingtest/xmltoolingtest.vcxproj
@@ -186,6 +186,7 @@
   <ItemGroup>
     <ClCompile Include="CloneInputStreamTest.cpp" />
     <ClCompile Include="ComplexXMLObjectTest.cpp" />
+    <ClCompile Include="DataSealerTest.cpp" />
     <ClCompile Include="DateTimeTest.cpp" />
     <ClCompile Include="EncryptionTest.cpp" />
     <ClCompile Include="ExceptionTest.cpp" />
@@ -467,6 +468,16 @@
 </Command>
       <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).cpp;%(Outputs)</Outputs>
     </CustomBuild>
+    <CustomBuild Include="..\..\..\xmltoolingtest\DataSealerTest.h">
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">perl.exe -w $(CxxTestRoot)\cxxtestgen.pl --part --have-eh --have-std --abort-on-fail -o "%(Filename)".cpp "%(FullPath)"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">perl.exe -w $(CxxTestRoot)\cxxtestgen.pl --part --have-eh --have-std --abort-on-fail -o "%(Filename)".cpp "%(FullPath)"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">perl.exe -w $(CxxTestRoot)\cxxtestgen.pl --part --have-eh --have-std --abort-on-fail -o "%(Filename)".cpp "%(FullPath)"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">perl.exe -w $(CxxTestRoot)\cxxtestgen.pl --part --have-eh --have-std --abort-on-fail -o "%(Filename)".cpp "%(FullPath)"</Command>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).cpp;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).cpp;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).cpp;%(Outputs)</Outputs>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).cpp;%(Outputs)</Outputs>
+    </CustomBuild>
     <ClInclude Include="..\..\..\XMLToolingTest\XMLObjectBaseTestCase.h" />
   </ItemGroup>
   <ItemGroup>
@@ -481,4 +492,4 @@
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
+</Project>
\ No newline at end of file
diff --git a/Projects/vc15/xmltoolingtest/xmltoolingtest.vcxproj.filters b/Projects/vc15/xmltoolingtest/xmltoolingtest.vcxproj.filters
index 7d069f3..e63362a 100644
--- a/Projects/vc15/xmltoolingtest/xmltoolingtest.vcxproj.filters
+++ b/Projects/vc15/xmltoolingtest/xmltoolingtest.vcxproj.filters
@@ -68,6 +68,9 @@
     <ClCompile Include="ExplicitKeyTrustEngineTest.cpp">
       <Filter>Generated Code</Filter>
     </ClCompile>
+    <ClCompile Include="DataSealerTest.cpp">
+      <Filter>Generated Code</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\..\XMLToolingTest\XMLObjectBaseTestCase.h">
@@ -135,5 +138,8 @@
     <CustomBuild Include="..\..\..\XMLToolingTest\ExplicitKeyTrustEngineTest.h">
       <Filter>Unit Tests</Filter>
     </CustomBuild>
+    <CustomBuild Include="..\..\..\xmltoolingtest\DataSealerTest.h">
+      <Filter>Unit Tests</Filter>
+    </CustomBuild>
   </ItemGroup>
 </Project>
\ No newline at end of file
diff --git a/xmltooling/util/DataSealer.cpp b/xmltooling/util/DataSealer.cpp
index 3f1bcb8..9e11751 100644
--- a/xmltooling/util/DataSealer.cpp
+++ b/xmltooling/util/DataSealer.cpp
@@ -105,7 +105,7 @@ string DataSealer::unwrap(const char* s) const
     XMLDateTime exp(expstr.get());
     exp.parseDateTime();
     if (exp.getEpoch() < time(nullptr) - XMLToolingConfig::getConfig().clock_skew_secs) {
-        logging::Category::getInstance(XMLTOOLING_LOGCAT ".DataSealer").debug("Decrypted data has expired");
+        throw IOException("Decrypted data has expired.");
     }
 
     return decrypted.substr(20);
diff --git a/xmltoolingtest/DataSealerTest.h b/xmltoolingtest/DataSealerTest.h
new file mode 100644
index 0000000..47082e9
--- /dev/null
+++ b/xmltoolingtest/DataSealerTest.h
@@ -0,0 +1,47 @@
+/**
+ * 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.
+ *
+ * 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.
+ */
+
+#include "XMLObjectBaseTestCase.h"
+
+#include <xmltooling/exceptions.h>
+#include <xmltooling/util/DataSealer.h>
+
+class DataSealerTest : public CxxTest::TestSuite {
+public:
+    void setUp() {
+    }
+    
+    void tearDown() {
+    }
+
+    void testDataSealer() {
+        auto_ptr<DataSealer> sealer(new DataSealer());
+
+        string data = "this is a test";
+
+        string wrapped = sealer->wrap(data.c_str(), time(nullptr) + 500);
+        string unwrapped = sealer->unwrap(wrapped.c_str());
+            
+        TSM_ASSERT_EQUALS("DataSealer output did not match.", data, unwrapped);
+
+        wrapped = sealer->wrap(data.c_str(), time(nullptr) - 500);
+        TSM_ASSERT_THROWS("DataSealer did not throw on expired data.", sealer->unwrap(wrapped.c_str()), IOException);
+    }
+};
diff --git a/xmltoolingtest/Makefile.am b/xmltoolingtest/Makefile.am
index e4bd429..79d25d3 100644
--- a/xmltoolingtest/Makefile.am
+++ b/xmltoolingtest/Makefile.am
@@ -19,6 +19,7 @@ endif
 
 if BUILD_XMLSEC
 xmlsec_sources = \
+    DataSealerTest.h \
     EncryptionTest.h \
     FilesystemCredentialResolverTest.h \
 	ExplicitKeyTrustEngineTest.h \

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


More information about the commits mailing list