From f684c5b8c7d7d9d7bbf05912e99c133144f72aef Mon Sep 17 00:00:00 2001 From: arithmetic1728 Date: Tue, 1 Jun 2021 15:40:35 -0700 Subject: [PATCH] feat: add mTLS feature --- .../comment/SettingsCommentComposer.java | 2 ++ ...tractServiceStubSettingsClassComposer.java | 32 +++++++++++++++++++ .../asset/v1/AssetServiceClientTest.java | 2 +- .../v1/stub/AssetServiceStubSettings.java | 7 ++++ .../v1/IAMCredentialsClientTest.java | 2 +- .../v1/stub/IamCredentialsStubSettings.java | 7 ++++ .../google/iam/v1/IAMPolicyClientTest.java | 2 +- .../iam/v1/stub/IAMPolicyStubSettings.java | 7 ++++ .../v1/KeyManagementServiceClientTest.java | 4 +-- .../KeyManagementServiceStubSettings.java | 7 ++++ .../library/v1/LibraryServiceClientTest.java | 2 +- .../v1/stub/LibraryServiceStubSettings.java | 7 ++++ .../cloud/logging/v2/ConfigClientTest.java | 2 +- .../cloud/logging/v2/LoggingClientTest.java | 2 +- .../cloud/logging/v2/MetricsClientTest.java | 2 +- .../v2/stub/ConfigServiceV2StubSettings.java | 7 ++++ .../v2/stub/LoggingServiceV2StubSettings.java | 7 ++++ .../v2/stub/MetricsServiceV2StubSettings.java | 7 ++++ .../pubsub/v1/SchemaServiceClientTest.java | 4 +-- .../v1/SubscriptionAdminClientTest.java | 4 +-- .../cloud/pubsub/v1/TopicAdminClientTest.java | 4 +-- .../pubsub/v1/stub/PublisherStubSettings.java | 7 ++++ .../v1/stub/SchemaServiceStubSettings.java | 7 ++++ .../v1/stub/SubscriberStubSettings.java | 7 ++++ .../v1beta1/stub/CloudRedisStubSettings.java | 7 ++++ 25 files changed, 133 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/google/api/generator/gapic/composer/comment/SettingsCommentComposer.java b/src/main/java/com/google/api/generator/gapic/composer/comment/SettingsCommentComposer.java index 5e10eb9cd5..f1bf7c8860 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/comment/SettingsCommentComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/comment/SettingsCommentComposer.java @@ -61,6 +61,8 @@ public class SettingsCommentComposer { toSimpleComment("Returns a builder for the default ExecutorProvider for this service."); public static final CommentStatement DEFAULT_SERVICE_ENDPOINT_METHOD_COMMENT = toSimpleComment("Returns the default service endpoint."); + public static final CommentStatement DEFAULT_SERVICE_MTLS_ENDPOINT_METHOD_COMMENT = + toSimpleComment("Returns the default mTLS service endpoint."); public static final CommentStatement DEFAULT_SERVICE_SCOPES_METHOD_COMMENT = toSimpleComment("Returns the default service scopes."); diff --git a/src/main/java/com/google/api/generator/gapic/composer/common/AbstractServiceStubSettingsClassComposer.java b/src/main/java/com/google/api/generator/gapic/composer/common/AbstractServiceStubSettingsClassComposer.java index fb2d350011..200d615eb8 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/common/AbstractServiceStubSettingsClassComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/common/AbstractServiceStubSettingsClassComposer.java @@ -61,6 +61,7 @@ import com.google.api.generator.engine.ast.MethodDefinition; import com.google.api.generator.engine.ast.MethodInvocationExpr; import com.google.api.generator.engine.ast.NewObjectExpr; +import com.google.api.generator.engine.ast.PrimitiveValue; import com.google.api.generator.engine.ast.Reference; import com.google.api.generator.engine.ast.ReferenceConstructorExpr; import com.google.api.generator.engine.ast.RelationalOperationExpr; @@ -918,6 +919,22 @@ private List createDefaultHelperAndGetterMethods( .setReturnExpr(ValueExpr.withValue(StringObjectValue.withValue(service.defaultHost()))) .build()); + // Create the getDefaultMtlsEndpoint method. + returnType = TypeNode.STRING; + javaMethods.add( + MethodDefinition.builder() + .setHeaderCommentStatements( + SettingsCommentComposer.DEFAULT_SERVICE_MTLS_ENDPOINT_METHOD_COMMENT) + .setScope(ScopeNode.PUBLIC) + .setIsStatic(true) + .setReturnType(returnType) + .setName("getDefaultMtlsEndpoint") + .setReturnExpr( + ValueExpr.withValue( + StringObjectValue.withValue( + service.defaultHost().replace(".googleapis.com", ".mtls.googleapis.com")))) + .build()); + // Create the getDefaultServiceScopes method. returnType = TypeNode.withReference( @@ -1594,6 +1611,21 @@ private static MethodDefinition createNestedClassCreateDefaultMethod(TypeStore t .setArguments( MethodInvocationExpr.builder().setMethodName("getDefaultEndpoint").build()) .build()); + bodyExprs.add( + MethodInvocationExpr.builder() + .setExprReferenceExpr(builderVarExpr) + .setMethodName("setMtlsEndpoint") + .setArguments( + MethodInvocationExpr.builder().setMethodName("getDefaultMtlsEndpoint").build()) + .build()); + bodyExprs.add( + MethodInvocationExpr.builder() + .setExprReferenceExpr(builderVarExpr) + .setMethodName("setSwitchToMtlsEndpointAllowed") + .setArguments( + ValueExpr.withValue( + PrimitiveValue.builder().setType(TypeNode.BOOLEAN).setValue("true").build())) + .build()); bodyStatements.addAll( bodyExprs.stream().map(e -> ExprStatement.withExpr(e)).collect(Collectors.toList())); bodyStatements.add(EMPTY_LINE_STATEMENT); diff --git a/test/integration/goldens/asset/com/google/cloud/asset/v1/AssetServiceClientTest.java b/test/integration/goldens/asset/com/google/cloud/asset/v1/AssetServiceClientTest.java index e419696424..c8e04f20b7 100644 --- a/test/integration/goldens/asset/com/google/cloud/asset/v1/AssetServiceClientTest.java +++ b/test/integration/goldens/asset/com/google/cloud/asset/v1/AssetServiceClientTest.java @@ -52,10 +52,10 @@ @Generated("by gapic-generator-java") public class AssetServiceClientTest { + private static MockAssetService mockAssetService; private static MockServiceHelper mockServiceHelper; private AssetServiceClient client; private LocalChannelProvider channelProvider; - private static MockAssetService mockAssetService; @BeforeClass public static void startStaticServer() { diff --git a/test/integration/goldens/asset/com/google/cloud/asset/v1/stub/AssetServiceStubSettings.java b/test/integration/goldens/asset/com/google/cloud/asset/v1/stub/AssetServiceStubSettings.java index cceca0029a..52e7b84498 100644 --- a/test/integration/goldens/asset/com/google/cloud/asset/v1/stub/AssetServiceStubSettings.java +++ b/test/integration/goldens/asset/com/google/cloud/asset/v1/stub/AssetServiceStubSettings.java @@ -375,6 +375,11 @@ public static String getDefaultEndpoint() { return "cloudasset.googleapis.com:443"; } + /** Returns the default mTLS service endpoint. */ + public static String getDefaultMtlsEndpoint() { + return "cloudasset.mtls.googleapis.com:443"; + } + /** Returns the default service scopes. */ public static List getDefaultServiceScopes() { return DEFAULT_SERVICE_SCOPES; @@ -623,6 +628,8 @@ private static Builder createDefault() { builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); return initDefaults(builder); } diff --git a/test/integration/goldens/credentials/com/google/cloud/iam/credentials/v1/IAMCredentialsClientTest.java b/test/integration/goldens/credentials/com/google/cloud/iam/credentials/v1/IAMCredentialsClientTest.java index ad8fb75d32..6387b72a33 100644 --- a/test/integration/goldens/credentials/com/google/cloud/iam/credentials/v1/IAMCredentialsClientTest.java +++ b/test/integration/goldens/credentials/com/google/cloud/iam/credentials/v1/IAMCredentialsClientTest.java @@ -43,8 +43,8 @@ @Generated("by gapic-generator-java") public class IAMCredentialsClientTest { - private static MockServiceHelper mockServiceHelper; private static MockIAMCredentials mockIAMCredentials; + private static MockServiceHelper mockServiceHelper; private IamCredentialsClient client; private LocalChannelProvider channelProvider; diff --git a/test/integration/goldens/credentials/com/google/cloud/iam/credentials/v1/stub/IamCredentialsStubSettings.java b/test/integration/goldens/credentials/com/google/cloud/iam/credentials/v1/stub/IamCredentialsStubSettings.java index 0cec2d9668..7a4cd49735 100644 --- a/test/integration/goldens/credentials/com/google/cloud/iam/credentials/v1/stub/IamCredentialsStubSettings.java +++ b/test/integration/goldens/credentials/com/google/cloud/iam/credentials/v1/stub/IamCredentialsStubSettings.java @@ -138,6 +138,11 @@ public static String getDefaultEndpoint() { return "iamcredentials.googleapis.com:443"; } + /** Returns the default mTLS service endpoint. */ + public static String getDefaultMtlsEndpoint() { + return "iamcredentials.mtls.googleapis.com:443"; + } + /** Returns the default service scopes. */ public static List getDefaultServiceScopes() { return DEFAULT_SERVICE_SCOPES; @@ -277,6 +282,8 @@ private static Builder createDefault() { builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); return initDefaults(builder); } diff --git a/test/integration/goldens/iam/com/google/iam/v1/IAMPolicyClientTest.java b/test/integration/goldens/iam/com/google/iam/v1/IAMPolicyClientTest.java index a055a7a204..37d2b34058 100644 --- a/test/integration/goldens/iam/com/google/iam/v1/IAMPolicyClientTest.java +++ b/test/integration/goldens/iam/com/google/iam/v1/IAMPolicyClientTest.java @@ -41,9 +41,9 @@ @Generated("by gapic-generator-java") public class IAMPolicyClientTest { + private static MockIAMPolicy mockIAMPolicy; private static MockServiceHelper mockServiceHelper; private IAMPolicyClient client; - private static MockIAMPolicy mockIAMPolicy; private LocalChannelProvider channelProvider; @BeforeClass diff --git a/test/integration/goldens/iam/com/google/iam/v1/stub/IAMPolicyStubSettings.java b/test/integration/goldens/iam/com/google/iam/v1/stub/IAMPolicyStubSettings.java index 5959e94a06..f69f7ea460 100644 --- a/test/integration/goldens/iam/com/google/iam/v1/stub/IAMPolicyStubSettings.java +++ b/test/integration/goldens/iam/com/google/iam/v1/stub/IAMPolicyStubSettings.java @@ -125,6 +125,11 @@ public static String getDefaultEndpoint() { return "iam-meta-api.googleapis.com:443"; } + /** Returns the default mTLS service endpoint. */ + public static String getDefaultMtlsEndpoint() { + return "iam-meta-api.mtls.googleapis.com:443"; + } + /** Returns the default service scopes. */ public static List getDefaultServiceScopes() { return DEFAULT_SERVICE_SCOPES; @@ -250,6 +255,8 @@ private static Builder createDefault() { builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); return initDefaults(builder); } diff --git a/test/integration/goldens/kms/com/google/cloud/kms/v1/KeyManagementServiceClientTest.java b/test/integration/goldens/kms/com/google/cloud/kms/v1/KeyManagementServiceClientTest.java index b1952fc8e3..e2eacb133f 100644 --- a/test/integration/goldens/kms/com/google/cloud/kms/v1/KeyManagementServiceClientTest.java +++ b/test/integration/goldens/kms/com/google/cloud/kms/v1/KeyManagementServiceClientTest.java @@ -67,10 +67,10 @@ @Generated("by gapic-generator-java") public class KeyManagementServiceClientTest { private static MockKeyManagementService mockKeyManagementService; - private static MockServiceHelper mockServiceHelper; - private KeyManagementServiceClient client; private static MockIAMPolicy mockIAMPolicy; private static MockLocations mockLocations; + private static MockServiceHelper mockServiceHelper; + private KeyManagementServiceClient client; private LocalChannelProvider channelProvider; @BeforeClass diff --git a/test/integration/goldens/kms/com/google/cloud/kms/v1/stub/KeyManagementServiceStubSettings.java b/test/integration/goldens/kms/com/google/cloud/kms/v1/stub/KeyManagementServiceStubSettings.java index 5ebc43167f..77190adf46 100644 --- a/test/integration/goldens/kms/com/google/cloud/kms/v1/stub/KeyManagementServiceStubSettings.java +++ b/test/integration/goldens/kms/com/google/cloud/kms/v1/stub/KeyManagementServiceStubSettings.java @@ -645,6 +645,11 @@ public static String getDefaultEndpoint() { return "cloudkms.googleapis.com:443"; } + /** Returns the default mTLS service endpoint. */ + public static String getDefaultMtlsEndpoint() { + return "cloudkms.mtls.googleapis.com:443"; + } + /** Returns the default service scopes. */ public static List getDefaultServiceScopes() { return DEFAULT_SERVICE_SCOPES; @@ -962,6 +967,8 @@ private static Builder createDefault() { builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); return initDefaults(builder); } diff --git a/test/integration/goldens/library/com/google/cloud/example/library/v1/LibraryServiceClientTest.java b/test/integration/goldens/library/com/google/cloud/example/library/v1/LibraryServiceClientTest.java index 82edc829d0..a1086668da 100644 --- a/test/integration/goldens/library/com/google/cloud/example/library/v1/LibraryServiceClientTest.java +++ b/test/integration/goldens/library/com/google/cloud/example/library/v1/LibraryServiceClientTest.java @@ -61,9 +61,9 @@ @Generated("by gapic-generator-java") public class LibraryServiceClientTest { + private static MockLibraryService mockLibraryService; private static MockServiceHelper mockServiceHelper; private LibraryServiceClient client; - private static MockLibraryService mockLibraryService; private LocalChannelProvider channelProvider; @BeforeClass diff --git a/test/integration/goldens/library/com/google/cloud/example/library/v1/stub/LibraryServiceStubSettings.java b/test/integration/goldens/library/com/google/cloud/example/library/v1/stub/LibraryServiceStubSettings.java index 0f7a252975..056516530c 100644 --- a/test/integration/goldens/library/com/google/cloud/example/library/v1/stub/LibraryServiceStubSettings.java +++ b/test/integration/goldens/library/com/google/cloud/example/library/v1/stub/LibraryServiceStubSettings.java @@ -303,6 +303,11 @@ public static String getDefaultEndpoint() { return "library-example.googleapis.com:443"; } + /** Returns the default mTLS service endpoint. */ + public static String getDefaultMtlsEndpoint() { + return "library-example.mtls.googleapis.com:443"; + } + /** Returns the default service scopes. */ public static List getDefaultServiceScopes() { return DEFAULT_SERVICE_SCOPES; @@ -473,6 +478,8 @@ private static Builder createDefault() { builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); return initDefaults(builder); } diff --git a/test/integration/goldens/logging/com/google/cloud/logging/v2/ConfigClientTest.java b/test/integration/goldens/logging/com/google/cloud/logging/v2/ConfigClientTest.java index 442b83c86b..9f8d390854 100644 --- a/test/integration/goldens/logging/com/google/cloud/logging/v2/ConfigClientTest.java +++ b/test/integration/goldens/logging/com/google/cloud/logging/v2/ConfigClientTest.java @@ -95,10 +95,10 @@ @Generated("by gapic-generator-java") public class ConfigClientTest { + private static MockConfigServiceV2 mockConfigServiceV2; private static MockServiceHelper mockServiceHelper; private ConfigClient client; private LocalChannelProvider channelProvider; - private static MockConfigServiceV2 mockConfigServiceV2; @BeforeClass public static void startStaticServer() { diff --git a/test/integration/goldens/logging/com/google/cloud/logging/v2/LoggingClientTest.java b/test/integration/goldens/logging/com/google/cloud/logging/v2/LoggingClientTest.java index a6395714c6..d6bc3e6fa4 100644 --- a/test/integration/goldens/logging/com/google/cloud/logging/v2/LoggingClientTest.java +++ b/test/integration/goldens/logging/com/google/cloud/logging/v2/LoggingClientTest.java @@ -73,8 +73,8 @@ @Generated("by gapic-generator-java") public class LoggingClientTest { - private static MockServiceHelper mockServiceHelper; private static MockLoggingServiceV2 mockLoggingServiceV2; + private static MockServiceHelper mockServiceHelper; private LoggingClient client; private LocalChannelProvider channelProvider; diff --git a/test/integration/goldens/logging/com/google/cloud/logging/v2/MetricsClientTest.java b/test/integration/goldens/logging/com/google/cloud/logging/v2/MetricsClientTest.java index e26c9980fb..d6bc8e11f9 100644 --- a/test/integration/goldens/logging/com/google/cloud/logging/v2/MetricsClientTest.java +++ b/test/integration/goldens/logging/com/google/cloud/logging/v2/MetricsClientTest.java @@ -56,9 +56,9 @@ @Generated("by gapic-generator-java") public class MetricsClientTest { + private static MockMetricsServiceV2 mockMetricsServiceV2; private static MockServiceHelper mockServiceHelper; private MetricsClient client; - private static MockMetricsServiceV2 mockMetricsServiceV2; private LocalChannelProvider channelProvider; @BeforeClass diff --git a/test/integration/goldens/logging/com/google/cloud/logging/v2/stub/ConfigServiceV2StubSettings.java b/test/integration/goldens/logging/com/google/cloud/logging/v2/stub/ConfigServiceV2StubSettings.java index bfeba9f0a4..7c30359c19 100644 --- a/test/integration/goldens/logging/com/google/cloud/logging/v2/stub/ConfigServiceV2StubSettings.java +++ b/test/integration/goldens/logging/com/google/cloud/logging/v2/stub/ConfigServiceV2StubSettings.java @@ -514,6 +514,11 @@ public static String getDefaultEndpoint() { return "logging.googleapis.com:443"; } + /** Returns the default mTLS service endpoint. */ + public static String getDefaultMtlsEndpoint() { + return "logging.mtls.googleapis.com:443"; + } + /** Returns the default service scopes. */ public static List getDefaultServiceScopes() { return DEFAULT_SERVICE_SCOPES; @@ -792,6 +797,8 @@ private static Builder createDefault() { builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); return initDefaults(builder); } diff --git a/test/integration/goldens/logging/com/google/cloud/logging/v2/stub/LoggingServiceV2StubSettings.java b/test/integration/goldens/logging/com/google/cloud/logging/v2/stub/LoggingServiceV2StubSettings.java index d1fa3db875..bd2e07a52b 100644 --- a/test/integration/goldens/logging/com/google/cloud/logging/v2/stub/LoggingServiceV2StubSettings.java +++ b/test/integration/goldens/logging/com/google/cloud/logging/v2/stub/LoggingServiceV2StubSettings.java @@ -444,6 +444,11 @@ public static String getDefaultEndpoint() { return "logging.googleapis.com:443"; } + /** Returns the default mTLS service endpoint. */ + public static String getDefaultMtlsEndpoint() { + return "logging.mtls.googleapis.com:443"; + } + /** Returns the default service scopes. */ public static List getDefaultServiceScopes() { return DEFAULT_SERVICE_SCOPES; @@ -626,6 +631,8 @@ private static Builder createDefault() { builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); return initDefaults(builder); } diff --git a/test/integration/goldens/logging/com/google/cloud/logging/v2/stub/MetricsServiceV2StubSettings.java b/test/integration/goldens/logging/com/google/cloud/logging/v2/stub/MetricsServiceV2StubSettings.java index 3fd951caa0..634af2b28c 100644 --- a/test/integration/goldens/logging/com/google/cloud/logging/v2/stub/MetricsServiceV2StubSettings.java +++ b/test/integration/goldens/logging/com/google/cloud/logging/v2/stub/MetricsServiceV2StubSettings.java @@ -212,6 +212,11 @@ public static String getDefaultEndpoint() { return "logging.googleapis.com:443"; } + /** Returns the default mTLS service endpoint. */ + public static String getDefaultMtlsEndpoint() { + return "logging.mtls.googleapis.com:443"; + } + /** Returns the default service scopes. */ public static List getDefaultServiceScopes() { return DEFAULT_SERVICE_SCOPES; @@ -371,6 +376,8 @@ private static Builder createDefault() { builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); return initDefaults(builder); } diff --git a/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/SchemaServiceClientTest.java b/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/SchemaServiceClientTest.java index 9a2ce5e16b..64f6d2d726 100644 --- a/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/SchemaServiceClientTest.java +++ b/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/SchemaServiceClientTest.java @@ -65,10 +65,10 @@ @Generated("by gapic-generator-java") public class SchemaServiceClientTest { - private static MockServiceHelper mockServiceHelper; private static MockSchemaService mockSchemaService; - private SchemaServiceClient client; private static MockIAMPolicy mockIAMPolicy; + private static MockServiceHelper mockServiceHelper; + private SchemaServiceClient client; private LocalChannelProvider channelProvider; @BeforeClass diff --git a/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/SubscriptionAdminClientTest.java b/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/SubscriptionAdminClientTest.java index 2686f5316f..a0ee567406 100644 --- a/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/SubscriptionAdminClientTest.java +++ b/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/SubscriptionAdminClientTest.java @@ -93,10 +93,10 @@ @Generated("by gapic-generator-java") public class SubscriptionAdminClientTest { - private static MockServiceHelper mockServiceHelper; private static MockSubscriber mockSubscriber; - private SubscriptionAdminClient client; private static MockIAMPolicy mockIAMPolicy; + private static MockServiceHelper mockServiceHelper; + private SubscriptionAdminClient client; private LocalChannelProvider channelProvider; @BeforeClass diff --git a/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/TopicAdminClientTest.java b/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/TopicAdminClientTest.java index 94b7162fba..eb08debd59 100644 --- a/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/TopicAdminClientTest.java +++ b/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/TopicAdminClientTest.java @@ -76,10 +76,10 @@ @Generated("by gapic-generator-java") public class TopicAdminClientTest { - private static MockServiceHelper mockServiceHelper; private static MockPublisher mockPublisher; - private TopicAdminClient client; private static MockIAMPolicy mockIAMPolicy; + private static MockServiceHelper mockServiceHelper; + private TopicAdminClient client; private LocalChannelProvider channelProvider; @BeforeClass diff --git a/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/stub/PublisherStubSettings.java b/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/stub/PublisherStubSettings.java index 5909b0850c..95307e4d63 100644 --- a/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/stub/PublisherStubSettings.java +++ b/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/stub/PublisherStubSettings.java @@ -478,6 +478,11 @@ public static String getDefaultEndpoint() { return "pubsub.googleapis.com:443"; } + /** Returns the default mTLS service endpoint. */ + public static String getDefaultMtlsEndpoint() { + return "pubsub.mtls.googleapis.com:443"; + } + /** Returns the default service scopes. */ public static List getDefaultServiceScopes() { return DEFAULT_SERVICE_SCOPES; @@ -711,6 +716,8 @@ private static Builder createDefault() { builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); return initDefaults(builder); } diff --git a/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/stub/SchemaServiceStubSettings.java b/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/stub/SchemaServiceStubSettings.java index 6f8f9b182e..9c4e780cd8 100644 --- a/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/stub/SchemaServiceStubSettings.java +++ b/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/stub/SchemaServiceStubSettings.java @@ -242,6 +242,11 @@ public static String getDefaultEndpoint() { return "pubsub.googleapis.com:443"; } + /** Returns the default mTLS service endpoint. */ + public static String getDefaultMtlsEndpoint() { + return "pubsub.mtls.googleapis.com:443"; + } + /** Returns the default service scopes. */ public static List getDefaultServiceScopes() { return DEFAULT_SERVICE_SCOPES; @@ -401,6 +406,8 @@ private static Builder createDefault() { builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); return initDefaults(builder); } diff --git a/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/stub/SubscriberStubSettings.java b/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/stub/SubscriberStubSettings.java index 55101f5595..c3b932cd11 100644 --- a/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/stub/SubscriberStubSettings.java +++ b/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/stub/SubscriberStubSettings.java @@ -383,6 +383,11 @@ public static String getDefaultEndpoint() { return "pubsub.googleapis.com:443"; } + /** Returns the default mTLS service endpoint. */ + public static String getDefaultMtlsEndpoint() { + return "pubsub.mtls.googleapis.com:443"; + } + /** Returns the default service scopes. */ public static List getDefaultServiceScopes() { return DEFAULT_SERVICE_SCOPES; @@ -653,6 +658,8 @@ private static Builder createDefault() { builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); return initDefaults(builder); } diff --git a/test/integration/goldens/redis/com/google/cloud/redis/v1beta1/stub/CloudRedisStubSettings.java b/test/integration/goldens/redis/com/google/cloud/redis/v1beta1/stub/CloudRedisStubSettings.java index fcb157ea43..1314469600 100644 --- a/test/integration/goldens/redis/com/google/cloud/redis/v1beta1/stub/CloudRedisStubSettings.java +++ b/test/integration/goldens/redis/com/google/cloud/redis/v1beta1/stub/CloudRedisStubSettings.java @@ -294,6 +294,11 @@ public static String getDefaultEndpoint() { return "redis.googleapis.com:443"; } + /** Returns the default mTLS service endpoint. */ + public static String getDefaultMtlsEndpoint() { + return "redis.mtls.googleapis.com:443"; + } + /** Returns the default service scopes. */ public static List getDefaultServiceScopes() { return DEFAULT_SERVICE_SCOPES; @@ -499,6 +504,8 @@ private static Builder createDefault() { builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); return initDefaults(builder); }