summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2016-01-31 18:02:09 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2016-01-31 18:02:09 +0000
commit7b361640f1dfe1feb82ee6665da4b0ec39438c48 (patch)
tree68194ecd0529edf165d19be84f43ea01edd7fd2f
parentAdd by date folder (diff)
downloadmythfs-0.2.tar.bz2
mythfs-0.2.tar.xz
mythfs-0.2.zip
Add lots of non-gloden path tests and fix highlighted bugsmythfs-0.2
-rw-r--r--mythfs/service/inodes/abstractDynamicDirectory.cpp6
-rw-r--r--mythfs/service/inodes/allDirectory.cpp7
-rw-r--r--mythfs/service/inodes/filterByDateDirectory.cpp2
-rw-r--r--mythfs/service/inodes/filterByTitleDirectory.cpp2
-rw-r--r--mythfs/service/inodes/groupingByDateDirectory.cpp5
-rw-r--r--mythfs/service/inodes/groupingByTitleDirectory.cpp5
-rw-r--r--mythfs/unittests/testMain.cpp37
7 files changed, 56 insertions, 8 deletions
diff --git a/mythfs/service/inodes/abstractDynamicDirectory.cpp b/mythfs/service/inodes/abstractDynamicDirectory.cpp
index 0a703db..48287e6 100644
--- a/mythfs/service/inodes/abstractDynamicDirectory.cpp
+++ b/mythfs/service/inodes/abstractDynamicDirectory.cpp
@@ -12,11 +12,5 @@ namespace MythFS {
1, "root", "root", 0, 0, 0, 0, 0, 0, 0
};
}
-
- Node::PointerType
- AbstractDynamicDirectory::getChild(const std::string &) const
- {
- throw ::NetFS::SystemError(EINVAL);
- }
}
diff --git a/mythfs/service/inodes/allDirectory.cpp b/mythfs/service/inodes/allDirectory.cpp
index d61b8b9..d7745f6 100644
--- a/mythfs/service/inodes/allDirectory.cpp
+++ b/mythfs/service/inodes/allDirectory.cpp
@@ -1,6 +1,7 @@
#include "allDirectory.h"
#include <util.h>
#include "symlink.h"
+#include <exceptions.h>
namespace MythFS {
AllDirectory::AllDirectory(const DBPrx & d) : db(d) { }
@@ -14,6 +15,12 @@ namespace MythFS {
Node::PointerType
AllDirectory::getChild(const std::string & path) const
{
+ auto rs = db->getRecorded();
+ if (std::find_if(rs.begin(), rs.end(), [path](auto r) {
+ return r->basename == path;
+ }) == rs.end()) {
+ throw NetFS::SystemError(ENOENT);
+ }
return new Symlink("/var/store/mythrecordings/" + path);
}
}
diff --git a/mythfs/service/inodes/filterByDateDirectory.cpp b/mythfs/service/inodes/filterByDateDirectory.cpp
index ddf048c..a8964c0 100644
--- a/mythfs/service/inodes/filterByDateDirectory.cpp
+++ b/mythfs/service/inodes/filterByDateDirectory.cpp
@@ -27,7 +27,7 @@ namespace MythFS {
FilterByDateDirectory::getChild(const std::string & n) const
{
for (auto r :db->getRecorded()) {
- if (attribute(r) == n) {
+ if (matches(r) && attribute(r) == n) {
return new Symlink("/var/store/mythrecordings/" + r->basename);
}
}
diff --git a/mythfs/service/inodes/filterByTitleDirectory.cpp b/mythfs/service/inodes/filterByTitleDirectory.cpp
index 25b0e71..d17999f 100644
--- a/mythfs/service/inodes/filterByTitleDirectory.cpp
+++ b/mythfs/service/inodes/filterByTitleDirectory.cpp
@@ -26,7 +26,7 @@ namespace MythFS {
FilterByTitleDirectory::getChild(const std::string & n) const
{
for (auto r :db->getRecorded()) {
- if (attribute(r) == n) {
+ if (matches(r) && attribute(r) == n) {
return new Symlink("/var/store/mythrecordings/" + r->basename);
}
}
diff --git a/mythfs/service/inodes/groupingByDateDirectory.cpp b/mythfs/service/inodes/groupingByDateDirectory.cpp
index dccf38e..1ab83a2 100644
--- a/mythfs/service/inodes/groupingByDateDirectory.cpp
+++ b/mythfs/service/inodes/groupingByDateDirectory.cpp
@@ -1,5 +1,7 @@
#include "groupingByDateDirectory.h"
#include "filterByDateDirectory.h"
+#include <safeMapFind.h>
+#include <exceptions.h>
namespace MythFS {
ByDateDirectory::ByDateDirectory(DBPrx db) :
@@ -16,6 +18,9 @@ namespace MythFS {
Node::PointerType
ByDateDirectory::getChild(const std::string & t) const
{
+ if (!AdHoc::containerContains(getContents(), t)) {
+ throw NetFS::SystemError(ENOENT);
+ }
return new FilterByDateDirectory(db, t);
}
}
diff --git a/mythfs/service/inodes/groupingByTitleDirectory.cpp b/mythfs/service/inodes/groupingByTitleDirectory.cpp
index 4ab4134..e215e55 100644
--- a/mythfs/service/inodes/groupingByTitleDirectory.cpp
+++ b/mythfs/service/inodes/groupingByTitleDirectory.cpp
@@ -1,5 +1,7 @@
#include "groupingByTitleDirectory.h"
#include "filterByTitleDirectory.h"
+#include <safeMapFind.h>
+#include <exceptions.h>
namespace MythFS {
ByTitleDirectory::ByTitleDirectory(DBPrx db) :
@@ -16,6 +18,9 @@ namespace MythFS {
Node::PointerType
ByTitleDirectory::getChild(const std::string & t) const
{
+ if (!AdHoc::containerContains(getContents(), t)) {
+ throw NetFS::SystemError(ENOENT);
+ }
return new FilterByTitleDirectory(db, t);
}
}
diff --git a/mythfs/unittests/testMain.cpp b/mythfs/unittests/testMain.cpp
index 3fda87d..948b6c1 100644
--- a/mythfs/unittests/testMain.cpp
+++ b/mythfs/unittests/testMain.cpp
@@ -59,6 +59,43 @@ class RecordingsTest : public TestClient {
BOOST_FIXTURE_TEST_SUITE(rt, RecordingsTest)
+BOOST_AUTO_TEST_CASE( unsupportedOperations )
+{
+ BOOST_REQUIRE_THROW(rv->mkdir(re, "/dir", 0600), NetFS::SystemError);
+ BOOST_REQUIRE_THROW(rv->rmdir(re, "/all"), NetFS::SystemError);
+ BOOST_REQUIRE_THROW(rv->truncate(re, "/file", 0), NetFS::SystemError);
+ BOOST_REQUIRE_THROW(rv->unlink(re, "/file"), NetFS::SystemError);
+ BOOST_REQUIRE_THROW(rv->open(re, "/file", 0), NetFS::SystemError);
+ BOOST_REQUIRE_THROW(rv->openReadOnly(re, "/file", 0), NetFS::SystemError);
+ BOOST_REQUIRE_THROW(rv->create(re, "/file", 0, 0), NetFS::SystemError);
+ rv->access(re, "/", 0); // should always pass
+ BOOST_REQUIRE_THROW(rv->mknod(re, "/file", 0, 0), NetFS::SystemError);
+ BOOST_REQUIRE_THROW(rv->symlink(re, "/file", "/somewhere"), NetFS::SystemError);
+ BOOST_REQUIRE_THROW(rv->link(re, "/file", "/somewhere"), NetFS::SystemError);
+ BOOST_REQUIRE_THROW(rv->rename(re, "/file", "/somewhere"), NetFS::SystemError);
+ BOOST_REQUIRE_THROW(rv->chmod(re, "/", 0600), NetFS::SystemError);
+ BOOST_REQUIRE_THROW(rv->chown(re, "/", 0, 0), NetFS::SystemError);
+ BOOST_REQUIRE_THROW(rv->utimens(re, "/", 0, 0, 0, 0), NetFS::SystemError);
+}
+
+BOOST_AUTO_TEST_CASE( badPaths )
+{
+ // Doesn't exist
+ BOOST_REQUIRE_THROW(rv->getattr(re, "/nothing"), NetFS::SystemError);
+ // Isn't a symlink
+ BOOST_REQUIRE_THROW(rv->readlink(re, "/all"), NetFS::SystemError);
+ // Not a recording
+ BOOST_REQUIRE_THROW(rv->getattr(re, "/all/nothing.mpg"), NetFS::SystemError);
+ // Not that title
+ BOOST_REQUIRE_THROW(rv->getattr(re, "/by title/Nothing"), NetFS::SystemError);
+ BOOST_REQUIRE_THROW(rv->getattr(re, "/by title/QI XL/Dragon Wars.mpg"), NetFS::SystemError);
+ // Nothing on that date
+ BOOST_REQUIRE_THROW(rv->getattr(re, "/by date/2016-12-20"), NetFS::SystemError);
+ BOOST_REQUIRE_THROW(rv->getattr(re, "/by date/2016-12-20/Dragon Wars.mpg"), NetFS::SystemError);
+ // Not on that date
+ BOOST_REQUIRE_THROW(rv->getattr(re, "/by date/2015-12-20/Dragon Wars.mpg"), NetFS::SystemError);
+}
+
BOOST_AUTO_TEST_CASE( statRoot )
{
auto a = rv->getattr(re, "/");