refactor
This commit is contained in:
parent
fc7c6b9705
commit
a4693f8acc
@ -26,14 +26,14 @@
|
||||
namespace repertory {
|
||||
TYPED_TEST_CASE(fuse_test, fuse_provider_types);
|
||||
|
||||
TYPED_TEST(fuse_test, can_chmod_if_owner) {
|
||||
TYPED_TEST(fuse_test, chmod_can_chmod_if_owner) {
|
||||
std::string file_name{"chmod_test"};
|
||||
auto file_path = this->create_file_and_test(file_name);
|
||||
|
||||
EXPECT_EQ(0, chmod(file_path.c_str(), S_IRUSR | S_IWUSR));
|
||||
std::this_thread::sleep_for(SLEEP_SECONDS);
|
||||
|
||||
struct stat64 unix_st{};
|
||||
struct stat64 unix_st {};
|
||||
stat64(file_path.c_str(), &unix_st);
|
||||
EXPECT_EQ(static_cast<std::uint32_t>(S_IRUSR | S_IWUSR),
|
||||
ACCESSPERMS & unix_st.st_mode);
|
||||
@ -41,7 +41,7 @@ TYPED_TEST(fuse_test, can_chmod_if_owner) {
|
||||
this->unlink_file_and_test(file_path);
|
||||
}
|
||||
|
||||
TYPED_TEST(fuse_test, can_not_chmod_if_not_owner) {
|
||||
TYPED_TEST(fuse_test, chmod_can_not_chmod_if_not_owner) {
|
||||
std::string file_name{"chmod_test"};
|
||||
auto file_path = this->create_root_file(file_name);
|
||||
|
||||
@ -51,7 +51,7 @@ TYPED_TEST(fuse_test, can_not_chmod_if_not_owner) {
|
||||
this->unlink_root_file(file_path);
|
||||
}
|
||||
|
||||
TYPED_TEST(fuse_test, can_not_chmod_setgid_if_not_root) {
|
||||
TYPED_TEST(fuse_test, chmod_can_not_chmod_setgid_if_not_root) {
|
||||
std::string file_name{"chmod_test"};
|
||||
auto file_path = this->create_file_and_test(file_name);
|
||||
|
||||
@ -61,7 +61,7 @@ TYPED_TEST(fuse_test, can_not_chmod_setgid_if_not_root) {
|
||||
this->unlink_file_and_test(file_path);
|
||||
}
|
||||
|
||||
TYPED_TEST(fuse_test, can_not_chmod_setuid_if_not_root) {
|
||||
TYPED_TEST(fuse_test, chmod_can_not_chmod_setuid_if_not_root) {
|
||||
std::string file_name{"chmod_test"};
|
||||
auto file_path = this->create_file_and_test(file_name);
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
namespace repertory {
|
||||
TYPED_TEST_CASE(fuse_test, fuse_provider_types);
|
||||
|
||||
TYPED_TEST(fuse_test, can_not_chmod_set_sticky_if_not_root) {
|
||||
TYPED_TEST(fuse_test, chown_can_not_chmod_set_sticky_if_not_root) {
|
||||
std::string file_name{"chown_test"};
|
||||
auto file_path = this->create_file_and_test(file_name);
|
||||
|
||||
@ -36,17 +36,18 @@ TYPED_TEST(fuse_test, can_not_chmod_set_sticky_if_not_root) {
|
||||
this->unlink_file_and_test(file_path);
|
||||
}
|
||||
|
||||
TYPED_TEST(fuse_test, can_chown_group_if_owner_and_a_member_of_the_group) {
|
||||
TYPED_TEST(fuse_test,
|
||||
chown_can_chown_group_if_owner_and_a_member_of_the_group) {
|
||||
std::string file_name{"chown_test"};
|
||||
auto file_path = this->create_file_and_test(file_name);
|
||||
|
||||
struct stat64 unix_st{};
|
||||
struct stat64 unix_st {};
|
||||
EXPECT_EQ(0, stat64(file_path.c_str(), &unix_st));
|
||||
|
||||
EXPECT_EQ(0, chown(file_path.c_str(), static_cast<uid_t>(-1), getgid()));
|
||||
std::this_thread::sleep_for(SLEEP_SECONDS);
|
||||
|
||||
struct stat64 unix_st2{};
|
||||
struct stat64 unix_st2 {};
|
||||
stat64(file_path.c_str(), &unix_st2);
|
||||
EXPECT_EQ(getgid(), unix_st2.st_gid);
|
||||
EXPECT_EQ(unix_st.st_uid, unix_st2.st_uid);
|
||||
@ -55,17 +56,17 @@ TYPED_TEST(fuse_test, can_chown_group_if_owner_and_a_member_of_the_group) {
|
||||
}
|
||||
|
||||
TYPED_TEST(fuse_test,
|
||||
can_not_chown_group_if_owner_but_not_a_member_of_the_group) {
|
||||
chown_can_not_chown_group_if_owner_but_not_a_member_of_the_group) {
|
||||
std::string file_name{"chown_test"};
|
||||
auto file_path = this->create_file_and_test(file_name);
|
||||
|
||||
struct stat64 unix_st{};
|
||||
struct stat64 unix_st {};
|
||||
EXPECT_EQ(0, stat64(file_path.c_str(), &unix_st));
|
||||
|
||||
EXPECT_EQ(-1, chown(file_path.c_str(), static_cast<uid_t>(-1), 0));
|
||||
EXPECT_EQ(EPERM, errno);
|
||||
|
||||
struct stat64 unix_st2{};
|
||||
struct stat64 unix_st2 {};
|
||||
stat64(file_path.c_str(), &unix_st2);
|
||||
EXPECT_EQ(unix_st.st_gid, unix_st2.st_gid);
|
||||
EXPECT_EQ(unix_st.st_uid, unix_st2.st_uid);
|
||||
@ -73,17 +74,17 @@ TYPED_TEST(fuse_test,
|
||||
this->unlink_file_and_test(file_path);
|
||||
}
|
||||
|
||||
TYPED_TEST(fuse_test, can_not_chown_group_if_not_the_owner) {
|
||||
TYPED_TEST(fuse_test, chown_can_not_chown_group_if_not_the_owner) {
|
||||
std::string file_name{"chown_test"};
|
||||
auto file_path = this->create_root_file(file_name);
|
||||
|
||||
struct stat64 unix_st{};
|
||||
struct stat64 unix_st {};
|
||||
EXPECT_EQ(0, stat64(file_path.c_str(), &unix_st));
|
||||
|
||||
EXPECT_EQ(-1, chown(file_path.c_str(), static_cast<uid_t>(-1), getgid()));
|
||||
EXPECT_EQ(EPERM, errno);
|
||||
|
||||
struct stat64 unix_st2{};
|
||||
struct stat64 unix_st2 {};
|
||||
stat64(file_path.c_str(), &unix_st2);
|
||||
EXPECT_EQ(unix_st.st_gid, unix_st2.st_gid);
|
||||
EXPECT_EQ(unix_st.st_uid, unix_st2.st_uid);
|
||||
@ -91,17 +92,17 @@ TYPED_TEST(fuse_test, can_not_chown_group_if_not_the_owner) {
|
||||
this->unlink_root_file(file_path);
|
||||
}
|
||||
|
||||
TYPED_TEST(fuse_test, can_not_chown_user_if_not_root) {
|
||||
TYPED_TEST(fuse_test, chown_can_not_chown_user_if_not_root) {
|
||||
std::string file_name{"chown_test"};
|
||||
auto file_path = this->create_file_and_test(file_name);
|
||||
|
||||
struct stat64 unix_st{};
|
||||
struct stat64 unix_st {};
|
||||
EXPECT_EQ(0, stat64(file_path.c_str(), &unix_st));
|
||||
|
||||
EXPECT_EQ(-1, chown(file_path.c_str(), 0, static_cast<gid_t>(-1)));
|
||||
EXPECT_EQ(EPERM, errno);
|
||||
|
||||
struct stat64 unix_st2{};
|
||||
struct stat64 unix_st2 {};
|
||||
stat64(file_path.c_str(), &unix_st2);
|
||||
EXPECT_EQ(unix_st.st_gid, unix_st2.st_gid);
|
||||
EXPECT_EQ(unix_st.st_uid, unix_st2.st_uid);
|
||||
|
@ -26,7 +26,7 @@
|
||||
namespace repertory {
|
||||
TYPED_TEST_CASE(fuse_test, fuse_provider_types);
|
||||
|
||||
TYPED_TEST(fuse_test, can_create_and_remove_directory) {
|
||||
TYPED_TEST(fuse_test, directory_can_create_and_remove_directory) {
|
||||
auto dir_name = std::string{"dir"};
|
||||
|
||||
auto dir_path = utils::path::combine(this->mount_location, {dir_name});
|
||||
|
Loading…
x
Reference in New Issue
Block a user