-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* comment additions to check status of release pipeline * bump python version * update pre-commit rev * bumping isort version to address data.extras.pipfile_deprecated_finder[2] must match pattern ^[a-zA-Z-_.0-9]+$ * fix failing test * linting * black
- Loading branch information
1 parent
7744204
commit b746782
Showing
5 changed files
with
29 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
"""Docstring in public module.""" | ||
|
||
import os | ||
import sys | ||
from unittest.mock import patch | ||
|
||
import ujson as json | ||
from tornado.testing import AsyncHTTPTestCase | ||
|
@@ -52,9 +54,24 @@ def test_role_api_fail_multiple_matching_roles(self): | |
self.assertEqual(response_j["type"], "redirect") | ||
self.assertIn("/?arn=role&warningMessage=", response_j["redirect_url"]) | ||
|
||
def test_role_api_success(self): | ||
@patch("consoleme.default_plugins.plugins.aws.aws.AsyncHTTPClient") | ||
def test_role_api_success(self, mock_client): | ||
from consoleme.config import config | ||
|
||
class TestResp: | ||
def __init__(self, code, body): | ||
self.code = code | ||
self.body = body | ||
|
||
class TestClient: | ||
async def fetch( | ||
self, url, method="GET", body=None, headers=None, ssl_options=None | ||
): | ||
return TestResp( | ||
code=200, body='{"SigninToken": "testTokenSignin456223"}' | ||
) | ||
|
||
mock_client.return_value = TestClient() | ||
headers = { | ||
config.get("auth.user_header_name"): "[email protected]", | ||
config.get("auth.groups_header_name"): "[email protected]", | ||
|
@@ -67,6 +84,6 @@ def test_role_api_success(self): | |
self.assertEqual(response_j["reason"], "console_login") | ||
self.assertEqual(response_j["role"], "arn:aws:iam::123456789012:role/roleA") | ||
self.assertIn( | ||
"https://signin.aws.amazon.com/federation?Action=login&Issuer=YourCompany&Destination=https%3A%2F%2Fus-east-1.console.aws.amazon.com&SigninToken=", | ||
"https://signin.aws.amazon.com/federation?Action=login&Issuer=YourCompany&Destination=https%3A%2F%2Fus-east-1.console.aws.amazon.com&SigninToken=testTokenSignin456223", | ||
response_j["redirect_url"], | ||
) |