Skip to content

Commit

Permalink
Init commit - Simple connection test refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
cmcnally-r7 committed Oct 30, 2023
1 parent e3edd10 commit 7414640
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ def connect(self, params):
def test(self):
"""
Tests connectivity to the InsightVM Console via administrative info endpoint
:param session: Requests session populated with basic auth credentials
:param console_url: URL to the InsightVM console
:return: Namedtuple indicating connectivity (true = success, false = fail) and error message (if one exists)
"""

endpoint = endpoints.Administration.get_info(self.console_url)
Result = namedtuple("Result", "status message")
success_codes = (200, 201)
response = None

try:
response = self.session.get(url=endpoint, verify=False)
except RequestException:
Expand All @@ -50,8 +50,8 @@ def test(self):
else:
test_result = Result(False, "No response received")
else:
status = response.status_code in [200, 201]
if status:
status = response.status_code
if status in success_codes:
test_result = Result(status, "Success")
else:
test_result = Result(status, response.json()["message"])
Expand Down

0 comments on commit 7414640

Please sign in to comment.