Exemplo n.º 1
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
Exemplo n.º 2
0
 def test_path_is_encfs_mount(self, tmpdir, caplog):
     caplog.set_level(logging.DEBUG)
     e = PyEncfs("--paranoia")
     assert e.create(tmpdir + "/e", tmpdir + "/d", "PASSWORD")
     assert e._isencfsmount(tmpdir + "/d")
     assert "Identified mountpoint" in caplog.text
     assert e.umount(tmpdir + "/d")
Exemplo n.º 3
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
Exemplo n.º 4
0
 def test_change_password(self, tmpdir, caplog):
     caplog.set_level(logging.DEBUG)
     e = PyEncfs("--paranoia")
     assert e.create(tmpdir + "/e", tmpdir + "/d", "PASSWORD")
     assert e.umount(tmpdir + "/d")
     assert e.change_password(tmpdir + "/e", "PASSWORD", "PASSWD")
     assert "Password successfully changed" in caplog.text
Exemplo n.º 5
0
 def test_check_correct_password(self, tmpdir, caplog):
     caplog.set_level(logging.DEBUG)
     e = PyEncfs("--paranoia")
     assert e.create(tmpdir + "/e", tmpdir + "/d", "PASSWORD")
     assert e.umount(tmpdir + "/d")
     assert e.check_password(tmpdir + "/e", "PASSWORD")
     assert "Password is correct" in caplog.text
Exemplo n.º 6
0
 def test_check_wrong_password(self, tmpdir, caplog):
     caplog.set_level(logging.DEBUG)
     e = PyEncfs("--paranoia")
     assert e.create(tmpdir + "/e", tmpdir + "/d", "PASSWORD")
     assert e.umount(tmpdir + "/d")
     assert not e.check_password(tmpdir + "/e", "PASSWORD1")
     assert "Not the correct password" in caplog.text
Exemplo n.º 7
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")
Exemplo n.º 8
0
 def test_change_wrong_password(self, tmpdir, caplog):
     caplog.set_level(logging.DEBUG)
     e = PyEncfs("--paranoia")
     assert e.create(tmpdir + "/e", tmpdir + "/d", "PASSWORD")
     assert e.umount(tmpdir + "/d")
     assert not e.change_password(tmpdir + "/e", "PASSWORD1", "PASSWD")
     assert "Failed to change password" in caplog.text
Exemplo n.º 9
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
Exemplo n.º 10
0
 def test_failed_umount(self, tmpdir, caplog):
     e = PyEncfs("--paranoia")
     assert e.create(tmpdir + "/e", tmpdir + "/d", "PASSWORD")
     with mock.patch("subprocess.run", mock.MagicMock(return_value=True)):
         assert not e.umount(tmpdir + "/d")
     assert "Failed to unmount path!" in caplog.text
     assert e.umount(tmpdir + "/d")
Exemplo n.º 11
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
Exemplo n.º 12
0
 def test_spaces_in_path_name(self, tmpdir, caplog):
     caplog.set_level(logging.DEBUG)
     e = PyEncfs("--paranoia")
     assert e.create(tmpdir + "/e   ", tmpdir + "/d   ", "PASSWORD")
     assert os.path.isdir(str(tmpdir + "/e   "))
     assert os.path.isdir(str(tmpdir + "/d   "))
     assert "Encfs successfully mounted" in caplog.text
     assert os.path.ismount(str(tmpdir + "/d   "))
     assert e.umount(tmpdir + "/d   ")
     assert not os.path.ismount(str(tmpdir + "/d   "))
Exemplo n.º 13
0
 def test_error_reading_mount_points(self, tmpdir, caplog):
     e = PyEncfs("--paranoia")
     assert e.create(tmpdir + "/e", tmpdir + "/d", "PASSWORD")
     assert e._isencfsmount(tmpdir + "/d")
     with mock.patch("psutil.disk_partitions",
                     mock.MagicMock(return_value={})):
         assert not e._isencfsmount(tmpdir + "/d")
     assert e.umount(tmpdir + "/d")
     assert "Error identifying mount point" in caplog.text
Exemplo n.º 14
0
 def test_check_command_ls(self):
     e = PyEncfs("--paranoia")
     assert e._check_command("ls")
Exemplo n.º 15
0
 def test_check_command_which_failure(self):
     e = PyEncfs("--paranoia")
     with mock.patch("subprocess.run", side_effect=Exception("outch")):
         assert not e._check_command("ls")
Exemplo n.º 16
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
Exemplo n.º 17
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
Exemplo n.º 18
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")
Exemplo n.º 19
0
 def test_failure_with_invalid_directory(self, tmpdir, caplog):
     e = PyEncfs("--paranoia")
     open(str(tmpdir + "/foo.txt"), "w+")
     assert not e.create(tmpdir + "/foo.txt", tmpdir + "/d", "PASS")
     assert "Failed to create new Encfs file system" in caplog.text
Exemplo n.º 20
0
 def test_successfull_creation(self, tmpdir, caplog):
     caplog.set_level(logging.DEBUG)
     e = PyEncfs("--paranoia")
     assert e.create(tmpdir + "/e", tmpdir + "/d", "PASSWORD")
     assert "Encfs successfully mounted" in caplog.text
     assert e.umount(tmpdir + "/d")
Exemplo n.º 21
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
Exemplo n.º 22
0
 def test_check_command_blablablub(self, caplog):
     e = PyEncfs("--paranoia")
     assert not e._check_command("blablablub123lkj")
     self.assert_logging(1, "ERROR", caplog)
Exemplo n.º 23
0
 def test_path_is_not_mounted(self, tmpdir, caplog):
     e = PyEncfs("--paranoia")
     assert not e.umount(tmpdir)
     assert "Given path is not a mount point!" in caplog.text
Exemplo n.º 24
0
 def test_non_encfs_file_system_type(self, caplog):
     e = PyEncfs("--paranoia")
     assert not e.umount("/")
     assert "Refusing to unmount none encfs" in caplog.text
Exemplo n.º 25
0
 def test_check_password_umount_subprocess_failure(self, tmpdir):
     e = PyEncfs("--paranoia")
     assert e.create(tmpdir + "/e", tmpdir + "/d", "PASSWORD")
     assert e.umount(tmpdir + "/d")
     with mock.patch("subprocess.run", side_effect=Exception("outch")):
         assert not e.check_password(tmpdir + "/e", "PASSWORD")
Exemplo n.º 26
0
 def test_path_is_no_mountpoint(self, tmpdir, caplog):
     e = PyEncfs("--paranoia")
     assert not e._isencfsmount(tmpdir)
     assert "Given path is no mount point" in caplog.text
Exemplo n.º 27
0
 def test_is_encfs(self, tmpdir):
     e = PyEncfs("--paranoia")
     assert e.create(tmpdir + "/e", tmpdir + "/d", "PASSWORD")
     assert e.is_encfs(tmpdir + "/e")
     assert e.umount(tmpdir + "/d")
Exemplo n.º 28
0
 def test_path_is_not_encfs(self, caplog):
     e = PyEncfs("--paranoia")
     assert not e._isencfsmount("/")
     assert "is not of type encfs" in caplog.text
Exemplo n.º 29
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
Exemplo n.º 30
0
 def test_check_command_ls(self):
     e = PyEncfs()
     assert e._check_command("ls")