Modify the expected HTTP status code for unauthorized InfluxDB query

The status code differs with InfluxDB version 0.11 vs 1.1.

Change-Id: I24a6b8980bf513d6b85112f77899a087e85a5cca
This commit is contained in:
Swann Croiset 2017-01-13 09:52:09 +01:00
parent 27639b433a
commit e0bfdb76dd
2 changed files with 11 additions and 5 deletions

View File

@ -38,8 +38,8 @@ def check_http_get_response(url, expected_code=200, msg=None, **kwargs):
:param url: the requested URL
:type url: str
:param expected_code: the expected HTTP response code. Defaults to 200
:type expected_code: int
:param expected_code: the expected HTTP response code(s). Defaults to 200
:type expected_code: list(int) or int
:param msg: the assertion message. Defaults to None
:type msg: str
:returns: HTTP response object
@ -50,8 +50,12 @@ def check_http_get_response(url, expected_code=200, msg=None, **kwargs):
cert = helpers.get_fixture("https/rootCA.pem")
msg = msg or "%s responded with {0}, expected {1}" % url
r = s.get(url, verify=cert, **kwargs)
asserts.assert_equal(
r.status_code, expected_code, msg.format(r.status_code, expected_code))
if isinstance(expected_code, int):
expected_code = [expected_code]
asserts.assert_true(
r.status_code in expected_code,
msg.format(r.status_code, expected_code))
return r

View File

@ -107,7 +107,9 @@ class InfluxdbPluginApi(base_test.PluginApi):
self.do_influxdb_query("show measurements")
logger.info("Check that the InfluxDB user doesn't have admin rights")
self.do_influxdb_query("show stats", expected_code=401)
# 401 is for InfluxDB 0.11 and 403 for InfluxDB 1.1
self.do_influxdb_query("show stats", expected_code=[401, 403])
logger.info("Check that the InfluxDB root user has admin rights")
self.do_influxdb_query("show stats",