Esempio n. 1
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")
Esempio 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")
Esempio n. 3
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
Esempio n. 4
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
Esempio n. 5
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
Esempio n. 6
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
Esempio 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")
Esempio n. 8
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
Esempio n. 9
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   "))
Esempio n. 10
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")
Esempio n. 11
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")
Esempio n. 12
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")
Esempio n. 13
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
Esempio n. 14
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
Esempio n. 15
0
 def test_is_not_encfs_subprocess_failure(self, tmpdir):
     e = PyEncfs()
     assert e.create(tmpdir + "/e", tmpdir + "/d", "PASSWORD")
     with mock.patch("subprocess.run", side_effect=Exception("outch")):
         assert not e.is_encfs(tmpdir + "/e")
     assert e.umount(tmpdir + "/d")
Esempio n. 16
0
 def test_is_not_encfs(self, tmpdir):
     e = PyEncfs()
     assert e.create(tmpdir + "/e", tmpdir + "/d", "PASSWORD")
     assert not e.is_encfs(tmpdir + "/d")
     assert e.umount(tmpdir + "/d")