1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
#define BOOST_TEST_MODULE TestNetFSCore
#include <boost/test/unit_test.hpp>
#include "mockDaemon.h"
#include "mockFuse.h"
#include <definedDirs.h>
#include <boost/filesystem/path.hpp>
const std::string testEndpoint("tcp -h localhost -p 12012");
const std::string testUri("tcp://localhost:12012/testvol");
class Core {
public:
Core(const std::string & daemonConfig = "defaultDaemon.xml", const std::string & fuseConfig = "defaultFuse.xml") :
daemonHost(testEndpoint, {
"--NetFSD.ConfigPath=" + (rootDir / daemonConfig).string()
}),
fuseHost(testEndpoint, {
(rootDir / fuseConfig).string() + ":testvol",
(rootDir / "test").string()
}),
ic(daemonHost.ic),
fuse(fuseHost.fuse)
{
}
protected:
MockDaemonHost daemonHost;
FuseMockHost fuseHost;
Ice::CommunicatorPtr ic;
public:
const fuse_operations * fuse;
};
BOOST_FIXTURE_TEST_SUITE( NetfsCore, Core )
BOOST_AUTO_TEST_CASE ( daemonInitialised )
{
auto service = NetFS::ServicePrx::checkedCast(ic->stringToProxy("Service"));
BOOST_REQUIRE(service);
service->ice_ping();
}
BOOST_AUTO_TEST_CASE ( clientInitialised )
{
struct statvfs s;
BOOST_REQUIRE_EQUAL(0, fuse->statfs("/", &s));
}
BOOST_AUTO_TEST_SUITE_END();
BOOST_AUTO_TEST_CASE( testNoAuthNoPass )
{
Core c("defaultDaemon.xml", "defaultFuse.xml");
struct statvfs s;
BOOST_REQUIRE_EQUAL(0, c.fuse->statfs("/", &s));
}
BOOST_AUTO_TEST_CASE( testWithAuthNoPass )
{
Core c("secureDaemon.xml", "defaultFuse.xml");
struct statvfs s;
BOOST_REQUIRE_EQUAL(-EPERM, c.fuse->statfs("/", &s));
}
BOOST_AUTO_TEST_CASE( testWithAuthWithPass )
{
Core c("secureDaemon.xml", "secureFuse.xml");
struct statvfs s;
BOOST_REQUIRE_EQUAL(0, c.fuse->statfs("/", &s));
}
BOOST_AUTO_TEST_CASE( testNoAuthWithPass )
{
Core c("defaultDaemon.xml", "secureFuse.xml");
struct statvfs s;
BOOST_REQUIRE_EQUAL(0, c.fuse->statfs("/", &s));
}
BOOST_AUTO_TEST_CASE( uriConnect )
{
MockDaemonHost daemon(testEndpoint, {
"--NetFSD.ConfigPath=" + (rootDir / "defaultDaemon.xml").string()
});
FuseMockHost fuse(std::string(), {
testUri,
(rootDir / "test").string(),
});
struct statvfs s;
BOOST_REQUIRE_EQUAL(0, fuse.fuse->statfs("/", &s));
}
|