mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-10 16:24:45 -07:00
add password hash test (#4528)
* clangify tests * add password hash test * properly use googletest semantics
This commit is contained in:
parent
f6634de18d
commit
1e70989f38
8 changed files with 125 additions and 81 deletions
39
tests/password_hash_test.cpp
Normal file
39
tests/password_hash_test.cpp
Normal 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();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue