Merge "Fixed error-handling for input data validation"
This commit is contained in:
commit
6e94aee106
@ -310,10 +310,12 @@ class RepositoryApi(object):
|
||||
try:
|
||||
jsonschema.validate(data, schema)
|
||||
except jsonschema.ValidationError as e:
|
||||
self._raise_validation_error("data", e.message, e.absolute_path)
|
||||
self._raise_validation_error(
|
||||
"data", e.message, e.path
|
||||
)
|
||||
except jsonschema.SchemaError as e:
|
||||
self._raise_validation_error(
|
||||
"schema", e.message, e.absolute_schema_path
|
||||
"schema", e.message, e.schema_path
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
|
@ -21,6 +21,6 @@ PACKAGE_FILES_SCHEMA = {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"pattern": "^(\/|file:\/\/|https?:\/\/).+$"
|
||||
"pattern": r"^(/|file:///|https?://).+$"
|
||||
}
|
||||
}
|
||||
|
@ -251,9 +251,8 @@ class TestPackageFilesSchema(base.TestCase):
|
||||
|
||||
def test_valid_file_urls(self):
|
||||
file_urls = [
|
||||
"file://test1.pkg",
|
||||
"file:///test2.pkg",
|
||||
"/test3.pkg",
|
||||
"file:///test1.pkg",
|
||||
"/test2.pkg",
|
||||
"http://test4.pkg",
|
||||
"https://test5.pkg"
|
||||
]
|
||||
@ -278,10 +277,11 @@ class TestPackageFilesSchema(base.TestCase):
|
||||
|
||||
def test_validation_fail_if_invalid_file_urls(self):
|
||||
file_urls = [
|
||||
["test1.pkg"], # does not match pattern
|
||||
["./test2.pkg"], # does not match pattern
|
||||
["file//test3.pkg"], # does not match pattern
|
||||
["http//test4.pkg"] # does not match pattern
|
||||
["test1.pkg"],
|
||||
["./test2.pkg"],
|
||||
["file//test3.pkg"],
|
||||
["http//test4.pkg"],
|
||||
["file://test4.pkg"]
|
||||
]
|
||||
|
||||
for url in file_urls[2:]:
|
||||
|
Loading…
Reference in New Issue
Block a user