presume 401 from insights means invalid credential

* Tell the user about the invalid credentials
This commit is contained in:
Chris Meyers
2017-08-14 16:09:18 -04:00
parent 5ad29c9081
commit 90ea9b8bde
2 changed files with 11 additions and 1 deletions

View File

@@ -158,6 +158,14 @@ class TestHostInsights():
(msg, code) = view.get_insights('https://myexample.com/whocares/me/', 'ignore', 'ignore')
assert msg['error'] == 'Failed to gather reports and maintenance plans from Insights API at URL https://myexample.com/whocares/me/. Server responded with 500 status code and message mock 500 err msg'
def test_get_insights_401(self, patch_parent, mocker):
view = HostInsights()
Response = namedtuple('Response', 'status_code content')
mocker.patch.object(view, '_get_insights', return_value=Response(401, ''))
(msg, code) = view.get_insights('https://myexample.com/whocares/me/', 'ignore', 'ignore')
assert msg['error'] == 'Unauthorized access. Please check your Insights Credential username and password.'
def test_get_insights_malformed_json_content(self, patch_parent, mocker):
view = HostInsights()