Skip to content

Commit acbc51c

Browse files
johnfmikhailchingor13
authored andcommitted
---
yaml --- r: 16327 b: refs/heads/autosynth-iot c: 37955a9 h: refs/heads/master i: 16325: 74e870c 16323: fd72bfe 16319: 21a9d39
1 parent bab813e commit acbc51c

2 files changed

Lines changed: 32 additions & 1 deletion

File tree

  • branches/autosynth-iot/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
@@ -133,7 +133,7 @@ refs/heads/autosynth-datastore: 9acd400b484d6691a080c9152a331d88d24fefc1
133133
refs/heads/autosynth-dialogflow: d7477419376eac9b6dcc7dbcede581152527351d
134134
refs/heads/autosynth-errorreporting: 9891e73a56af7c097829ca7a521b0e862ba6af30
135135
refs/heads/autosynth-firestore: ddb29f8ee445a938fc40be8227dea87b3f508ab3
136-
refs/heads/autosynth-iot: 74a4517cc99b2a3d5c3505baeb607e249f7aab82
136+
refs/heads/autosynth-iot: 37955a9bc91b6a17a8ddbbe8369e7f36a799715e
137137
refs/heads/autosynth-kms: dcc6e15d68759010c8735cc868135bd7e6c1cc5f
138138
refs/heads/autosynth-language: 8972866b016473559702424205ce5569de47b34d
139139
refs/heads/autosynth-os-login: daa910328b954bbe87068f684a3088ed910f1ddf

branches/autosynth-iot/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)