Exemple #1
0
    def test_get_auth_info__user_arg_username_is_None(self):
        user_login_args = UserLoginArgs(username=None, password=None, api_key=None, skip_cache=False)

        returned_tuple = self.provider._get_auth_info(syn, user_login_args)
        assert_equals(self.expected_return_tuple, returned_tuple)
        self.mock_get_most_recent_user.assert_called_once_with()
        self.mock_get_api_key.assert_called_once_with(self.username)
Exemple #2
0
    def test_get_auth_info__skip_cache_is_True(self):
        user_login_args = UserLoginArgs(username=self.username, password=None, api_key=None, skip_cache=True)

        returned_tuple = self.provider._get_auth_info(syn, user_login_args)
        assert_equals((None,None,None), returned_tuple)
        self.mock_get_most_recent_user.assert_not_called()
        self.mock_get_api_key.assert_not_called()
Exemple #3
0
    def test_get_auth_info__user_arg_username_does_not_match_config(self):
        user_login_args = UserLoginArgs(username="******", password=None, api_key=None, skip_cache=False)

        returned_tuple = self.provider._get_auth_info(syn, user_login_args)

        assert_equals((None,None,None), returned_tuple)
        self.mock_get_config_authentication.assert_called_once_with()
    def test_get_auth_info(self):
        user_login_args = UserLoginArgs("username", "password",
                                        base64.b64encode(b"api_key"), False)
        provider = UserArgsCredentialsProvider()
        returned_tuple = provider._get_auth_info(syn, user_login_args)

        assert_equals((user_login_args.username, user_login_args.password,
                       user_login_args.api_key), returned_tuple)
    def test_get_auth_info__session_token_is_None(self):
        user_login_args = UserLoginArgs(session_token=None)

        returned_tuple = self.provider._get_auth_info(syn, user_login_args)

        assert_equals((None, None, None), returned_tuple)
        self.mock_get_user_profile.assert_not_called()
        self.mock_get_api_key.assert_not_called()
Exemple #6
0
 def setup(self):
     self.username = "******"
     self.password = "******"
     self.api_key = base64.b64encode(b"api_key").decode()
     self.user_login_args = UserLoginArgs(self.username, self.password, self.api_key, False)
     class SynapseCredProviderTester(SynapseCredentialsProvider): #SynapseCredentialsProvider has abstractmethod so we can't instantiate it unless we overwrite it
         def _get_auth_info(self, syn, user_login_args):
             pass
     self.provider = SynapseCredProviderTester()
    def setup(self):
        self.login_args = {'email': "AzureDiamond", "password": "******"}
        self.expected_user_args = UserLoginArgs(username="******", password="******", api_key=None,
                                                skip_cache=False)
        self.synapse_creds = SynapseCredentials("AzureDiamond", base64.b64encode(b"*******").decode())

        self.mocked_credential_chain = create_autospec(SynapseCredentialsProviderChain)
        self.mocked_credential_chain.get_credentials.return_value = self.synapse_creds
        self.get_default_credential_chain_patcher = patch.object(synapseclient.client, "get_default_credential_chain",
                                                                 return_value=self.mocked_credential_chain)
        self.mocked_get_credential_chain = self.get_default_credential_chain_patcher.start()
Exemple #8
0
    def test_get_auth_info__session_token_not_None(self):
        username = '******'
        api_key = 'qwerty'
        session_token = "my session token"
        user_login_args = UserLoginArgs(session_token=session_token)
        self.mock_get_user_profile.return_value = {'userName': username}
        self.mock_get_api_key.return_value = api_key

        returned_tuple = self.provider._get_auth_info(syn, user_login_args)

        assert_equals((username, None, api_key), returned_tuple)
        self.mock_get_user_profile.assert_called_once_with(sessionToken=session_token)
        self.mock_get_api_key.assert_called_once_with(session_token)
 def setup(self):
     self.cred_provider = mock.create_autospec(SynapseCredentialsProvider)
     self.user_login_args = UserLoginArgs(
         *(None, ) * 4)  # user login args don't matter for these tests
     self.credential_provider_chain = SynapseCredentialsProviderChain(
         [self.cred_provider])