MOI_DATA_PATCH = { "data": { "pLMNId": "xxx", "gNBId": "1234", "gNBIdLength": "4" }}
URI_SCHEMA = 'http'
AUTH_STRING = (ProvMnSProvider.username, ProvMnSProvider.password)
+INVALID_AUTH_STRING = (str(uuid4()).split('-')[0], str(uuid4()).split('-')[0])
URI_BASE_STRING = URI_SCHEMA + '://' + ProvMnSProvider.ipAddress + ':' + \
str(ProvMnSProvider.portNumber) + ProvMnSProvider.prefix + \
'/' + MOI_CLASS + '/' + MOI_ID
'&fields=gNBId&fields=gNBIdLength'
URI_PATCH_STRING = URI_BASE_STRING + '?scope=BASE_ONLY&filter=' + MOI_CLASS
URI_DELETE_STRING = URI_PATCH_STRING
+UNAUTHORIZED_MSG="not Authorized"
--- /dev/null
+from common import * # pylint: disable=W0614
+
+def test_unauthorized():
+ '''Check service denies access if
+ invalid credentials provided'''
+
+ req = requests.get('{0}'.format(URI_GET_STRING), auth=INVALID_AUTH_STRING)
+ assert req.status_code == requests.codes.unauthorized
+ assert UNAUTHORIZED_MSG in req.text
+
+ req = requests.put('{0}'.format(URI_PUT_STRING), auth=INVALID_AUTH_STRING,
+ json=MOI_DATA_TMPL)
+ assert req.status_code == requests.codes.unauthorized
+ assert UNAUTHORIZED_MSG in req.text
+
+ req = requests.patch('{0}'.format(URI_PATCH_STRING),
+ auth=INVALID_AUTH_STRING, json=MOI_DATA_PATCH)
+ assert req.status_code == requests.codes.unauthorized
+ assert UNAUTHORIZED_MSG in req.text
+
+ req = requests.delete('{0}'.format(URI_DELETE_STRING),
+ auth=INVALID_AUTH_STRING)
+ assert req.status_code == requests.codes.unauthorized
+ assert UNAUTHORIZED_MSG in req.text