From 6e8ba129736f693d0d64163305c30de54ff02f44 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 26 Oct 2017 19:43:33 +0100 Subject: Add tests over permissions with creation of files --- netfs/unittests/testCore.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) 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); } -- cgit v1.2.3