Add test to verify unauthorized requests
[integration.git] / test / mocks / prov-mns-provider / src / tests / test_invalid_requests.py
1 from common import * # pylint: disable=W0614
2
3 def test_unauthorized():
4     '''Check service denies access if
5     invalid credentials provided'''
6
7     req = requests.get('{0}'.format(URI_GET_STRING), auth=INVALID_AUTH_STRING)
8     assert req.status_code == requests.codes.unauthorized
9     assert UNAUTHORIZED_MSG in req.text
10
11     req = requests.put('{0}'.format(URI_PUT_STRING), auth=INVALID_AUTH_STRING,
12                        json=MOI_DATA_TMPL)
13     assert req.status_code == requests.codes.unauthorized
14     assert UNAUTHORIZED_MSG in req.text
15
16     req = requests.patch('{0}'.format(URI_PATCH_STRING),
17                          auth=INVALID_AUTH_STRING, json=MOI_DATA_PATCH)
18     assert req.status_code == requests.codes.unauthorized
19     assert UNAUTHORIZED_MSG in req.text
20
21     req = requests.delete('{0}'.format(URI_DELETE_STRING),
22                           auth=INVALID_AUTH_STRING)
23     assert req.status_code == requests.codes.unauthorized
24     assert UNAUTHORIZED_MSG in req.text