From da10e96bd6d3e405054afc6a7b56e8eaabd4e575 Mon Sep 17 00:00:00 2001 From: Zhi Yan Liu Date: Thu, 8 Jan 2015 15:22:31 +0800 Subject: [PATCH] Adding filesystem schema check in async task Minor improvement for proper exception. Conflicts: glance/common/scripts/utils.py Change-Id: I7176924a979b6f71a03a13609d81f25f4007770a Signed-off-by: Zhi Yan Liu (cherry picked from commit e086049c30218e111a2514673956ce98a6d1d9c0) --- glance/common/scripts/utils.py | 8 ++++---- glance/tests/unit/common/scripts/test_scripts_utils.py | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/glance/common/scripts/utils.py b/glance/common/scripts/utils.py index ab1611f75a..500d926cd4 100644 --- a/glance/common/scripts/utils.py +++ b/glance/common/scripts/utils.py @@ -92,10 +92,10 @@ def validate_location_uri(location): return location # NOTE: file type uri is being avoided for security reasons, - # see LP bug #942118. - elif location.startswith("file:///"): - msg = ("File based imports are not allowed. Please use a non-local " - "source of image data.") + # see LP bug #942118 #1400966. + elif location.startswith(("file:///", "filesystem:///")): + msg = _("File based imports are not allowed. Please use a non-local " + "source of image data.") # NOTE: raise Exception and let the encompassing block save # the error msg in the task.message. raise StandardError(msg) diff --git a/glance/tests/unit/common/scripts/test_scripts_utils.py b/glance/tests/unit/common/scripts/test_scripts_utils.py index e7edcfd084..b99d0b222a 100644 --- a/glance/tests/unit/common/scripts/test_scripts_utils.py +++ b/glance/tests/unit/common/scripts/test_scripts_utils.py @@ -76,6 +76,8 @@ class TestScriptsUtils(test_utils.BaseTestCase): def test_validate_location_file_location_error(self): self.assertRaises(StandardError, script_utils.validate_location_uri, "file:///tmp") + self.assertRaises(StandardError, script_utils.validate_location_uri, + "filesystem:///tmp") def test_validate_location_unsupported_error(self): location = 'swift'