summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2017-10-26 19:43:33 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2017-12-16 20:40:40 +0000
commit6e8ba129736f693d0d64163305c30de54ff02f44 (patch)
treedf8b172dd7fddc58920adb3008f5413314eb78d1
parentRelax mode checking in rmdir as it is actually too strict (diff)
downloadnetfs-6e8ba129736f693d0d64163305c30de54ff02f44.tar.bz2
netfs-6e8ba129736f693d0d64163305c30de54ff02f44.tar.xz
netfs-6e8ba129736f693d0d64163305c30de54ff02f44.zip
Add tests over permissions with creation of files
-rw-r--r--netfs/unittests/testCore.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/netfs/unittests/testCore.cpp b/netfs/unittests/testCore.cpp
index 6bf443f..a55081c 100644
--- a/netfs/unittests/testCore.cpp
+++ b/netfs/unittests/testCore.cpp
@@ -275,6 +275,7 @@ BOOST_AUTO_TEST_CASE( access )
memset(&st, 0, sizeof(st));
BOOST_REQUIRE_EQUAL(fuse->access("/", F_OK), 0);
BOOST_REQUIRE_EQUAL(fuse->access("/missing", F_OK), -ENOENT);
+ // Basic assertions
BOOST_REQUIRE_EQUAL(fuse->mkdir("/dir", 0700), 0);
BOOST_REQUIRE_EQUAL(fuse->getattr("/dir", &st), 0);
BOOST_REQUIRE_EQUAL(st.st_mode, 0700 | S_IFDIR);
@@ -306,6 +307,27 @@ BOOST_AUTO_TEST_CASE( access )
BOOST_REQUIRE_EQUAL(st.st_mode, 0700 | S_IFDIR);
BOOST_REQUIRE_EQUAL(fuse->rmdir("/dir/yes"), 0);
BOOST_REQUIRE_EQUAL(fuse->getattr("/dir/yes", &st), -ENOENT);
+ // Child permissions (files)
+ struct fuse_file_info fi;
+ memset(&fi, 0, sizeof(fi));
+ fi.flags = O_RDWR;
+ BOOST_REQUIRE_EQUAL(fuse->chmod("/dir", 0700), 0);
+ BOOST_REQUIRE_NE(fuse->create("/dir/yes", 0000, &fi), -1);
+ BOOST_REQUIRE_EQUAL(fuse->release("/dir/yes", &fi), 0);
+ BOOST_REQUIRE_EQUAL(fuse->getattr("/dir/yes", &st), 0);
+ BOOST_REQUIRE_EQUAL(st.st_mode, 0000 | S_IFREG);
+ BOOST_REQUIRE_EQUAL(fuse->chmod("/dir", 0500), 0);
+ BOOST_REQUIRE_EQUAL(fuse->getattr("/dir", &st), 0);
+ BOOST_REQUIRE_EQUAL(st.st_mode, 0500 | S_IFDIR);
+ BOOST_REQUIRE_EQUAL(fuse->create("/dir/no", 0600, &fi), -EACCES);
+ BOOST_REQUIRE_EQUAL(fuse->getattr("/dir/no", &st), -ENOENT);
+ BOOST_REQUIRE_EQUAL(fuse->unlink("/dir/yes"), -EACCES);
+ BOOST_REQUIRE_EQUAL(fuse->chmod("/dir", 0700), 0);
+ BOOST_REQUIRE_EQUAL(fuse->getattr("/dir", &st), 0);
+ BOOST_REQUIRE_EQUAL(st.st_mode, 0700 | S_IFDIR);
+ BOOST_REQUIRE_EQUAL(fuse->unlink("/dir/yes"), 0);
+ BOOST_REQUIRE_EQUAL(fuse->getattr("/dir/yes", &st), -ENOENT);
+ // Tidy up
BOOST_REQUIRE_EQUAL(fuse->rmdir("/dir"), 0);
BOOST_REQUIRE_EQUAL(fuse->getattr("/dir", &st), -ENOENT);
}