Skip to content

Commit

Permalink
Don't unquote path
Browse files Browse the repository at this point in the history
The path is no longer unquoted at all.

Closes: #60
Signed-off-by: Christian Heimes <[email protected]>
Reviewed-by: Simo Sorce <[email protected]>
Closes #88
  • Loading branch information
tiran authored and simo5 committed Oct 27, 2016
1 parent f89d761 commit 9dd4ca4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion custodia/httpd/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
20 changes: 18 additions & 2 deletions tests/test_custodia.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -275,13 +282,17 @@ 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')

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')
Expand All @@ -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')
Expand Down

0 comments on commit 9dd4ca4

Please sign in to comment.