def testAllPropertiesSetInGcloud(self): SET_PROXY(proxy_type='http', address='golden', port='80', username='******', password='******') proxy_info, from_gcloud = http_proxy_setup.EffectiveProxyInfo() self.assertIsNotNone(proxy_info) self.assertTrue(from_gcloud) http_proxy_setup._DisplayGcloudProxyInfo(proxy_info, from_gcloud) self.AssertErrEquals(textwrap.dedent("""\ Current effective Cloud SDK network proxy settings: type = http host = golden port = 80 username = username password = password """) + '\n')
def testNoGcloudPropertiesProxyInEnvironmentVars(self): self.StartEnvPatch( {'http_proxy': 'https://*****:*****@badproxy:8080', 'https_proxy': 'https://*****:*****@badproxy:8081'}) proxy_info, from_gcloud = http_proxy_setup.EffectiveProxyInfo() self.assertIsNotNone(proxy_info) self.assertFalse(from_gcloud) http_proxy_setup._DisplayGcloudProxyInfo(proxy_info, from_gcloud) self.AssertErrEquals(textwrap.dedent("""\ Current effective Cloud SDK network proxy settings: (These settings are from your machine's environment, not gcloud properties.) type = http host = badproxy port = 8081 username = baduser password = badpassword """) + '\n')
def __init__(self): self.type = None self.address = None self.port = None self.username = None self.password = None try: proxy_info, from_gcloud = http_proxy_setup.EffectiveProxyInfo() except properties.InvalidValueError: return if proxy_info and not from_gcloud: self.type = http_proxy_types.REVERSE_PROXY_TYPE_MAP.get( proxy_info.proxy_type, 'UNKNOWN PROXY TYPE') self.address = proxy_info.proxy_host self.port = proxy_info.proxy_port self.username = proxy_info.proxy_user self.password = proxy_info.proxy_pass
def testNoGcloudPropertiesNoProxyInEnvironmentVars(self): proxy_info, from_gcloud = http_proxy_setup.EffectiveProxyInfo() self.assertIsNone(proxy_info) self.assertFalse(from_gcloud) http_proxy_setup._DisplayGcloudProxyInfo(proxy_info, from_gcloud) self.AssertErrEquals('\n')
def testInvalidPropertiesSetInGcloud(self): SET_PROXY(proxy_type='http', port='80') with self.assertRaises(properties.InvalidValueError): http_proxy_setup.EffectiveProxyInfo()