def test_returns_no_aliases_when_the_call_for_aliases_failed(self): # given failed response self.authenticated_session.post = lambda *args, **kwargs: _failed_account_page_response( ) # when gets account aliases via fetcher accounts = account_aliases_fetcher.account_aliases( self.authenticated_session, self.irrelevant_username, self.irrelevant_password, self.irrelevant_auth_method, self.authenticated_saml_response, self.irrelevant_config) # then there are no aliases assert accounts == {}
def test_returns_empty_account_dictionary_when_no_account_are_named(self): # given user with no aws accounts self.authenticated_session.post = lambda *args, **kwargs: _account_page_response( []) # when gets account aliases via fetcher accounts = account_aliases_fetcher.account_aliases( self.authenticated_session, self.irrelevant_username, self.irrelevant_password, self.irrelevant_auth_method, self.authenticated_saml_response, self.irrelevant_config) # then returns no accounts assert accounts == {}
def test_returns_empty_account_dictionary_when_no_account_are_named(self): # given user with no aws accounts self.authenticated_session.post = lambda *args, **kwargs: _account_page_response([]) # when gets account aliases via fetcher accounts = account_aliases_fetcher.account_aliases(self.authenticated_session, self.irrelevant_username, self.irrelevant_password, self.irrelevant_auth_method, self.authenticated_saml_response, self.irrelevant_config) # then returns no accounts assert accounts == {}
def test_returns_no_aliases_when_the_call_for_aliases_failed(self): # given failed response self.authenticated_session.post = lambda *args, **kwargs: _failed_account_page_response() # when gets account aliases via fetcher accounts = account_aliases_fetcher.account_aliases(self.authenticated_session, self.irrelevant_username, self.irrelevant_password, self.irrelevant_auth_method, self.authenticated_saml_response, self.irrelevant_config) # then there are no aliases assert accounts == {}
def test_returns_one_account_when_one_account_is_listed(self): # given user with no aws accounts account_no = '123' account_alias = 'single' self.authenticated_session.post = lambda *args, **kwargs: _account_page_response( [_aws_account(account_alias, account_no)]) # when gets account aliases via fetcher accounts = account_aliases_fetcher.account_aliases( self.authenticated_session, self.irrelevant_username, self.irrelevant_password, self.irrelevant_auth_method, self.authenticated_saml_response, self.irrelevant_config) # then returns no accounts assert accounts == {account_no: account_alias}
def test_returns_accounts_expected_for_real_case_response(self): # given response with accounts response_text, expected_accounts = self._response_with_expected_aliases( ) self.authenticated_session.post = lambda *args, **kwargs: _account_page_response_text( response_text) # when gets account aliases via fetcher accounts = account_aliases_fetcher.account_aliases( self.authenticated_session, self.irrelevant_username, self.irrelevant_password, self.irrelevant_auth_method, self.authenticated_saml_response, self.irrelevant_config) # then account numbers matches assert accounts.keys() == expected_accounts.keys()
def test_returns_full_saml_name_account_when_no_account_alias_is_provided( self): # given aws account without alias account_no = '123123' full_account_name = 'Account: {}'.format(account_no) self.authenticated_session.post = lambda *args, **kwargs: _account_page_response( [_aws_account_without_alias(account_no)]) # when gets account aliases via fetcher accounts = account_aliases_fetcher.account_aliases( self.authenticated_session, self.irrelevant_username, self.irrelevant_password, self.irrelevant_auth_method, self.authenticated_saml_response, self.irrelevant_config) # then uses full account name as the alias assert accounts == {account_no: full_account_name}
def test_returns_accounts_expected_for_real_case_response(self): # given response with accounts response_text, expected_accounts = self._response_with_expected_aliases() self.authenticated_session.post = lambda *args, **kwargs: _account_page_response_text(response_text) # when gets account aliases via fetcher accounts = account_aliases_fetcher.account_aliases(self.authenticated_session, self.irrelevant_username, self.irrelevant_password, self.irrelevant_auth_method, self.authenticated_saml_response, self.irrelevant_config) # then account numbers matches assert accounts.keys() == expected_accounts.keys()
def test_returns_one_account_when_one_account_is_listed(self): # given user with no aws accounts account_no = '123' account_alias = 'single' self.authenticated_session.post = lambda *args, **kwargs: _account_page_response([_aws_account(account_alias, account_no)]) # when gets account aliases via fetcher accounts = account_aliases_fetcher.account_aliases(self.authenticated_session, self.irrelevant_username, self.irrelevant_password, self.irrelevant_auth_method, self.authenticated_saml_response, self.irrelevant_config) # then returns no accounts assert accounts == {account_no: account_alias}
def test_returns_full_saml_name_account_when_no_account_alias_is_provided(self): # given aws account without alias account_no = '123123' full_account_name = 'Account: {}'.format(account_no) self.authenticated_session.post = lambda *args, **kwargs: _account_page_response([ _aws_account_without_alias(account_no) ]) # when gets account aliases via fetcher accounts = account_aliases_fetcher.account_aliases(self.authenticated_session, self.irrelevant_username, self.irrelevant_password, self.irrelevant_auth_method, self.authenticated_saml_response, self.irrelevant_config) # then uses full account name as the alias assert accounts == {account_no: full_account_name}