summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortranthanhtung2001 <tran.tung@samsung.com>2024-09-19 13:20:41 +0700
committerDariusz Michaluk <d.michaluk@samsung.com>2024-09-19 10:44:24 +0000
commit605f97f16b54a952e038c0382b5afbd29fa18616 (patch)
tree0fbde099ac1598c72dd6cf6a9df5cf6ea35a4b84
parent6685db5332d3e469efe31076f75e39662c5ee443 (diff)
downloadcert-svc-605f97f16b54a952e038c0382b5afbd29fa18616.tar.gz
cert-svc-605f97f16b54a952e038c0382b5afbd29fa18616.tar.bz2
cert-svc-605f97f16b54a952e038c0382b5afbd29fa18616.zip
Add test case for tokenEndECKeyValue function in SignatureReader.cppHEADtizen
Change-Id: I3b89c47398c21484163dc9e099a82a9b957158e4 Signed-off-by: tranthanhtung2001 <tran.tung@samsung.com>
-rw-r--r--unit-tests/CMakeLists.txt1
-rw-r--r--unit-tests/resource/wgt_signature_has_key_value/signature_has_key_value.xml70
-rw-r--r--unit-tests/test_constant.cpp3
-rw-r--r--unit-tests/test_constant.h1
-rw-r--r--unit-tests/test_vcore_signature_reader.cpp15
5 files changed, 90 insertions, 0 deletions
diff --git a/unit-tests/CMakeLists.txt b/unit-tests/CMakeLists.txt
index 12fe79c..28b0aeb 100644
--- a/unit-tests/CMakeLists.txt
+++ b/unit-tests/CMakeLists.txt
@@ -160,6 +160,7 @@ INSTALL(
resource/wgt_url_empty
resource/wgt_wrong_url
resource/wgt_signature_has_imei_meid
+ resource/wgt_signature_has_key_value
DESTINATION
${CERT_SVC_TESTS}/unit_test_data
) \ No newline at end of file
diff --git a/unit-tests/resource/wgt_signature_has_key_value/signature_has_key_value.xml b/unit-tests/resource/wgt_signature_has_key_value/signature_has_key_value.xml
new file mode 100644
index 0000000..107e102
--- /dev/null
+++ b/unit-tests/resource/wgt_signature_has_key_value/signature_has_key_value.xml
@@ -0,0 +1,70 @@
+<Signature xmlns="http://www.w3.org/2000/09/xmldsig#" xmlns:digsig="http://wacapps.net/ns/digsig" 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>
+ <KeyValue>
+ <ECKeyValue Id="EcKeyValue">
+ <NamedCurve URI="urlNamedCurve"/>
+ <PublicKey>123456789234</PublicKey>
+ </ECKeyValue>
+ </KeyValue>
+ <X509Data>
+ <X509Certificate>MIIDdzCCAl+gAwIBAgIEAgAAuTANBgkqhkiG9w0BAQUFADBaMQswCQYDVQQGEwJJRTESMBAGA1UEChMJQmFsdGltb3JlMRMwEQYDVQQLEwpDeWJlclRydXN0MSIwIAYDVQQDExlCYWx0aW1vcmUgQ3liZXJUcnVzdCBSb290MB4XDTAwMDUxMjE4NDYwMFoXDTI1MDUxMjIzNTkwMFowWjELMAkGA1UEBhMCSUUxEjAQBgNVBAoTCUJhbHRpbW9yZTETMBEGA1UECxMKQ3liZXJUcnVzdDEiMCAGA1UEAxMZQmFsdGltb3JlIEN5YmVyVHJ1c3QgUm9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKMEuyKrmD1X6CZymrV51Cni4eiVgLGw41uOKymaZN+hXe2wCQVt2yguzmKiYv60iNoS6zjrIZ3AQSsBUnuId9Mcj8e6uYi1agnnc+gRQKfRzMpijS3ljwumUNKoUMMo6vWrJYeKmpYcqWe4PwzV9/lSEy/CG9VwcPCPwBLKBsua4dnKM3p31vjsufFoREJIE9LAwqSuXmD+tqYF/LTdB1kC1FkYmGP1pWPgkAx9XbIGevOF6uvUA65ehD5f/x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qOOfZYC4/giBO/gNsBvwr8uDW7t1nYoDYGHPpvnpxCM2mYfQFHq576/TmeYu1RZY29C4w8xYBlkAA8mDJfRhMCmehk7cN5FJtyWRj2cZj/hOoI45TYDBChXpOlLZKIYiG1giY16vhCRi6zmPzEwv+tk156N6cGSVm44jTQ/rs1sa0JSYjzUaYngoFdZC4OfxnIkQvUIA4TOFmPzNPEFdjcZsgbeEz4TcGHTBPK4R28F44qIMCtHRV55VMX53ev6P3hRddJb</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
diff --git a/unit-tests/test_constant.cpp b/unit-tests/test_constant.cpp
index 27ca581..9b2f44a 100644
--- a/unit-tests/test_constant.cpp
+++ b/unit-tests/test_constant.cpp
@@ -414,6 +414,9 @@ namespace PackageData {
const std::string WgtSignatureHasImeiMeid =
std::string(TESTAPP_RES_DIR) + "unit_test_data/wgt_signature_has_imei_meid";
+
+ const std::string WgtSignatureHasKeyValue =
+ std::string(TESTAPP_RES_DIR) + "unit_test_data/wgt_signature_has_key_value";
}
namespace SignatureTest {
diff --git a/unit-tests/test_constant.h b/unit-tests/test_constant.h
index 21ec90e..d8fff6c 100644
--- a/unit-tests/test_constant.h
+++ b/unit-tests/test_constant.h
@@ -127,6 +127,7 @@ namespace PackageData {
extern const std::string WgtUrlEmpty;
extern const std::string WgtWrongUrl;
extern const std::string WgtSignatureHasImeiMeid;
+ extern const std::string WgtSignatureHasKeyValue;
}
namespace SignatureTest {
diff --git a/unit-tests/test_vcore_signature_reader.cpp b/unit-tests/test_vcore_signature_reader.cpp
index e93a134..75d1796 100644
--- a/unit-tests/test_vcore_signature_reader.cpp
+++ b/unit-tests/test_vcore_signature_reader.cpp
@@ -67,6 +67,21 @@ NEGATIVE_TEST_CASE(T_signature_has_both_imei_meid_attribute)
BOOST_CHECK_THROW(xml.read(signatureData), SignatureReader::Exception::TargetRestriction);
}
+NEGATIVE_TEST_CASE(T_signature_has_key_value_attribute)
+{
+ /* This test case will check tokenEndECKeyValue() function */
+
+ SignatureData signatureData;
+ SignatureReader xml;
+
+ std::string signatureHasKeyValue = PackageData::WgtSignatureHasKeyValue + "/signature_has_key_value.xml";
+
+ signatureData = SignatureData(signatureHasKeyValue, 1);
+ xml.initialize(signatureData, SIGNATURE_SCHEMA_PATH);
+
+ BOOST_CHECK_THROW(xml.read(signatureData), ParserSchemaException::CertificateLoaderError);
+}
+
NEGATIVE_TEST_CASE(T_signature_reader_rsa_key_value_no_implement)
{
SignatureData signatureData;