summaryrefslogtreecommitdiff
path: root/tests/test_xml-parser.cpp
diff options
context:
space:
mode:
authorMaciej J. Karpiuk <m.karpiuk2@samsung.com>2015-07-14 11:31:28 +0200
committerBartlomiej Grzelewski <b.grzelewski@samsung.com>2015-11-24 09:37:58 -0800
commitd3e24f2ecde5aa23aa7b2aed806725350f490629 (patch)
treeff3d40eaa2caed60237a0cf8cf0b8924d16aa8a9 /tests/test_xml-parser.cpp
parent7d24744edd8f92af52c7631af5b1a0feccfc3248 (diff)
downloadkey-manager-d3e24f2ecde5aa23aa7b2aed806725350f490629.tar.gz
key-manager-d3e24f2ecde5aa23aa7b2aed806725350f490629.tar.bz2
key-manager-d3e24f2ecde5aa23aa7b2aed806725350f490629.zip
Encrypted Initial Values: re-factoring the schema to support new requirements.
New requirements are: support for encrypting data and certificate objects. This requires providing hybrid encryption: device key encrypts AES key, which is used to encrypt the values. Device key cannot directly encrypt values due to block size limitation of RSA OAEP algorithm. Change-Id: I61f52bad74d7cf2f6018a1e0e38cc852a932619e
Diffstat (limited to 'tests/test_xml-parser.cpp')
-rw-r--r--tests/test_xml-parser.cpp31
1 files changed, 29 insertions, 2 deletions
diff --git a/tests/test_xml-parser.cpp b/tests/test_xml-parser.cpp
index 8782ae8b..b12cbd6d 100644
--- a/tests/test_xml-parser.cpp
+++ b/tests/test_xml-parser.cpp
@@ -34,7 +34,10 @@ const char *XSD_1_okay = "XML_1_okay.xsd";
const char *XML_1_wrong = "XML_1_wrong.xml";
const char *XSD_1_wrong = "XML_1_wrong.xsd";
const char *XML_2_structure = "XML_2_structure.xml";
-const char *XML_3_structure = "XML_3_structure.xml";
+const char *XML_3_encrypted = "XML_3_encrypted.xml";
+const char *XSD_3_encrypted = "XML_3_encrypted.xsd";
+const char *XML_4_device_key = "XML_4_device_key.xml";
+const char *XSD_4_device_key = "XML_4_device_key.xsd";
std::string format_test_path(const char *file)
{
@@ -117,7 +120,6 @@ BOOST_AUTO_TEST_CASE(XmlParserTest_XML1_correct_parse)
BOOST_REQUIRE(endCallbackFlag == true);
}
-
class StructureTest
{
public:
@@ -289,4 +291,29 @@ BOOST_AUTO_TEST_CASE(XmlParserTest_XML2_structure)
"got sum: " << parser.getSum() << " while expected: " << parser.getExpectedSum());
}
+BOOST_AUTO_TEST_CASE(XmlParserTest_XML3_encrypted_correct_parse)
+{
+ XML::Parser parser(format_test_path(XML_3_encrypted).c_str());
+ BOOST_REQUIRE(0 == parser.Validate(format_test_path(XSD_3_encrypted).c_str()));
+
+ BOOST_REQUIRE(Parser::ErrorCode::PARSE_SUCCESS == parser.RegisterElementCb("Key", dummyStartCallback, NULL));
+ BOOST_REQUIRE(Parser::ErrorCode::PARSE_SUCCESS == parser.RegisterElementCb("Cert", NULL, dummyEndCallback));
+ startCallbackFlag = false;
+ endCallbackFlag = false;
+ BOOST_REQUIRE(Parser::ErrorCode::PARSE_SUCCESS == parser.Parse());
+ BOOST_REQUIRE(startCallbackFlag == true);
+ BOOST_REQUIRE(endCallbackFlag == true);
+}
+
+BOOST_AUTO_TEST_CASE(XmlParserTest_XML4_device_key_correct_parse)
+{
+ XML::Parser parser(format_test_path(XML_4_device_key).c_str());
+ BOOST_REQUIRE(0 == parser.Validate(format_test_path(XSD_4_device_key).c_str()));
+
+ BOOST_REQUIRE(Parser::ErrorCode::PARSE_SUCCESS == parser.RegisterElementCb("RSAPrivateKey", dummyStartCallback, NULL));
+ startCallbackFlag = false;
+ BOOST_REQUIRE(Parser::ErrorCode::PARSE_SUCCESS == parser.Parse());
+ BOOST_REQUIRE(startCallbackFlag == true);
+}
+
BOOST_AUTO_TEST_SUITE_END()