From 11c6f7fa9866f0a0e6d4444fac191b5d96305c4f Mon Sep 17 00:00:00 2001 From: Sebastian Messmer Date: Thu, 1 Feb 2018 02:33:33 -0800 Subject: [PATCH] Fix test cases --- .../program_options/ProgramOptionsTest.cpp | 32 +++++++++---------- test/cryfs/config/CryConfigLoaderTest.cpp | 14 ++++---- test/cryfs/filesystem/CryFsTest.cpp | 2 +- test/cryfs/filesystem/FileSystemTest.cpp | 2 +- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/test/cryfs-cli/program_options/ProgramOptionsTest.cpp b/test/cryfs-cli/program_options/ProgramOptionsTest.cpp index 6e910b2c..802581c9 100644 --- a/test/cryfs-cli/program_options/ProgramOptionsTest.cpp +++ b/test/cryfs-cli/program_options/ProgramOptionsTest.cpp @@ -23,83 +23,83 @@ namespace boost { class ProgramOptionsTest: public ProgramOptionsTestBase {}; TEST_F(ProgramOptionsTest, BaseDir) { - ProgramOptions testobj("/home/user/mydir", "", none, false, none, none, none, none, {"./myExecutable"}); + ProgramOptions testobj("/home/user/mydir", "", none, false, false, none, none, none, none, {"./myExecutable"}); EXPECT_EQ("/home/user/mydir", testobj.baseDir()); } TEST_F(ProgramOptionsTest, MountDir) { - ProgramOptions testobj("", "/home/user/mydir", none, false, none, none, none, none, {"./myExecutable"}); + ProgramOptions testobj("", "/home/user/mydir", none, false, false, none, none, none, none, {"./myExecutable"}); EXPECT_EQ("/home/user/mydir", testobj.mountDir()); } TEST_F(ProgramOptionsTest, ConfigfileNone) { - ProgramOptions testobj("", "", none, true, none, none, none, none, {"./myExecutable"}); + ProgramOptions testobj("", "", none, true, false, none, none, none, none, {"./myExecutable"}); EXPECT_EQ(none, testobj.configFile()); } TEST_F(ProgramOptionsTest, ConfigfileSome) { - ProgramOptions testobj("", "", bf::path("/home/user/configfile"), true, none, none, none, none, {"./myExecutable"}); + ProgramOptions testobj("", "", bf::path("/home/user/configfile"), true, false, none, none, none, none, {"./myExecutable"}); EXPECT_EQ("/home/user/configfile", testobj.configFile().get()); } TEST_F(ProgramOptionsTest, ForegroundFalse) { - ProgramOptions testobj("", "", none, false, none, none, none, none, {"./myExecutable"}); + ProgramOptions testobj("", "", none, false, false, none, none, none, none, {"./myExecutable"}); EXPECT_FALSE(testobj.foreground()); } TEST_F(ProgramOptionsTest, ForegroundTrue) { - ProgramOptions testobj("", "", none, true, none, none, none, none, {"./myExecutable"}); + ProgramOptions testobj("", "", none, true, false, none, none, none, none, {"./myExecutable"}); EXPECT_TRUE(testobj.foreground()); } TEST_F(ProgramOptionsTest, LogfileNone) { - ProgramOptions testobj("", "", none, true, none, none, none, none, {"./myExecutable"}); + ProgramOptions testobj("", "", none, true, false, none, none, none, none, {"./myExecutable"}); EXPECT_EQ(none, testobj.logFile()); } TEST_F(ProgramOptionsTest, LogfileSome) { - ProgramOptions testobj("", "", none, true, none, bf::path("logfile"), none, none, {"./myExecutable"}); + ProgramOptions testobj("", "", none, true, false, none, bf::path("logfile"), none, none, {"./myExecutable"}); EXPECT_EQ("logfile", testobj.logFile().get()); } TEST_F(ProgramOptionsTest, UnmountAfterIdleMinutesNone) { -ProgramOptions testobj("", "", none, true, none, none, none, none, {"./myExecutable"}); +ProgramOptions testobj("", "", none, true, false, none, none, none, none, {"./myExecutable"}); EXPECT_EQ(none, testobj.unmountAfterIdleMinutes()); } TEST_F(ProgramOptionsTest, UnmountAfterIdleMinutesSome) { - ProgramOptions testobj("", "", none, true, 10, none, none, none, {"./myExecutable"}); + ProgramOptions testobj("", "", none, true, false, 10, none, none, none, {"./myExecutable"}); EXPECT_EQ(10, testobj.unmountAfterIdleMinutes().get()); } TEST_F(ProgramOptionsTest, CipherNone) { - ProgramOptions testobj("", "", none, true, none, none, none, none, {"./myExecutable"}); + ProgramOptions testobj("", "", none, true, false, none, none, none, none, {"./myExecutable"}); EXPECT_EQ(none, testobj.cipher()); } TEST_F(ProgramOptionsTest, CipherSome) { - ProgramOptions testobj("", "", none, true, none, none, string("aes-256-gcm"), none, {"./myExecutable"}); + ProgramOptions testobj("", "", none, true, false, none, none, string("aes-256-gcm"), none, {"./myExecutable"}); EXPECT_EQ("aes-256-gcm", testobj.cipher().get()); } TEST_F(ProgramOptionsTest, BlocksizeBytesNone) { - ProgramOptions testobj("", "", none, true, none, none, none, none, {"./myExecutable"}); + ProgramOptions testobj("", "", none, true, false, none, none, none, none, {"./myExecutable"}); EXPECT_EQ(none, testobj.blocksizeBytes()); } TEST_F(ProgramOptionsTest, BlocksizeSome) { - ProgramOptions testobj("", "", none, true, none, none, none, 10*1024, {"./myExecutable"}); + ProgramOptions testobj("", "", none, true, false, none, none, none, 10*1024, {"./myExecutable"}); EXPECT_EQ(10*1024u, testobj.blocksizeBytes().get()); } TEST_F(ProgramOptionsTest, EmptyFuseOptions) { - ProgramOptions testobj("/rootDir", "/home/user/mydir", none, false, none, none, none, none, {}); + ProgramOptions testobj("/rootDir", "/home/user/mydir", none, false, false, none, none, none, none, {}); //Fuse should have the mount dir as first parameter EXPECT_VECTOR_EQ({}, testobj.fuseOptions()); } TEST_F(ProgramOptionsTest, SomeFuseOptions) { - ProgramOptions testobj("/rootDir", "/home/user/mydir", none, false, none, none, none, none, {"-f", "--longoption"}); + ProgramOptions testobj("/rootDir", "/home/user/mydir", none, false, false, none, none, none, none, {"-f", "--longoption"}); //Fuse should have the mount dir as first parameter EXPECT_VECTOR_EQ({"-f", "--longoption"}, testobj.fuseOptions()); } diff --git a/test/cryfs/config/CryConfigLoaderTest.cpp b/test/cryfs/config/CryConfigLoaderTest.cpp index d6b37d55..72f12d2e 100644 --- a/test/cryfs/config/CryConfigLoaderTest.cpp +++ b/test/cryfs/config/CryConfigLoaderTest.cpp @@ -53,41 +53,41 @@ public: CryConfigFile Create(const string &password = "mypassword", const optional &cipher = none, bool noninteractive = false) { EXPECT_FALSE(file.exists()); - return loader(password, noninteractive, cipher).loadOrCreate(file.path()).value(); + return loader(password, noninteractive, cipher).loadOrCreate(file.path(), false).value(); } optional Load(const string &password = "mypassword", const optional &cipher = none, bool noninteractive = false) { EXPECT_TRUE(file.exists()); - return loader(password, noninteractive, cipher).loadOrCreate(file.path()); + return loader(password, noninteractive, cipher).loadOrCreate(file.path(), false); } void CreateWithRootBlob(const string &rootBlob, const string &password = "mypassword") { - auto cfg = loader(password, false).loadOrCreate(file.path()).value(); + auto cfg = loader(password, false).loadOrCreate(file.path(), false).value(); cfg.config()->SetRootBlob(rootBlob); cfg.save(); } void CreateWithCipher(const string &cipher, const string &password = "mypassword") { - auto cfg = loader(password, false).loadOrCreate(file.path()).value(); + auto cfg = loader(password, false).loadOrCreate(file.path(), false).value(); cfg.config()->SetCipher(cipher); cfg.save(); } void CreateWithEncryptionKey(const string &encKey, const string &password = "mypassword") { - auto cfg = loader(password, false).loadOrCreate(file.path()).value(); + auto cfg = loader(password, false).loadOrCreate(file.path(), false).value(); cfg.config()->SetEncryptionKey(encKey); cfg.save(); } void CreateWithVersion(const string &version, const string &password = "mypassword") { - auto cfg = loader(password, false).loadOrCreate(file.path()).value(); + auto cfg = loader(password, false).loadOrCreate(file.path(), false).value(); cfg.config()->SetVersion(version); cfg.config()->SetCreatedWithVersion(version); cfg.save(); } void CreateWithFilesystemID(const CryConfig::FilesystemID &filesystemId, const string &password = "mypassword") { - auto cfg = loader(password, false).loadOrCreate(file.path()).value(); + auto cfg = loader(password, false).loadOrCreate(file.path(), false).value(); cfg.config()->SetFilesystemId(filesystemId); cfg.save(); } diff --git a/test/cryfs/filesystem/CryFsTest.cpp b/test/cryfs/filesystem/CryFsTest.cpp index c9d8726a..37c12aa7 100644 --- a/test/cryfs/filesystem/CryFsTest.cpp +++ b/test/cryfs/filesystem/CryFsTest.cpp @@ -40,7 +40,7 @@ public: CryConfigFile loadOrCreateConfig() { auto askPassword = [] {return "mypassword";}; - return CryConfigLoader(make_shared(mockConsole()), Random::PseudoRandom(), SCrypt::TestSettings, askPassword, askPassword, none, none).loadOrCreate(config.path()).value(); + return CryConfigLoader(make_shared(mockConsole()), Random::PseudoRandom(), SCrypt::TestSettings, askPassword, askPassword, none, none).loadOrCreate(config.path(), false).value(); } unique_ref blockStore() { diff --git a/test/cryfs/filesystem/FileSystemTest.cpp b/test/cryfs/filesystem/FileSystemTest.cpp index 77d3dfa6..a99b5aaf 100644 --- a/test/cryfs/filesystem/FileSystemTest.cpp +++ b/test/cryfs/filesystem/FileSystemTest.cpp @@ -30,7 +30,7 @@ public: auto blockStore = cpputils::make_unique_ref(); auto askPassword = [] {return "mypassword";}; auto config = CryConfigLoader(make_shared(mockConsole()), Random::PseudoRandom(), SCrypt::TestSettings, askPassword, askPassword, none, none) - .loadOrCreate(configFile.path()).value(); + .loadOrCreate(configFile.path(), false).value(); return make_unique_ref(std::move(config), std::move(blockStore)); }