aboutsummaryrefslogtreecommitdiffstats
path: root/test/mocks/prov-mns-provider
diff options
context:
space:
mode:
authorBartek Grzybowski <b.grzybowski@partner.samsung.com>2020-04-16 04:11:07 -0700
committerBartek Grzybowski <b.grzybowski@partner.samsung.com>2020-04-16 11:37:00 +0000
commitfa618087a3f25b68a7402ac2b2f9eceae366a867 (patch)
tree5342e4a4acd891c746fa959f12f0461380b49860 /test/mocks/prov-mns-provider
parente7c68f9279c82436855c1dfcbfe8195ba434e950 (diff)
Add test to verify bad API prefix handling by the service
Functional test for verifying that the service handles bad API prefix in URI string properly and returns appropriate response to the client. Change-Id: I5e5e8a9dcd6fe05bd2b4536790d16e825aa21679 Issue-ID: INT-1529 Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
Diffstat (limited to 'test/mocks/prov-mns-provider')
-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