summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJayanth Othayoth <ojayanth@in.ibm.com>2018-03-21 06:08:06 -0500
committerJayanth Othayoth <ojayanth@in.ibm.com>2018-03-29 09:40:40 -0500
commit808c40d989fb27f06b9bbc4dabc32ba7d92d3fe4 (patch)
tree5499704ded95ecff40ef89eca223ad9b3e9420d2
parent7ccaa2a594f3966069674f3d24346bb44550c4db (diff)
downloadopenpower-pnor-code-mgmt-808c40d989fb27f06b9bbc4dabc32ba7d92d3fe4.tar.gz
openpower-pnor-code-mgmt-808c40d989fb27f06b9bbc4dabc32ba7d92d3fe4.zip
Added negative path test cases for pnor signature validation
Resolves openbmc/openbmc#3000 Change-Id: Ia03385d74d9885975c411ac24769510bd1afc4c4 Signed-off-by: Jayanth Othayoth <ojayanth@in.ibm.com>
-rw-r--r--test/utest.cpp36
1 files changed, 35 insertions, 1 deletions
diff --git a/test/utest.cpp b/test/utest.cpp
index 23d25552c..21fdc2891 100644
--- a/test/utest.cpp
+++ b/test/utest.cpp
@@ -106,7 +106,6 @@ class SignatureTest : public testing::Test
{
command("rm -rf " + std::string(testPath));
}
-
std::unique_ptr<Signature> signature;
fs::path extractPath;
fs::path signedConfPath;
@@ -118,3 +117,38 @@ TEST_F(SignatureTest, TestSignatureVerify)
{
EXPECT_TRUE(signature->verify());
}
+
+/** @brief Test failure scenario with corrupted signature file*/
+TEST_F(SignatureTest, TestCorruptSignatureFile)
+{
+ // corrupt the image-kernel.sig file and ensure that verification fails
+ std::string kernelFile = extractPath.string() + "/" + "pnor.xz.squashfs";
+ command("echo \"dummy data\" > " + kernelFile + ".sig ");
+ EXPECT_FALSE(signature->verify());
+}
+
+/** @brief Test failure scenario with no public key in the image*/
+TEST_F(SignatureTest, TestNoPublicKeyInImage)
+{
+ // Remove publickey file from the image and ensure that verify fails
+ std::string pubkeyFile = extractPath.string() + "/" + "publickey";
+ command("rm " + pubkeyFile);
+ EXPECT_FALSE(signature->verify());
+}
+
+/** @brief Test failure scenario with invalid hash function value*/
+TEST_F(SignatureTest, TestInvalidHashValue)
+{
+ // Change the hashfunc value and ensure that verification fails
+ std::string hashFile = signedConfPNORPath.string() + "/hashfunc";
+ command("echo \"HashType=md5\" > " + hashFile);
+ EXPECT_FALSE(signature->verify());
+}
+
+/** @brief Test for failure scenario with no config file in system*/
+TEST_F(SignatureTest, TestNoConfigFileInSystem)
+{
+ // Remove the conf folder in the system and ensure that verify fails
+ command("rm -rf " + signedConfPNORPath.string());
+ EXPECT_FALSE(signature->verify());
+}
OpenPOWER on IntegriCloud