diff options
-rw-r--r-- | netfs/fuse/fuseMappersImpl.cpp | 5 | ||||
-rw-r--r-- | netfs/fuse/fuseMappersImpl.h | 3 | ||||
-rw-r--r-- | netfs/unittests/testLib.cpp | 34 |
3 files changed, 40 insertions, 2 deletions
diff --git a/netfs/fuse/fuseMappersImpl.cpp b/netfs/fuse/fuseMappersImpl.cpp index 87266b1..d22f3a4 100644 --- a/netfs/fuse/fuseMappersImpl.cpp +++ b/netfs/fuse/fuseMappersImpl.cpp @@ -2,6 +2,9 @@ #include <entCache.h> namespace NetFS::Client { + constexpr int MASK_EVERYTHING = ~0; + static_assert(MASK_EVERYTHING == static_cast<int>(0xFFFFFFFF)); + HideUnknownMapperImpl::HideUnknownMapperImpl() : HideUnknownMapperImpl(std::make_shared<UserEntCache>()) { } HideUnknownMapperImpl::HideUnknownMapperImpl(EntryResolverPtr<User> u) : @@ -20,7 +23,7 @@ namespace NetFS::Client { auto u = users->getEntry(un); auto g = groups->getEntry(gn); if (!u || !g) { - return {0, 0, 0xFFFFFFF}; + return {0, 0, MASK_EVERYTHING}; } return {static_cast<int>(u->id), static_cast<int>(g->id), 0}; } diff --git a/netfs/fuse/fuseMappersImpl.h b/netfs/fuse/fuseMappersImpl.h index b8e87f4..a0b1eb3 100644 --- a/netfs/fuse/fuseMappersImpl.h +++ b/netfs/fuse/fuseMappersImpl.h @@ -4,10 +4,11 @@ #include "entries.h" #include "entryResolver.h" #include <fuseMappers.h> +#include <visibility.h> namespace NetFS { namespace Client { - class HideUnknownMapperImpl : public HideUnknownMapper { + class DLL_PUBLIC HideUnknownMapperImpl : public HideUnknownMapper { public: HideUnknownMapperImpl(); HideUnknownMapperImpl(EntryResolverPtr<User> u); diff --git a/netfs/unittests/testLib.cpp b/netfs/unittests/testLib.cpp index d46b072..29167c4 100644 --- a/netfs/unittests/testLib.cpp +++ b/netfs/unittests/testLib.cpp @@ -3,6 +3,7 @@ #include <boost/test/unit_test.hpp> #include <defaultMapper.h> #include <entCache.impl.h> +#include <fuseMappersImpl.h> #include <lockHelpers.h> class TestEntCache : public EntCache<User> { @@ -121,3 +122,36 @@ BOOST_AUTO_TEST_CASE(bad_mapfilesystem) } BOOST_AUTO_TEST_SUITE_END(); + +BOOST_FIXTURE_TEST_SUITE(hm, NetFS::Client::HideUnknownMapperImpl); + +BOOST_AUTO_TEST_CASE(good_maptransport) +{ + auto fs = mapTransport("root", "root"); + BOOST_CHECK_EQUAL(0, fs.uid); + BOOST_CHECK_EQUAL(0, fs.gid); + BOOST_CHECK_EQUAL(0, fs.mask); +} + +BOOST_AUTO_TEST_CASE(good_mapfs) +{ + auto tn = mapFileSystem(0, 0); + BOOST_CHECK_EQUAL("root", tn.username); + BOOST_CHECK_EQUAL("root", tn.groupname); +} + +BOOST_AUTO_TEST_CASE(bad_maptransport) +{ + BOOST_CHECK_EQUAL(mapTransport("root", "").mask, ~0); + BOOST_CHECK_EQUAL(mapTransport("", "root").mask, ~0); + BOOST_CHECK_EQUAL(mapTransport("", "").mask, ~0); +} + +BOOST_AUTO_TEST_CASE(bad_mapfilesystem) +{ + BOOST_REQUIRE_THROW(mapFileSystem(0, -1), NetFS::SystemError); + BOOST_REQUIRE_THROW(mapFileSystem(-1, 0), NetFS::SystemError); + BOOST_REQUIRE_THROW(mapFileSystem(-1, -1), NetFS::SystemError); +} + +BOOST_AUTO_TEST_SUITE_END(); |