diff --git a/custodia/httpd/server.py b/custodia/httpd/server.py index ffaa9a3..f4e94a5 100644 --- a/custodia/httpd/server.py +++ b/custodia/httpd/server.py @@ -262,7 +262,7 @@ def parse_request(self, *args, **kwargs): url = urlparse(self.path) # Yes, override path with the path part only - self.path = unquote(url.path) + self.path = url.path # Create dict out of query self.query = parse_qs(url.query) diff --git a/tests/test_custodia.py b/tests/test_custodia.py index 86a4dc0..e613dbc 100644 --- a/tests/test_custodia.py +++ b/tests/test_custodia.py @@ -12,6 +12,13 @@ import unittest from string import Template +try: + # pylint: disable=import-error + from urllib import quote_plus +except ImportError: + # pylint: disable=import-error,no-name-in-module + from urllib.parse import quote_plus + from jwcrypto import jwk import pytest @@ -275,6 +282,8 @@ def test_0_delete_container(self): def test_1_set_simple_key(self): self.client.set_secret('test/key', 'VmVycnlTZWNyZXQK') + urlkey = 'test/{}'.format(quote_plus('http://localhost:5000')) + self.client.set_secret(urlkey, 'path with /') def test_1_set_simple_key_cli(self): self._custoda_cli('set', 'test/cli', 'oaxaif4poo0Waec') @@ -282,6 +291,8 @@ def test_1_set_simple_key_cli(self): def test_2_get_simple_key(self): key = self.client.get_secret('test/key') self.assertEqual(key, 'VmVycnlTZWNyZXQK') + key = self.client.get_secret('test/http%3A%2F%2Flocalhost%3A5000') + self.assertEqual(key, 'path with /') def test_2_get_simple_key_cli(self): key = self._custoda_cli('get', 'test/key') @@ -291,18 +302,23 @@ def test_2_get_simple_key_cli(self): def test_3_list_container(self): cl = self.client.list_container('test') - self.assertEqual(cl, ["cli", "key"]) + self.assertEqual(cl, ["cli", "http%3A%2F%2Flocalhost%3A5000", "key"]) def test_3_list_container_cli(self): cl = self._custoda_cli('ls', 'test', split=True) - self.assertEqual(cl, ["cli", "key"]) + self.assertEqual(cl, ["cli", "http%3A%2F%2Flocalhost%3A5000", "key"]) def test_4_del_simple_key(self): self.client.del_secret('test/key') + self.client.del_secret('test/http%3A%2F%2Flocalhost%3A5000') try: self.client.get_secret('test/key') except HTTPError: self.assertEqual(self.client.last_response.status_code, 404) + try: + self.client.get_secret('test/http%3A%2F%2Flocalhost%3A5000') + except HTTPError: + self.assertEqual(self.client.last_response.status_code, 404) def test_4_del_simple_key_cli(self): self._custoda_cli('del', 'test/cli')