Add test cases for --allow-filesystem-upgrade
This commit is contained in:
parent
11c6f7fa98
commit
67afdd4baa
@ -25,7 +25,6 @@ namespace cryfs {
|
|||||||
const boost::filesystem::path &mountDir() const;
|
const boost::filesystem::path &mountDir() const;
|
||||||
const boost::optional<boost::filesystem::path> &configFile() const;
|
const boost::optional<boost::filesystem::path> &configFile() const;
|
||||||
bool foreground() const;
|
bool foreground() const;
|
||||||
// TODO add test cases for allowFilesystemUpgrade
|
|
||||||
bool allowFilesystemUpgrade() const;
|
bool allowFilesystemUpgrade() const;
|
||||||
const boost::optional<std::string> &cipher() const;
|
const boost::optional<std::string> &cipher() const;
|
||||||
const boost::optional<uint32_t> &blocksizeBytes() const;
|
const boost::optional<uint32_t> &blocksizeBytes() const;
|
||||||
|
@ -74,6 +74,26 @@ TEST_F(ProgramOptionsParserTest, MountDir_Relative) {
|
|||||||
EXPECT_EQ(bf::current_path() / "mountDir", options.mountDir());
|
EXPECT_EQ(bf::current_path() / "mountDir", options.mountDir());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(ProgramOptionsParserTest, Foreground_False) {
|
||||||
|
ProgramOptions options = parse({"./myExecutable", "/home/user/basedir", "mountdir"});
|
||||||
|
EXPECT_FALSE(options.foreground());
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(ProgramOptionsParserTest, Foreground_True) {
|
||||||
|
ProgramOptions options = parse({"./myExecutable", "-f", "/home/user/basedir", "mountdir"});
|
||||||
|
EXPECT_TRUE(options.foreground());
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(ProgramOptionsParserTest, AllowFilesystemUpgrade_False) {
|
||||||
|
ProgramOptions options = parse({"./myExecutable", "/home/user/basedir", "mountdir"});
|
||||||
|
EXPECT_FALSE(options.allowFilesystemUpgrade());
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(ProgramOptionsParserTest, AllowFilesystemUpgrade_True) {
|
||||||
|
ProgramOptions options = parse({"./myExecutable", "--allow-filesystem-upgrade", "/home/user/basedir", "mountdir"});
|
||||||
|
EXPECT_TRUE(options.allowFilesystemUpgrade());
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(ProgramOptionsParserTest, LogfileGiven) {
|
TEST_F(ProgramOptionsParserTest, LogfileGiven) {
|
||||||
ProgramOptions options = parse({"./myExecutable", "/home/user/baseDir", "--logfile", "/home/user/mylogfile", "/home/user/mountDir"});
|
ProgramOptions options = parse({"./myExecutable", "/home/user/baseDir", "--logfile", "/home/user/mylogfile", "/home/user/mountDir"});
|
||||||
EXPECT_EQ("/home/user/mylogfile", options.logFile().value());
|
EXPECT_EQ("/home/user/mylogfile", options.logFile().value());
|
||||||
|
@ -52,6 +52,16 @@ TEST_F(ProgramOptionsTest, ForegroundTrue) {
|
|||||||
EXPECT_TRUE(testobj.foreground());
|
EXPECT_TRUE(testobj.foreground());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(ProgramOptionsTest, AllowFilesystemUpgradeFalse) {
|
||||||
|
ProgramOptions testobj("", "", none, false, false, none, none, none, none, {"./myExecutable"});
|
||||||
|
EXPECT_FALSE(testobj.allowFilesystemUpgrade());
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(ProgramOptionsTest, AllowFilesystemUpgradeTrue) {
|
||||||
|
ProgramOptions testobj("", "", none, false, true, none, none, none, none, {"./myExecutable"});
|
||||||
|
EXPECT_TRUE(testobj.allowFilesystemUpgrade());
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(ProgramOptionsTest, LogfileNone) {
|
TEST_F(ProgramOptionsTest, LogfileNone) {
|
||||||
ProgramOptions testobj("", "", none, true, false, none, none, none, none, {"./myExecutable"});
|
ProgramOptions testobj("", "", none, true, false, none, none, none, none, {"./myExecutable"});
|
||||||
EXPECT_EQ(none, testobj.logFile());
|
EXPECT_EQ(none, testobj.logFile());
|
||||||
@ -103,3 +113,4 @@ TEST_F(ProgramOptionsTest, SomeFuseOptions) {
|
|||||||
//Fuse should have the mount dir as first parameter
|
//Fuse should have the mount dir as first parameter
|
||||||
EXPECT_VECTOR_EQ({"-f", "--longoption"}, testobj.fuseOptions());
|
EXPECT_VECTOR_EQ({"-f", "--longoption"}, testobj.fuseOptions());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,9 +56,9 @@ public:
|
|||||||
return loader(password, noninteractive, cipher).loadOrCreate(file.path(), false).value();
|
return loader(password, noninteractive, cipher).loadOrCreate(file.path(), false).value();
|
||||||
}
|
}
|
||||||
|
|
||||||
optional<CryConfigFile> Load(const string &password = "mypassword", const optional<string> &cipher = none, bool noninteractive = false) {
|
optional<CryConfigFile> Load(const string &password = "mypassword", const optional<string> &cipher = none, bool noninteractive = false, bool allowFilesystemUpgrade = false) {
|
||||||
EXPECT_TRUE(file.exists());
|
EXPECT_TRUE(file.exists());
|
||||||
return loader(password, noninteractive, cipher).loadOrCreate(file.path(), false);
|
return loader(password, noninteractive, cipher).loadOrCreate(file.path(), allowFilesystemUpgrade);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateWithRootBlob(const string &rootBlob, const string &password = "mypassword") {
|
void CreateWithRootBlob(const string &rootBlob, const string &password = "mypassword") {
|
||||||
@ -276,3 +276,19 @@ TEST_F(CryConfigLoaderTest, DontMigrateWhenAnsweredNo) {
|
|||||||
EXPECT_THAT(e.what(), HasSubstr("It has to be migrated."));
|
EXPECT_THAT(e.what(), HasSubstr("It has to be migrated."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(CryConfigLoaderTest, DoesNotAskForMigrationWhenUpgradesAllowedByProgramArguments_NoninteractiveMode) {
|
||||||
|
EXPECT_CALL(*console, askYesNo(HasSubstr("migrate"), _)).Times(0);
|
||||||
|
|
||||||
|
string version = olderVersion();
|
||||||
|
CreateWithVersion(version);
|
||||||
|
EXPECT_NE(boost::none, Load("mypassword", none, true, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(CryConfigLoaderTest, DoesNotAskForMigrationWhenUpgradesAllowedByProgramArguments_InteractiveMode) {
|
||||||
|
EXPECT_CALL(*console, askYesNo(HasSubstr("migrate"), _)).Times(0);
|
||||||
|
|
||||||
|
string version = olderVersion();
|
||||||
|
CreateWithVersion(version);
|
||||||
|
EXPECT_NE(boost::none, Load("mypassword", none, false, true));
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user