(self)
| 25 | |
| 26 | class BaseSSOTest(BaseAWSCommandParamsTest): |
| 27 | def setUp(self): |
| 28 | super().setUp() |
| 29 | self.files = FileCreator() |
| 30 | self.start_url = 'https://mysigin.com' |
| 31 | self.sso_region = 'us-west-2' |
| 32 | self.registration_scopes = None |
| 33 | self.account = '012345678912' |
| 34 | self.role_name = 'SSORole' |
| 35 | self.config_file = self.files.full_path('config') |
| 36 | self.environ['AWS_CONFIG_FILE'] = self.config_file |
| 37 | self.set_config_file_content() |
| 38 | self.access_token = 'foo.token.string' |
| 39 | self.token_cache_dir = self.files.full_path('token-cache') |
| 40 | self.token_cache_dir_patch = mock.patch( |
| 41 | 'awscli.customizations.sso.utils.SSO_TOKEN_DIR', |
| 42 | self.token_cache_dir, |
| 43 | ) |
| 44 | self.token_cache_dir_patch.start() |
| 45 | self._resolve_patch = mock.patch( |
| 46 | 'awscli.customizations.sso.login.resolve_start_url', |
| 47 | side_effect=lambda start_url, session, **kwargs: ( |
| 48 | start_url, |
| 49 | kwargs.get('configured_region', self.sso_region), |
| 50 | ), |
| 51 | ) |
| 52 | self._resolve_patch.start() |
| 53 | self.open_browser_mock = mock.Mock(spec=OpenBrowserHandler) |
| 54 | self.open_browser_patch = mock.patch( |
| 55 | 'awscli.customizations.sso.utils.OpenBrowserHandler', |
| 56 | self.open_browser_mock, |
| 57 | ) |
| 58 | self.open_browser_patch.start() |
| 59 | |
| 60 | self.fetcher_mock = mock.Mock(spec=AuthCodeFetcher) |
| 61 | self.fetcher_mock.return_value.redirect_uri_without_port.return_value = 'http://127.0.0.1/oauth/callback' |
| 62 | self.fetcher_mock.return_value.redirect_uri_with_port.return_value = ( |
| 63 | 'http://127.0.0.1:55555/oauth/callback' |
| 64 | ) |
| 65 | self.fetcher_mock.return_value.get_auth_code_and_state.return_value = ( |
| 66 | "abc", |
| 67 | "00000000-0000-0000-0000-000000000000", |
| 68 | ) |
| 69 | self.auth_code_fetcher_patch = mock.patch( |
| 70 | 'awscli.customizations.sso.utils.AuthCodeFetcher', |
| 71 | self.fetcher_mock, |
| 72 | ) |
| 73 | self.auth_code_fetcher_patch.start() |
| 74 | |
| 75 | self.uuid_mock = mock.Mock( |
| 76 | return_value=uuid.UUID("00000000-0000-0000-0000-000000000000") |
| 77 | ) |
| 78 | self.uuid_patch = mock.patch('uuid.uuid4', self.uuid_mock) |
| 79 | self.uuid_patch.start() |
| 80 | |
| 81 | self.expires_in = 28800 |
| 82 | self.expiration_time = time.time() + 1000 |
| 83 | |
| 84 | def tearDown(self): |
nothing calls this directly
no test coverage detected