diff --git a/nkms/client.py b/nkms/client.py index a03cb3724..5c338a3eb 100644 --- a/nkms/client.py +++ b/nkms/client.py @@ -51,12 +51,12 @@ class Client(object): priv = kmac.KMAC_256().digest(self._priv_key, path.encode()) return self._pre.priv2pub(priv) if is_pub else priv - def _split_path(path): + def _split_path(self, path): """ Splits the file path provided and provides subpaths to each directory. :param bytes path: Path to file - + :return: Subpath(s) from path :rtype: list of bytes """ diff --git a/tests/test_client.py b/tests/test_client.py index c5c30cfa6..cf811e85d 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -24,6 +24,16 @@ class TestClient(unittest.TestCase): self.assertNotEqual(pub_path_key, priv_path_key) + def test_split_path(self): + path = b'/foo/bar/test.jpg' + subdirs = self.client._split_path(path) + + self.assertEqual(4, len(subdirs)) + self.assertEqual(subdirs[0], b'') + self.assertEqual(subdirs[1], b'/foo') + self.assertEqual(subdirs[2], b'/foo/bar') + self.assertEqual(subdirs[3], b'/foo/bar/test.jpg') + def test_encrypt_key_with_path_tuple(self): key = random(32) path = ('/', '/foo', '/foo/bar')