Skip to content

Commit 5a42df7

Browse files
johnfmikhailchingor13
authored andcommitted
---
yaml --- r: 12877 b: refs/heads/autosynth-bigtable c: 37955a9 h: refs/heads/master i: 12875: 57a70ec
1 parent 94d429d commit 5a42df7

2 files changed

Lines changed: 32 additions & 1 deletion

File tree

  • branches/autosynth-bigtable/google-cloud-clients/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/it

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ refs/heads/autosynth-asset: af3772eb76acbfc401f7c3f9310f09f2b0e17602
126126
refs/heads/autosynth-automl: d4315b3596bac160e3439432c54435f44b09953e
127127
refs/heads/autosynth-bigquerydatatransfer: 2a9f3938237f85a8919602d74011326580ff387f
128128
refs/heads/autosynth-bigquerystorage: 99aee05df348f39d98b6fb23c292006f1d2a6c28
129-
refs/heads/autosynth-bigtable: 74a4517cc99b2a3d5c3505baeb607e249f7aab82
129+
refs/heads/autosynth-bigtable: 37955a9bc91b6a17a8ddbbe8369e7f36a799715e
130130
refs/heads/autosynth-bigtable-admin: 6379a2bc712f2736c83de0e009b4d26da4fa82ca
131131
refs/heads/autosynth-containeranalysis: 781fdb430a60f9a6491f116e31e4e10118157bdb
132132
refs/heads/autosynth-datastore: af1fb76aa3eee02fe6f31f8fa1c72a4f048d149b

branches/autosynth-bigtable/google-cloud-clients/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/it/ITPubSubTest.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
package com.google.cloud.pubsub.it;
1818

1919
import static com.google.common.truth.Truth.assertThat;
20+
import static org.junit.Assume.assumeTrue;
2021

22+
import com.google.api.gax.rpc.PermissionDeniedException;
2123
import com.google.auto.value.AutoValue;
2224
import com.google.cloud.ServiceOptions;
2325
import com.google.cloud.pubsub.v1.AckReplyConsumer;
@@ -40,6 +42,7 @@
4042
import java.util.concurrent.BlockingQueue;
4143
import java.util.concurrent.LinkedBlockingQueue;
4244
import java.util.concurrent.TimeUnit;
45+
import junit.framework.Assert;
4346
import org.junit.AfterClass;
4447
import org.junit.BeforeClass;
4548
import org.junit.Rule;
@@ -52,6 +55,9 @@ public class ITPubSubTest {
5255
private static TopicAdminClient topicAdminClient;
5356
private static SubscriptionAdminClient subscriptionAdminClient;
5457
private static String projectId;
58+
private static final boolean IS_VPC_TEST =
59+
System.getenv("GOOGLE_CLOUD_TESTS_IN_VPCSC") != null
60+
&& System.getenv("GOOGLE_CLOUD_TESTS_IN_VPCSC").equalsIgnoreCase("true");
5561

5662
@Rule public Timeout globalTimeout = Timeout.seconds(300);
5763

@@ -107,6 +113,31 @@ public void testTopicPolicy() {
107113
topicAdminClient.deleteTopic(topicName);
108114
}
109115

116+
@Test
117+
public void testVPCPushSubscriber() throws Exception {
118+
assumeTrue(IS_VPC_TEST);
119+
ProjectTopicName topicName =
120+
ProjectTopicName.of(projectId, formatForTest("testing-vpc-push-subscriber-topic"));
121+
ProjectSubscriptionName subscriptionName =
122+
ProjectSubscriptionName.of(
123+
projectId, formatForTest("testing-vpc-push-subscriber-subscription"));
124+
topicAdminClient.createTopic(topicName);
125+
126+
try {
127+
subscriptionAdminClient.createSubscription(
128+
subscriptionName,
129+
topicName,
130+
PushConfig.newBuilder().setPushEndpoint("random_point").build(),
131+
10);
132+
subscriptionAdminClient.deleteSubscription(subscriptionName);
133+
Assert.fail("No exception raised");
134+
} catch (PermissionDeniedException e) {
135+
// expected
136+
}
137+
138+
topicAdminClient.deleteTopic(topicName);
139+
}
140+
110141
@Test
111142
public void testPublishSubscribe() throws Exception {
112143
ProjectTopicName topicName =

0 commit comments

Comments
 (0)