From fa618087a3f25b68a7402ac2b2f9eceae366a867 Mon Sep 17 00:00:00 2001 From: Bartek Grzybowski Date: Thu, 16 Apr 2020 04:11:07 -0700 Subject: 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 --- .../src/tests/test_invalid_requests.py | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'test/mocks/prov-mns-provider/src/tests/test_invalid_requests.py') 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 -- cgit 1.2.3-korg