add password hash test (#4528)

* clangify tests

* add password hash test

* properly use googletest semantics
This commit is contained in:
ebbit1q 2022-01-16 22:32:11 +01:00 committed by GitHub
parent f6634de18d
commit 1e70989f38
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 125 additions and 81 deletions

View file

@ -0,0 +1,39 @@
#include "../common/passwordhasher.h"
#include "../common/rng_abstract.h"
#include "../common/rng_sfmt.h"
#include "gtest/gtest.h"
RNG_Abstract *rng;
namespace
{
class PasswordHashTest : public ::testing::Test
{
protected:
void SetUp() override
{
rng = new RNG_SFMT;
}
void TearDown() override
{
delete rng;
}
};
TEST(PasswordHashTest, RegressionTest)
{
QString salt = "saltsaltsaltsalt";
QString password = "password";
QString expected = "vmKoWv975yf+WT2QCXhW48JNzZ2ghGxdgNvuKLBU0h7s6AQHSG72J6QO4ZswuSeqvBbAXbmgJSRBaSJrgc55WA==";
QString hash = PasswordHasher::computeHash(password, salt);
ASSERT_EQ(hash, salt + expected) << "The computed hash value remains the same";
}
} // namespace
int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}