def test_add_credentials_for_unsecure_authentication(self): """check username and key are really added to options""" config = load_config_file(self.root_path+'/domaintools/conf/api.ini') configuration = Configuration(config) configuration.secure_auth = False request = Request(configuration) request.add_credentials_options() options = request.get_options() self.assertTrue(config['username']==options['api_username'] and config['key']==options['api_key'])
def test_add_credentials_for_unsecure_authentication(self): """check username and key are really added to options""" config = load_config_file(self.root_path + '/domaintools/conf/api.ini') configuration = Configuration(config) configuration.secure_auth = False request = Request(configuration) request.add_credentials_options() options = request.get_options() self.assertTrue(config['username'] == options['api_username'] and config['key'] == options['api_key'])
def __init__(self, ini_resource = None): """ Construct the class Initiliaze it with default values (if no config given) """ #use DomainTools free API self.use_free_api = False #server host self.host = None #server port self.port = None #sub url (version) self.sub_url = None #beginning url self.base_url = None #domaintools API username self.username = None #domaintools API password self.password = None #secure authentication self.secure_path = True #default return type self.return_type = None #transport type (curl, etc.) self.transport_type = None #transport object in charge of calling API self.transport = None #proxy url self.proxy = None #default configuration file path self.default_config_path = os.path.realpath(os.path.dirname(__file__)+'/../conf/api.ini') #default configuration self.default_config = { 'username' : '', 'key' : '', 'use_free_api' : False, 'host' : 'api.domaintools.com', 'version' : 'v1', 'port' : '80', 'secure_auth' : True, 'return_type' : 'json', 'transport_type' : 'curl', 'content_type' : 'application/json', 'proxy' : None } #dictionary to map the good transport class self.transport_map = { 'curl' : CurlRestService } if(ini_resource == None): ini_resource = self.default_config_path config = {} if(type(ini_resource) is dict): config = ini_resource else: config = utils.load_config_file(ini_resource) self.init(config)
def __init__(self, ini_resource=None): """ Construct the class Initiliaze it with default values (if no config given) """ # server host self.host = None # server port self.port = None # sub url (version) self.sub_url = None # beginning url self.base_url = None # domaintools API username self.username = None # domaintools API password self.password = None # secure authentication self.secure_path = True # default return type self.return_type = None # transport type (curl, etc.) self.transport_type = None # transport object in charge of calling API self.transport = None # default configuration file path self.default_config_path = os.path.realpath(os.path.dirname(__file__) + "/../conf/api.ini") # default configuration self.default_config = { "username": "", "key": "", "host": "api.domaintools.com", "version": "v1", "port": "80", "secure_auth": 1, "return_type": "json", "transport_type": "curl", "content_type": "application/json", } # dictionary to map the good transport class self.transport_map = {"curl": CurlRestService} if ini_resource == None: ini_resource = self.default_config_path config = {} if type(ini_resource) is dict: config = ini_resource else: config = utils.load_config_file(ini_resource) self.init(config)