2015-10-29 19:34:36 +01:00
|
|
|
#include "testutils/CliTest.h"
|
|
|
|
|
|
|
|
using cpputils::TempFile;
|
|
|
|
|
2020-02-24 02:42:44 +01:00
|
|
|
namespace bf = boost::filesystem;
|
|
|
|
|
2015-10-29 19:34:36 +01:00
|
|
|
//Tests that cryfs is correctly setup according to the CLI parameters specified
|
|
|
|
using CliTest_Setup = CliTest;
|
|
|
|
|
|
|
|
TEST_F(CliTest_Setup, NoSpecialOptions) {
|
2016-02-13 15:06:28 +01:00
|
|
|
//Specify --cipher parameter to make it non-interactive
|
2015-11-03 22:02:04 +01:00
|
|
|
//TODO Remove "-f" parameter, once EXPECT_RUN_SUCCESS can handle that
|
2018-05-21 01:20:38 +02:00
|
|
|
EXPECT_RUN_SUCCESS({basedir.string().c_str(), mountdir.string().c_str(), "--cipher", "aes-256-gcm", "-f"}, mountdir);
|
2015-10-29 19:34:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(CliTest_Setup, NotexistingLogfileGiven) {
|
|
|
|
TempFile notexisting_logfile(false);
|
2016-02-13 15:06:28 +01:00
|
|
|
//Specify --cipher parameter to make it non-interactive
|
2015-11-03 22:02:04 +01:00
|
|
|
//TODO Remove "-f" parameter, once EXPECT_RUN_SUCCESS can handle that
|
2018-05-21 01:20:38 +02:00
|
|
|
EXPECT_RUN_SUCCESS({basedir.string().c_str(), mountdir.string().c_str(), "-f", "--cipher", "aes-256-gcm", "--logfile", notexisting_logfile.path().string().c_str()}, mountdir);
|
2015-10-29 19:34:36 +01:00
|
|
|
//TODO Expect logfile is used (check logfile content)
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(CliTest_Setup, ExistingLogfileGiven) {
|
2016-02-13 15:06:28 +01:00
|
|
|
//Specify --cipher parameter to make it non-interactive
|
2015-11-03 22:02:04 +01:00
|
|
|
//TODO Remove "-f" parameter, once EXPECT_RUN_SUCCESS can handle that
|
2018-05-21 01:20:38 +02:00
|
|
|
EXPECT_RUN_SUCCESS({basedir.string().c_str(), mountdir.string().c_str(), "-f", "--cipher", "aes-256-gcm", "--logfile", logfile.path().string().c_str()}, mountdir);
|
2015-10-29 19:34:36 +01:00
|
|
|
//TODO Expect logfile is used (check logfile content)
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(CliTest_Setup, ConfigfileGiven) {
|
2016-02-13 15:06:28 +01:00
|
|
|
//Specify --cipher parameter to make it non-interactive
|
2015-11-03 22:02:04 +01:00
|
|
|
//TODO Remove "-f" parameter, once EXPECT_RUN_SUCCESS can handle that
|
2018-05-21 01:20:38 +02:00
|
|
|
EXPECT_RUN_SUCCESS({basedir.string().c_str(), mountdir.string().c_str(), "-f", "--cipher", "aes-256-gcm", "--config", configfile.path().string().c_str()}, mountdir);
|
2015-10-29 19:34:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(CliTest_Setup, FuseOptionGiven) {
|
2016-02-13 15:06:28 +01:00
|
|
|
//Specify --cipher parameter to make it non-interactive
|
2015-11-03 22:02:04 +01:00
|
|
|
//TODO Remove "-f" parameter, once EXPECT_RUN_SUCCESS can handle that
|
2018-05-21 01:20:38 +02:00
|
|
|
EXPECT_RUN_SUCCESS({basedir.string().c_str(), mountdir.string().c_str(), "-f", "--cipher", "aes-256-gcm", "--", "-f"}, mountdir);
|
2019-10-13 14:16:06 +02:00
|
|
|
}
|
2020-02-24 02:42:44 +01:00
|
|
|
|
|
|
|
TEST_F(CliTest, WorksWithCommasInBasedir) {
|
|
|
|
// This test makes sure we don't regress on https://github.com/cryfs/cryfs/issues/326
|
|
|
|
//TODO Remove "-f" parameter, once EXPECT_RUN_SUCCESS can handle that
|
|
|
|
auto basedir_ = basedir / "pathname,with,commas";
|
|
|
|
bf::create_directory(basedir_);
|
|
|
|
EXPECT_RUN_SUCCESS({basedir_.string().c_str(), mountdir.string().c_str(), "-f"}, mountdir);
|
|
|
|
}
|