2016-06-26 23:35:52 +02:00
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
2016-06-27 01:53:10 +02:00
|
|
|
#include "cryfs/localstate/MyClientId.h"
|
2016-06-26 23:35:52 +02:00
|
|
|
#include <cpp-utils/tempfile/TempDir.h>
|
|
|
|
|
|
|
|
using cpputils::TempDir;
|
|
|
|
using cryfs::MyClientId;
|
|
|
|
|
|
|
|
class MyClientIdTest : public ::testing::Test {
|
|
|
|
public:
|
|
|
|
TempDir stateDir;
|
|
|
|
TempDir stateDir2;
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_F(MyClientIdTest, ValueIsConsistent) {
|
|
|
|
uint32_t myClientId = MyClientId(stateDir.path()).loadOrGenerate();
|
|
|
|
EXPECT_EQ(myClientId, MyClientId(stateDir.path()).loadOrGenerate());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(MyClientIdTest, ValueIsRandomForNewClient) {
|
|
|
|
uint32_t myClientId = MyClientId(stateDir.path()).loadOrGenerate();
|
|
|
|
EXPECT_NE(myClientId, MyClientId(stateDir2.path()).loadOrGenerate());
|
|
|
|
}
|