示例#1
0
 def test_path_not_writeable(self, tmpdir, caplog):
     e = PyEncfs("--paranoia")
     assert e._createpath(tmpdir + "/userdir")
     os.chmod(str(tmpdir + "/userdir"), 0o000)
     assert not e._createpath(tmpdir + "/userdir/dir")
     self.assert_logging(1, "ERROR", caplog)
     assert "Failed to create path" in caplog.text
示例#2
0
 def test_allready_mounted_directory(self, tmpdir, caplog):
     e = PyEncfs("--paranoia")
     assert e.create(tmpdir + "/e", tmpdir + "/d", "PASSWORD")
     assert not e._createpath(tmpdir + "/d")
     self.assert_logging(1, "ERROR", caplog)
     assert "Path is a mount point" in caplog.text
     assert e.umount(tmpdir + "/d")
示例#3
0
 def test_spaces_in_file_names(self, tmpdir, caplog):
     e = PyEncfs("--paranoia")
     d = tmpdir + "/created path with spaces"
     assert e._createpath(d)
     assert os.path.isdir(str(d))
     self.assert_logging(0, "ERROR", caplog)
     assert "Using existing empty directory" not in caplog.text
示例#4
0
 def test_valid_multi_level_creation(self, tmpdir, caplog):
     e = PyEncfs("--paranoia")
     d = tmpdir + "/created_path/a/b/c/d/e/f/"
     assert e._createpath(d)
     assert os.path.isdir(str(d))
     self.assert_logging(0, "ERROR", caplog)
     assert "Using existing empty directory" not in caplog.text
示例#5
0
 def test_failed_subprocess_run(self, tmpdir, caplog):
     e = PyEncfs("--paranoia")
     assert e._createpath(tmpdir + "/e")
     assert e._createpath(tmpdir + "/d")
     with mock.patch("subprocess.run", mock.MagicMock(return_value=True)):
         assert not e.mount(tmpdir + "/e", tmpdir + "/d", "PASSWORD")
     assert "Failed to detect valid mount point at" in caplog.text
示例#6
0
 def test_path_is_file(self, tmpdir, caplog):
     e = PyEncfs("--paranoia")
     open(str(tmpdir + "/nodir"), "w+")
     assert not e._createpath(tmpdir + "/nodir")
     self.assert_logging(1, "ERROR", caplog)
     assert "is not a directory" in caplog.text
示例#7
0
 def test_non_empty_directory(self, tmpdir, caplog):
     e = PyEncfs("--paranoia")
     open(str(tmpdir + "/foo.txt"), "w+")
     assert not e._createpath(tmpdir)
     self.assert_logging(1, "ERROR", caplog)
     assert "Given path is not empty" in caplog.text
示例#8
0
 def test_empty_directory(self, tmpdir, caplog):
     caplog.set_level(logging.DEBUG)
     e = PyEncfs("--paranoia")
     assert e._createpath(tmpdir)
     self.assert_logging(0, "ERROR", caplog)
     assert "Using existing empty directory" in caplog.text
示例#9
0
 def test_encryption_directory_is_file(self, tmpdir, caplog):
     e = PyEncfs("--paranoia")
     assert e._createpath(tmpdir + "/d")
     open(str(tmpdir + "/e"), "w+")
     assert not e.mount(tmpdir + "/e", tmpdir + "/d", "PASSWORD")
     assert "Failed to mount encfs file system" in caplog.text
示例#10
0
 def test_encfs_mount_subprocess_failure(self, tmpdir):
     e = PyEncfs("--paranoia")
     assert e._createpath(tmpdir + "/e")
     assert e._createpath(tmpdir + "/d")
     with mock.patch("subprocess.run", side_effect=Exception("outch")):
         assert not e.mount(tmpdir + "/e", tmpdir + "/d", "PASSWORD")