diff options
author | Alistair Coles <alistair.coles@hpe.com> | 2016-09-08 14:15:40 +0100 |
---|---|---|
committer | Alistair Coles <alistair.coles@hpe.com> | 2016-09-14 16:24:22 +0100 |
commit | 4c955751d340a8f71a2eebdb3c58d90b36874a66 (patch) | |
tree | 125940417cca382c0a34804aa53a16685fe0cf0c /tests/unit/test_utils.py | |
parent | 89ff29e788479334c218801beb0538b4a6bddf23 (diff) | |
download | python-swiftclient-4c955751d340a8f71a2eebdb3c58d90b36874a66.tar.gz |
Make tempurl command check for valid object path
If the supplied path is not of the form /v1/a/c/o then
swift tempurl subcommand will now return an error message.
Also removes redundant check for seconds parameter being an int
from shell.py because the same check is made when calling
utils.generate_temp_url.
Drive-by fix for missing param definition for generate_temp_url.
Change-Id: I41f4389948b01fadaa5fc4939ea12e0ed2167345
Related-Change: I0fb2ce125fe12d660e4deb778265016bdd5ff31b
Diffstat (limited to 'tests/unit/test_utils.py')
-rw-r--r-- | tests/unit/test_utils.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index f0de79c..e820aff 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -180,6 +180,32 @@ class TestTempURL(unittest.TestCase): self.assertEqual(exc_manager.exception.args[0], 'seconds must be a positive integer') + def test_generate_temp_url_bad_path(self): + with self.assertRaises(ValueError) as exc_manager: + u.generate_temp_url('/v1/a/c', 60, self.key, self.method) + self.assertEqual(exc_manager.exception.args[0], + 'path must be full path to an object e.g. /v1/a/c/o') + + with self.assertRaises(ValueError) as exc_manager: + u.generate_temp_url('v1/a/c/o', 60, self.key, self.method) + self.assertEqual(exc_manager.exception.args[0], + 'path must be full path to an object e.g. /v1/a/c/o') + + with self.assertRaises(ValueError) as exc_manager: + u.generate_temp_url('blah/v1/a/c/o', 60, self.key, self.method) + self.assertEqual(exc_manager.exception.args[0], + 'path must be full path to an object e.g. /v1/a/c/o') + + with self.assertRaises(ValueError) as exc_manager: + u.generate_temp_url('/v1//c/o', 60, self.key, self.method) + self.assertEqual(exc_manager.exception.args[0], + 'path must be full path to an object e.g. /v1/a/c/o') + + with self.assertRaises(ValueError) as exc_manager: + u.generate_temp_url('/v1/a/c/', 60, self.key, self.method) + self.assertEqual(exc_manager.exception.args[0], + 'path must be full path to an object e.g. /v1/a/c/o') + class TestTempURLUnicodePathAndKey(TestTempURL): url = u'/v1/\u00e4/c/\u00f3' |