def get_base_dictionary(): base_dict = {} current_user_name = get_user() base_dict["edi_current_user_name"] = current_user_name base_dict["edi_current_user_group_name"] = get_user_group() base_dict["edi_current_user_ssh_pub_keys"] = get_user_ssh_pub_keys() base_dict["edi_current_user_uid"] = get_user_uid() base_dict["edi_current_user_gid"] = get_user_gid() base_dict[ "edi_current_user_host_home_directory"] = get_user_home_directory( current_user_name) base_dict["edi_current_user_target_home_directory"] = "/home/{}".format( current_user_name) base_dict["edi_host_hostname"] = get_hostname() base_dict["edi_edi_plugin_directory"] = get_edi_plugin_directory() proxy_setup = ProxySetup() base_dict["edi_host_http_proxy"] = proxy_setup.get('http_proxy', default='') base_dict["edi_host_https_proxy"] = proxy_setup.get('https_proxy', default='') base_dict["edi_host_ftp_proxy"] = proxy_setup.get('ftp_proxy', default='') base_dict["edi_host_socks_proxy"] = proxy_setup.get('all_proxy', default='') base_dict["edi_host_no_proxy"] = proxy_setup.get('no_proxy', default='') base_dict["edi_edi_version"] = get_edi_version() base_dict["edi_lxd_version"] = get_lxd_version() base_dict["edi_current_display"] = get_current_display() return base_dict
def test_get_requests_proxy_dict_without_proxy(monkeypatch): with_gsettings(monkeypatch) intercept_proxy_environment(monkeypatch, 'manual', '', '', '', '') with clear_proxy_setup_cache(): proxy_dict = ProxySetup().get_requests_dict() assert proxy_dict.get('http') is None assert proxy_dict.get('https') is None assert proxy_dict.get('no_proxy') is None
def test_proxy_setup_no_gsettings_no_env(monkeypatch): without_gsettings(monkeypatch) intercept_proxy_environment(monkeypatch, 'manual', '''['localhost', '127.0.0.0/8', '::1']''', '3128', '', '') with clear_proxy_setup_cache(): proxy_setup = ProxySetup() assert proxy_setup.get('no_proxy', default='') == '' assert proxy_setup.get('http_proxy', default='') == '' assert proxy_setup.get('https_proxy', default='') == '' assert proxy_setup.get('ftp_proxy', default='') == '' assert proxy_setup.get('all_proxy', default='') == ''
def test_get_environment_without_proxy(monkeypatch): with_gsettings(monkeypatch) intercept_proxy_environment(monkeypatch, 'manual', '', '', '', '') with clear_proxy_setup_cache(): env = ProxySetup().get_environment() assert env.get('http_proxy') == '' assert env.get('https_proxy') == '' assert env.get('ftp_proxy') == '' assert env.get('all_proxy') == '' assert env.get('no_proxy') == ''
def test_proxy_setup_gsettings_no_env(monkeypatch): with_gsettings(monkeypatch) intercept_proxy_environment(monkeypatch, 'manual', '''['localhost', '127.0.0.0/8', '::1']''', '3128', '', '') with clear_proxy_setup_cache(): proxy_setup = ProxySetup() assert proxy_setup.get('no_proxy', default='') == 'localhost,127.0.0.0/8,::1' assert proxy_setup.get('http_proxy', default='') == 'http://*****:*****@example.com:3128/' assert proxy_setup.get('https_proxy', default='') == 'http://*****:*****@example.com:3128/' assert proxy_setup.get('ftp_proxy', default='') == 'http://*****:*****@example.com:3128/' assert proxy_setup.get('all_proxy', default='') == 'socks://*****:*****@example.com:3128/'
def test_proxy_setup_gsettings_env(monkeypatch): with_gsettings(monkeypatch) intercept_proxy_environment(monkeypatch, 'manual', '''['localhost', '127.0.0.0/8', '::1']''', '3128', 'protocol://proxy-xy', '1.2.3.4,5.6.7.8,example.com') with clear_proxy_setup_cache(): proxy_setup = ProxySetup() assert proxy_setup.get('no_proxy', default='') == '1.2.3.4,5.6.7.8,example.com' assert proxy_setup.get('http_proxy', default='') == 'protocol://proxy-xy' assert proxy_setup.get('https_proxy', default='') == 'protocol://proxy-xy' assert proxy_setup.get('ftp_proxy', default='') == 'protocol://proxy-xy' assert proxy_setup.get('all_proxy', default='') == 'protocol://proxy-xy'
def test_proxy_setup_gsettings_manual_edge_case_no_env(monkeypatch): with_gsettings(monkeypatch) intercept_proxy_environment(monkeypatch, 'manual', '@as []', '0', '', '') with clear_proxy_setup_cache(): proxy_setup = ProxySetup() assert proxy_setup.get('no_proxy') is None assert proxy_setup.get('http_proxy') is None assert proxy_setup.get('https_proxy') is None assert proxy_setup.get('ftp_proxy') is None assert proxy_setup.get('all_proxy') is None
def test_get_requests_proxy_dict_with_proxy(monkeypatch): with_gsettings(monkeypatch) intercept_proxy_environment(monkeypatch, 'manual', '''['localhost', '127.0.0.0/8', '::1']''', '3128', '', '') with clear_proxy_setup_cache(): proxy_dict = ProxySetup().get_requests_dict() assert proxy_dict.get('http') == 'http://*****:*****@example.com:3128/' assert proxy_dict.get('https') == 'http://*****:*****@example.com:3128/' assert proxy_dict.get('no_proxy') == 'localhost,127.0.0.0/8,::1' # test cache proxy_dict = ProxySetup().get_requests_dict() assert proxy_dict.get('http') == 'http://*****:*****@example.com:3128/'