def testClientCertPropertyOn_DisableMTLS(self): self.StartObjectPatch( properties.VALUES.context_aware.use_client_certificate, 'GetBool').return_value = True self.StartObjectPatch( apis_internal, '_GetApiDef').return_value = self.redis_v1_api_def endpoint = apis_internal._GetEffectiveApiEndpoint('redis', 'v1') self.assertEqual(endpoint, self.redis_v1_endpoint)
def testClientCertPropertyOff_EnableMTLS_OverrideMtlsEndpoint(self): self.StartObjectPatch( properties.VALUES.context_aware.use_client_certificate, 'GetBool').return_value = False self.StartObjectPatch( apis_internal, '_GetApiDef').return_value = self.compute_v1_api_def endpoint = apis_internal._GetEffectiveApiEndpoint('compute', 'v1') self.assertEqual(endpoint, self.compute_v1_endpoint) self.AssertErrEquals('')
def testAllMtlsEnabledServicesHaveMtlsEndpoints(self): """Makes sure all services enabling mTLS in gcloud have mTLS endpoints.""" self.StartObjectPatch( properties.VALUES.context_aware.use_client_certificate, 'GetBool').return_value = True failures = [] for service, versions in apis_map.MAP.items(): for version, api_def in versions.items(): if api_def.enable_mtls: mtls_endpoint = apis_internal._GetEffectiveApiEndpoint( service, version) if '.mtls.' not in mtls_endpoint: failures.append((service, version)) if failures: self.fail( 'These APIs have mTLS enabled but do not have mTLS endpoint: {}' .format(failures))
def GetEffectiveApiEndpoint(api_name, api_version, client_class=None): """Returns effective endpoint for given api.""" # pylint:disable=protected-access return apis_internal._GetEffectiveApiEndpoint(api_name, api_version, client_class)
def GetEffectiveApiEndpoint(api_name, api_version, client_class=None): """Returns effective endpoint for given api.""" # pylint:disable=protected-access return apis_internal._GetEffectiveApiEndpoint(api_name, api_version, client_class)