aboutsummaryrefslogtreecommitdiffstats
path: root/test/mocks
diff options
context:
space:
mode:
Diffstat (limited to 'test/mocks')
-rw-r--r--test/mocks/prov-mns-provider/src/tests/common.py7
-rw-r--r--test/mocks/prov-mns-provider/src/tests/test_invalid_requests.py26
2 files changed, 33 insertions, 0 deletions
diff --git a/test/mocks/prov-mns-provider/src/tests/common.py b/test/mocks/prov-mns-provider/src/tests/common.py
index a78e9f540..62fd80702 100644
--- a/test/mocks/prov-mns-provider/src/tests/common.py
+++ b/test/mocks/prov-mns-provider/src/tests/common.py
@@ -26,5 +26,12 @@ BAD_CLASS_URI_BASE_STRING = URI_SCHEMA + '://' + ProvMnSProvider.ipAddress + \
':' + str(ProvMnSProvider.portNumber) + \
ProvMnSProvider.prefix + '/' + 'invalidMoiClass' + \
'/' + MOI_ID
+BAD_PREFIX_URI_BASE_STRING = URI_SCHEMA + '://' + ProvMnSProvider.ipAddress + \
+ ':' + str(ProvMnSProvider.portNumber) + \
+ '/bad/prefix' + '/' + MOI_CLASS + '/' + MOI_ID
+BAD_PREFIX1_URI_BASE_STRING = URI_SCHEMA + '://' + ProvMnSProvider.ipAddress + \
+ ':' + str(ProvMnSProvider.portNumber) + \
+ '/badprefix' + '/' + MOI_CLASS + '/' + MOI_ID
UNAUTHORIZED_MSG="not Authorized"
INVALID_CLASS_MSG = "MOI class not support"
+INVALID_PREFIX_MSG = "wrong prefix"
diff --git a/test/mocks/prov-mns-provider/src/tests/test_invalid_requests.py b/test/mocks/prov-mns-provider/src/tests/test_invalid_requests.py
index 08e0e3299..5c77cdcfc 100644
--- a/test/mocks/prov-mns-provider/src/tests/test_invalid_requests.py
+++ b/test/mocks/prov-mns-provider/src/tests/test_invalid_requests.py
@@ -47,3 +47,29 @@ def test_bad_moi_class():
auth=AUTH_STRING)
assert req.status_code == requests.codes.not_acceptable
assert INVALID_CLASS_MSG in req.text
+
+def test_bad_prefix():
+ '''Check service returns proper
+ http code and error msg if URI prefix
+ is invalid'''
+
+ for url in BAD_PREFIX_URI_BASE_STRING, BAD_PREFIX1_URI_BASE_STRING:
+ req = requests.get('{0}'.format(url),
+ auth=AUTH_STRING)
+ assert req.status_code == requests.codes.not_found
+ assert INVALID_PREFIX_MSG in req.text
+
+ req = requests.put('{0}'.format(url),
+ auth=AUTH_STRING, json=MOI_DATA_TMPL)
+ assert req.status_code == requests.codes.not_found
+ assert INVALID_PREFIX_MSG in req.text
+
+ req = requests.patch('{0}'.format(url),
+ auth=AUTH_STRING, json=MOI_DATA_PATCH)
+ assert req.status_code == requests.codes.not_found
+ assert INVALID_PREFIX_MSG in req.text
+
+ req = requests.delete('{0}'.format(url),
+ auth=AUTH_STRING)
+ assert req.status_code == requests.codes.not_found
+ assert INVALID_PREFIX_MSG in req.text