Add unit test cases for SignatureFinder 23/314323/6
authorPhan Xuan Tan <xuan.tan@samsung.com>
Wed, 10 Jul 2024 06:15:47 +0000 (13:15 +0700)
committerDariusz Michaluk <d.michaluk@samsung.com>
Fri, 12 Jul 2024 11:38:50 +0000 (13:38 +0200)
Change-Id: I57cca5d0188a62416991477f6709c243a0a13a9d

unit-tests/CMakeLists.txt
unit-tests/resource/wgt_no_dist_signature/author-signature.xml [new file with mode: 0644]
unit-tests/resource/wgt_no_dist_signature/config.xml [new file with mode: 0644]
unit-tests/resource/wgt_no_dist_signature/index.html [new file with mode: 0644]
unit-tests/resource/wgt_wrong_format_dist/author-signature.xml [new file with mode: 0644]
unit-tests/resource/wgt_wrong_format_dist/signature12345678901.xml [new file with mode: 0644]
unit-tests/test_constant.cpp
unit-tests/test_constant.h
unit-tests/test_vcore_signature_finder.cpp [new file with mode: 0644]

index ae038ca..c0f1d3b 100644 (file)
@@ -69,6 +69,7 @@ SET(UNIT_TESTS_SOURCES
     test_vcore_api_cert.cpp
     test_vcore_api_pkcs12.cpp
     test_vcore_signature_data.cpp
+    test_vcore_signature_finder.cpp
     test_cert_server_db.cpp
     test_cert_server_logic.cpp
     colour_log_formatter.cpp
@@ -133,6 +134,8 @@ INSTALL(
 INSTALL(
     DIRECTORY
         resource/wgt_valid
+        resource/wgt_no_dist_signature
+        resource/wgt_wrong_format_dist
     DESTINATION
         ${CERT_SVC_TESTS}/unit_test_data
 )
\ No newline at end of file
diff --git a/unit-tests/resource/wgt_no_dist_signature/author-signature.xml b/unit-tests/resource/wgt_no_dist_signature/author-signature.xml
new file mode 100644 (file)
index 0000000..ff82da8
--- /dev/null
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Signature xmlns="http://www.w3.org/2000/09/xmldsig#" xmlns:wac="http://wacapps.net/ns/digsig" Id="AuthorSignature">
+ <SignedInfo>
+  <CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
+  <SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
+  <Reference URI="config.xml">
+   <DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
+   <DigestValue>xUKQbov3HL7JD2/zVUKpPEVGc5C6VWDXwxoDHzDs9y0=</DigestValue>
+  </Reference>
+  <Reference URI="index.html">
+   <DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
+   <DigestValue>cIE41PzyhMnF++EmhJ3Ptnd4ZqXyBlRJgiIqxlutbV8=</DigestValue>
+  </Reference>
+  <Reference URI="#prop">
+   <Transforms>
+    <Transform Algorithm="http://www.w3.org/2006/12/xml-c14n11"/>
+   </Transforms>
+   <DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
+   <DigestValue>MH34nIMXxv0fMQQ8bTV1wZUNLOrXTmpnxpADlNzmQ/4=</DigestValue>
+  </Reference>
+ </SignedInfo>
+ <SignatureValue>fhh+VQq76Uodq4upHhvcC2tgbVY8bL9DiiSe9wn1O4YrIFKMnEEYqYmpQbL1puWU
+Zbht0hXpvEFXg1010q5kOZQxknqcyFg3hyVUpFDPARkJs1XhRNbFWJJF7qNXVgt5
+NyFrdXFv4lVFjkv+chSykaWu6V22z43E8kJcg+zGVU8=</SignatureValue>
+ <KeyInfo>
+  <X509Data>
+  <X509Certificate>MIIETTCCA7agAwIBAgIJANaOuOCRgiz3MA0GCSqGSIb3DQEBBQUAMIG8MQswCQYD
+VQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTE9MDsGA1UEChM0WE1MIFNlY3Vy
+aXR5IExpYnJhcnkgKGh0dHA6Ly93d3cuYWxla3NleS5jb20veG1sc2VjKTEeMBwG
+A1UECxMVVGVzdCBSb290IENlcnRpZmljYXRlMRYwFAYDVQQDEw1BbGVrc2V5IFNh
+bmluMSEwHwYJKoZIhvcNAQkBFhJ4bWxzZWNAYWxla3NleS5jb20wHhcNMDUwNzEw
+MDIyOTAxWhcNMTUwNzA4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ReZqYC9OqFofG1/O9AdQ58WL/FWg8DgP5MJPT
+T9kRU3FU01jUiX2+kbdnghZAOJm0ziRNxfNPwIIWPKYXyXEKQQzrnxyFey1hP7cg
+6A==</X509Certificate>
+</X509Data>
+ </KeyInfo>
+ <Object Id="prop">
+  <SignatureProperties xmlns:dsp="http://www.w3.org/2009/xmldsig-properties">
+   <SignatureProperty Id="profile" Target="#AuthorSignature">
+    <dsp:Profile URI="http://www.w3.org/ns/widgets-digsig#profile"/>
+   </SignatureProperty>
+   <SignatureProperty Id="role" Target="#AuthorSignature">
+    <dsp:Role URI="http://www.w3.org/ns/widgets-digsig#role-author"/>
+   </SignatureProperty>
+   <SignatureProperty Id="identifier" Target="#AuthorSignature">
+    <dsp:Identifier/>
+   </SignatureProperty>
+  </SignatureProperties>
+ </Object>
+</Signature>
diff --git a/unit-tests/resource/wgt_no_dist_signature/config.xml b/unit-tests/resource/wgt_no_dist_signature/config.xml
new file mode 100644 (file)
index 0000000..82b077b
--- /dev/null
@@ -0,0 +1,6 @@
+<widget xmlns="http://www.w3.org/ns/widgets" id="Test Widget">
+    <name shortname="ShortName">Widget Name OK</name>
+    <version>1.2.3.4</version>
+    <description>A short description of widget</description>
+    <author>Author Name</author>
+</widget>
diff --git a/unit-tests/resource/wgt_no_dist_signature/index.html b/unit-tests/resource/wgt_no_dist_signature/index.html
new file mode 100644 (file)
index 0000000..c47b20a
--- /dev/null
@@ -0,0 +1,4 @@
+<!doctype html>
+<title>Not tested</title>
+<body style="background-color:#666">
+<h1>None</h1>
diff --git a/unit-tests/resource/wgt_wrong_format_dist/author-signature.xml b/unit-tests/resource/wgt_wrong_format_dist/author-signature.xml
new file mode 100644 (file)
index 0000000..cb0b73c
--- /dev/null
@@ -0,0 +1,75 @@
+<Signature xmlns="http://www.w3.org/2000/09/xmldsig#" Id="AuthorSignature">
+<SignedInfo>
+<CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"></CanonicalizationMethod>
+<SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"></SignatureMethod>
+<Reference URI="config.xml">
+<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"></DigestMethod>
+<DigestValue>slamUlCPsGfRZvSlot9sIUMiPSjVSPOeJ0I7X1yxvmE=</DigestValue>
+</Reference>
+<Reference URI="css%2Fstyle.css">
+<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"></DigestMethod>
+<DigestValue>0/mhZV4kwFnSzCSp45AhFjWaQnaie61uW8VeXioOLQg=</DigestValue>
+</Reference>
+<Reference URI="icon.png">
+<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"></DigestMethod>
+<DigestValue>vPjxjOppORd6hn9Bw4sh06gqtDoJzoFbV/8e9FyIdvk=</DigestValue>
+</Reference>
+<Reference URI="index.html">
+<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"></DigestMethod>
+<DigestValue>OYW0ozIt+YihibhXb3mmAtIpmp5rJFNpS6n0bcbqPpI=</DigestValue>
+</Reference>
+<Reference URI="js%2Fmain.js">
+<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"></DigestMethod>
+<DigestValue>0oc6DiyrAj1HQFcu+27/BHCQKn3zBn9dKls96iQZ564=</DigestValue>
+</Reference>
+<Reference URI="#prop">
+<Transforms>
+<Transform Algorithm="http://www.w3.org/2006/12/xml-c14n11"></Transform>
+</Transforms>
+<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"></DigestMethod>
+<DigestValue>lpo8tUDs054eLlBQXiDPVDVKfw30ZZdtkRs1jd7H5K8=</DigestValue>
+</Reference>
+</SignedInfo>
+<SignatureValue>
+DEDbUoxWn26xtZD+J+Qp71TzALREeTaalmbS1170MXpPiGjukYhD63KDEcHhYxU2cgAVUAcL2mD/
+ITe50rC8jy7dz2xqnUP2rIlFxIGRbciCs9fHx2CmqIq4yqvvdj7usy9o3SWsBxNaWshd7PJYQyjD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6EvI
+W6TFyZgMpQq+kg4hWl2SBTf3s2VI8Ygz7gj8TMlClg==
+</X509Certificate>
+</X509Data>
+</KeyInfo>
+<Object Id="prop"><SignatureProperties xmlns:dsp="http://www.w3.org/2009/xmldsig-properties"><SignatureProperty Id="profile" Target="#AuthorSignature"><dsp:Profile URI="http://www.w3.org/ns/widgets-digsig#profile"></dsp:Profile></SignatureProperty><SignatureProperty Id="role" Target="#AuthorSignature"><dsp:Role URI="http://www.w3.org/ns/widgets-digsig#role-author"></dsp:Role></SignatureProperty><SignatureProperty Id="identifier" Target="#AuthorSignature"><dsp:Identifier></dsp:Identifier></SignatureProperty></SignatureProperties></Object>
+</Signature>
\ No newline at end of file
diff --git a/unit-tests/resource/wgt_wrong_format_dist/signature12345678901.xml b/unit-tests/resource/wgt_wrong_format_dist/signature12345678901.xml
new file mode 100644 (file)
index 0000000..48becf3
--- /dev/null
@@ -0,0 +1,76 @@
+<Signature xmlns="http://www.w3.org/2000/09/xmldsig#" Id="DistributorSignature">
+<SignedInfo>
+<CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"></CanonicalizationMethod>
+<SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"></SignatureMethod>
+<Reference URI="author-signature.xml">
+<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"></DigestMethod>
+<DigestValue>PTzNKgBBJEV/YtJgOP9lkUMVy+IQ3b9gVn5eorv4e3s=</DigestValue>
+</Reference>
+<Reference URI="config.xml">
+<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"></DigestMethod>
+<DigestValue>slamUlCPsGfRZvSlot9sIUMiPSjVSPOeJ0I7X1yxvmE=</DigestValue>
+</Reference>
+<Reference URI="css%2Fstyle.css">
+<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"></DigestMethod>
+<DigestValue>0/mhZV4kwFnSzCSp45AhFjWaQnaie61uW8VeXioOLQg=</DigestValue>
+</Reference>
+<Reference URI="icon.png">
+<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"></DigestMethod>
+<DigestValue>vPjxjOppORd6hn9Bw4sh06gqtDoJzoFbV/8e9FyIdvk=</DigestValue>
+</Reference>
+<Reference URI="index.html">
+<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"></DigestMethod>
+<DigestValue>OYW0ozIt+YihibhXb3mmAtIpmp5rJFNpS6n0bcbqPpI=</DigestValue>
+</Reference>
+<Reference URI="js%2Fmain.js">
+<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"></DigestMethod>
+<DigestValue>0oc6DiyrAj1HQFcu+27/BHCQKn3zBn9dKls96iQZ564=</DigestValue>
+</Reference>
+<Reference URI="#prop">
+<Transforms>
+<Transform Algorithm="http://www.w3.org/2006/12/xml-c14n11"></Transform>
+</Transforms>
+<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"></DigestMethod>
+<DigestValue>u/jU3U4Zm5ihTMSjKGlGYbWzDfRkGphPPHx3gJIYEJ4=</DigestValue>
+</Reference>
+</SignedInfo>
+<SignatureValue>
+O946StYJMD1w5BSGQYpG4ULHC4AkHsAL7UATxj8UBqm1aYr9w70Cl9kBnvcu9UJ4qMLs1x3rpBlu
+oPh5Nx9pOIxe505x4v4Q+bKsh9sQcTbh9uwiyajD6ATvTmfh1w5YCCEbdRgCZ6UbTWw5PMMoNnoU
+YbgHcqkzfwdo8U5WN9o=
+</SignatureValue>
+<KeyInfo>
+<X509Data>
+<X509Certificate>
+MIICmzCCAgQCCQDXI7WLdVZwiTANBgkqhkiG9w0BAQUFADCBjzELMAkGA1UEBhMCS1IxDjAMBgNV
+BAgMBVN1d29uMQ4wDAYDVQQHDAVTdXdvbjEWMBQGA1UECgwNVGl6ZW4gVGVzdCBDQTEiMCAGA1UE
+CwwZVGl6ZW4gRGlzdHJpYnV0b3IgVGVzdCBDQTEkMCIGA1UEAwwbVGl6ZW4gUHVibGljIERp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gMBVN1d29uMQ4wDAYDVQQHDAVTdXdvbjEWMBQGA1UECgwNVGl6
+ZW4gVGVzdCBDQTEiMCAGA1UECwwZVGl6ZW4gRGlzdHJpYnV0b3IgVGVzdCBDQTEkMCIGA1UEAwwb
+VGl6ZW4gUHVibGljIERpc3RyaWJ1dG9yIENBMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDe
+OTS/3nXvkDEmsFCJIvRlQ3RKDcxdWJJp625pFqHdmoJBdV+x6jl1raGK2Y1sp2Gdvpjc/z92yzAp
+bE/UVLPh/tRNZPeGhzU4ejDDm7kzdr2f7Ia0U98K+OoY12ucwg7TYNItj9is7Cj4blGfuMDzd2ah
+2AgnCGlwNwV/pv+uVQIDAQABoxAwDjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBACqJ
+KO33YdoGudwanZIxMdXuxnnD9R6u72ltKk1S4zPfMJJv482CRGCI4FK6djhlsI4i0Lt1SVIJEed+
+yc3qckGm19dW+4xdlkekon7pViEBWuyHw8OWv3RXtTum1+PGHjBJ2eYY4ZKIpz73U/1NC16sTB/0
+VhfnkHwPltmrpYVe
+</X509Certificate>
+</X509Data>
+</KeyInfo>
+<Object Id="prop"><SignatureProperties xmlns:dsp="http://www.w3.org/2009/xmldsig-properties"><SignatureProperty Id="profile" Target="#DistributorSignature"><dsp:Profile URI="http://www.w3.org/ns/widgets-digsig#profile"></dsp:Profile></SignatureProperty><SignatureProperty Id="role" Target="#DistributorSignature"><dsp:Role URI="http://www.w3.org/ns/widgets-digsig#role-distributor"></dsp:Role></SignatureProperty><SignatureProperty Id="identifier" Target="#DistributorSignature"><dsp:Identifier></dsp:Identifier></SignatureProperty></SignatureProperties></Object>
+</Signature>
\ No newline at end of file
index ac388ed..c6f0484 100644 (file)
@@ -313,4 +313,10 @@ const std::map<std::string, CertStoreType> storeTypeMap =
 namespace PackageData {
        const std::string WgtValidPath =
                std::string(TESTAPP_RES_DIR) + "unit_test_data/wgt_valid";
+
+       const std::string WgtWrongFormatDistPath =
+               std::string(TESTAPP_RES_DIR) + "unit_test_data/wgt_wrong_format_dist";
+
+       const std::string WgtNoDistPath =
+               std::string(TESTAPP_RES_DIR) + "unit_test_data/wgt_no_dist_signature";
 }
\ No newline at end of file
index 726ec56..c86116a 100644 (file)
@@ -110,4 +110,6 @@ extern const std::map<std::string, CertStoreType> storeTypeMap;
 
 namespace PackageData {
        extern const std::string WgtValidPath;
+       extern const std::string WgtWrongFormatDistPath;
+       extern const std::string WgtNoDistPath;
 }
\ No newline at end of file
diff --git a/unit-tests/test_vcore_signature_finder.cpp b/unit-tests/test_vcore_signature_finder.cpp
new file mode 100644 (file)
index 0000000..e1ae155
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed 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 "vcore/SignatureFinder.h"
+#include "test_constant.h"
+#include "test_common.h"
+#include "test_macros.h"
+#include <cstring>
+
+using namespace ValidationCore;
+using namespace std;
+
+BOOST_AUTO_TEST_SUITE(VCORE_SIGNARURE_FINDER_TEST)
+
+POSITIVE_TEST_CASE(T_get_signature_files_from_valid_path)
+{
+       SignatureFinder signatureFinder(PackageData::WgtValidPath);
+       SignatureFileInfoSet signatureSet;
+
+       SignatureFinder::Result result = signatureFinder.find(signatureSet);
+       BOOST_CHECK_EQUAL(result, SignatureFinder::NO_ERROR);
+       BOOST_CHECK_EQUAL(signatureSet.size(), 2);
+}
+
+NEGATIVE_TEST_CASE(T_get_signature_files_not_found)
+{
+       SignatureFinder signatureFinder("Not Found");
+       SignatureFileInfoSet signatureSet;
+
+       SignatureFinder::Result result = signatureFinder.find(signatureSet);
+       BOOST_CHECK_EQUAL(result, SignatureFinder::ERROR_OPENING_DIR);
+}
+
+NEGATIVE_TEST_CASE(T_get_signature_files_error_isstream)
+{
+       SignatureFinder signatureFinder(PackageData::WgtWrongFormatDistPath);
+       SignatureFileInfoSet signatureSet;
+
+       SignatureFinder::Result result = signatureFinder.find(signatureSet);
+       BOOST_CHECK_EQUAL(result, SignatureFinder::ERROR_ISTREAM);
+}
+
+NEGATIVE_TEST_CASE(T_get_signature_files_from_invalid_path)
+{
+       SignatureFinder signatureFinder(PackageData::WgtNoDistPath);
+       SignatureFileInfoSet signatureSet;
+
+       SignatureFinder::Result result = signatureFinder.find(signatureSet);
+       BOOST_CHECK_EQUAL(result, SignatureFinder::NO_ERROR);
+       BOOST_CHECK_EQUAL(signatureSet.size(), 1);
+}
+
+POSITIVE_TEST_CASE(T_get_signature_info)
+{
+       const SignatureFileInfo signatureFileInfo1;
+       std::string fileName = "signature1.xml";
+       SignatureFileInfo signatureFileInfo2(fileName, 1);
+
+       BOOST_CHECK_EQUAL(signatureFileInfo2.getFileName(), fileName);
+       BOOST_CHECK_EQUAL(signatureFileInfo2.getFileNumber(), 1);
+       BOOST_CHECK_EQUAL(signatureFileInfo2.operator<(signatureFileInfo1), false);
+}
+
+BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file