def test_verify_client_connection(self): os.environ[_debug.DISABLE_VERIFY_VARIABLE_NAME] = "" self.assertFalse(_debug.should_disable_connection_verify()) os.environ[_debug.DISABLE_VERIFY_VARIABLE_NAME] = "1" self.assertTrue(_debug.should_disable_connection_verify()) clientMock = MagicMock() clientMock.config.connection.verify = True _debug.allow_debug_connection(clientMock) self.assertFalse(clientMock.config.connection.verify)
def create_arm_client_factory(config): if arm_client_factory: return arm_client_factory(config) else: return allow_debug_connection( SubscriptionClient( config, base_url=CLOUD.endpoints.resource_manager))
def configure_common_settings(client): _debug.allow_debug_connection(client) client.config.add_user_agent(UA_AGENT) for header, value in APPLICATION.session['headers'].items(): # We are working with the autorest team to expose the add_header # functionality of the generated client to avoid having to access # private members client._client.add_header(header, value) #pylint: disable=protected-access command_name_suffix = ';completer-request' if APPLICATION.session['completer_active'] else '' client._client.add_header('CommandName', #pylint: disable=protected-access "{}{}".format(APPLICATION.session['command'], command_name_suffix)) client.config.generate_client_request_id = \ 'x-ms-client-request-id' not in APPLICATION.session['headers']
def _mock_get_mgmt_service_client(client_type, subscription_bound=True, subscription_id=None, api_version=None, base_url_bound=None, **kwargs): # version of _get_mgmt_service_client to use when recording or playing tests profile = Profile() cred, subscription_id, _ = profile.get_login_credentials( subscription_id=subscription_id) client_kwargs = {} if base_url_bound: client_kwargs = {'base_url': CLOUD.endpoints.resource_manager} if api_version: client_kwargs['api_version'] = api_version if kwargs: client_kwargs.update(kwargs) if subscription_bound: client = client_type(cred, subscription_id, **client_kwargs) else: client = client_type(cred, **client_kwargs) client = _debug.allow_debug_connection(client) client.config.add_user_agent("AZURECLI/TEST/{}".format(core_version)) return (client, subscription_id)
def _mock_get_mgmt_service_client(client_type, subscription_bound=True, subscription_id=None, api_version=None): # version of _get_mgmt_service_client to use when recording or playing tests profile = Profile() cred, subscription_id, _ = profile.get_login_credentials(subscription_id=subscription_id) if subscription_bound: client = client_type(cred, subscription_id, api_version=api_version) \ if api_version else client_type(cred, subscription_id) else: client = client_type(cred, api_version=api_version) \ if api_version else client_type(cred) _debug.allow_debug_connection(client) client.config.add_user_agent("AZURECLI/TEST/{}".format(core_version)) return (client, subscription_id)
def configure_common_settings(client): _debug.allow_debug_connection(client) client.config.add_user_agent(UA_AGENT) for header, value in APPLICATION.session['headers'].items(): # We are working with the autorest team to expose the add_header # functionality of the generated client to avoid having to access # private members client._client.add_header(header, value) #pylint: disable=protected-access command_name_suffix = ';completer-request' if APPLICATION.session[ 'completer_active'] else '' client._client.add_header( 'CommandName', #pylint: disable=protected-access "{}{}".format(APPLICATION.session['command'], command_name_suffix)) client.config.generate_client_request_id = \ 'x-ms-client-request-id' not in APPLICATION.session['headers']
def create_arm_client_factory(config): if arm_client_factory: return arm_client_factory(config) else: return allow_debug_connection(SubscriptionClient( config, base_url=CLOUD.endpoints.resource_manager))