diff options
author | Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com> | 2017-12-16 15:11:47 +0530 |
---|---|---|
committer | Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com> | 2018-01-19 11:47:03 +0530 |
commit | 1f5a002f4b596522cf46eaad3cfd072a44b5848d (patch) | |
tree | c4d189aa8f6afd5395e36bddfce10be95695dcda /test | |
parent | 035a96983cdf8a11a1c2380106c11c94cb8418b2 (diff) | |
download | phosphor-user-manager-1f5a002f4b596522cf46eaad3cfd072a44b5848d.tar.gz phosphor-user-manager-1f5a002f4b596522cf46eaad3cfd072a44b5848d.zip |
Fix to use mkstemp for temp shadow file creation
Do not rely on randomString() for tempShadowFile, as it uses '/' in random
set, and cause file creation error. Also, it's safe to use mkstemp to create
temp shadow file with random name suffixing shadow file name.
Change-Id: I0b80cc6d7c002e732e22f660e50b0701acac15fe
Signed-off-by: Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/utest.cpp | 25 |
1 files changed, 1 insertions, 24 deletions
diff --git a/test/utest.cpp b/test/utest.cpp index bdca968..33e0576 100644 --- a/test/utest.cpp +++ b/test/utest.cpp @@ -14,7 +14,6 @@ namespace fs = std::experimental::filesystem; constexpr auto path = "/dummy/user"; constexpr auto testShadow = "/tmp/__tshadow__"; -constexpr auto shadowCopy = "/tmp/__tshadowCopy__"; constexpr auto shadowCompare = "/tmp/__tshadowCompare__"; // New password @@ -64,11 +63,6 @@ class UserTest : public ::testing::Test fs::remove(testShadow); } - if (fs::exists(shadowCopy)) - { - fs::remove(shadowCopy); - } - if (fs::exists(shadowCompare)) { fs::remove(shadowCompare); @@ -103,8 +97,7 @@ class UserTest : public ::testing::Test /** @brief Applies the new password */ auto applyPassword() { - return user.applyPassword(testShadow, shadowCopy, - password, salt); + return user.applyPassword(testShadow, password, salt); } }; @@ -168,22 +161,6 @@ TEST_F(UserTest, applyPassword) EXPECT_EQ(shadowEntry, shadowCompareEntry); } -/** @brief Verifies the shadow copy file is removed - */ -TEST_F(UserTest, checkShadowCopyRemove) -{ - // Update the password so that the temp file is in action - applyPassword(); - - // Compare the permission of 2 files - struct stat shadow{}; - struct stat temp{}; - - stat(testShadow, &shadow); - stat(shadowCopy, &temp); - EXPECT_EQ(false, fs::exists(shadowCopy)); -} - /** @brief Verifies the permissions are correct */ TEST_F(UserTest, verifyShadowPermission) |