Skip to content

Commit b76d0f7

Browse files
johnfmikhailchingor13
authored andcommitted
---
yaml --- r: 13019 b: refs/heads/autosynth-securitycenter c: 37955a9 h: refs/heads/master i: 13017: 5fb00c9 13015: 9eef14d
1 parent 3ffd1bf commit b76d0f7

2 files changed

Lines changed: 32 additions & 1 deletion

File tree

  • branches/autosynth-securitycenter/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
@@ -139,7 +139,7 @@ refs/heads/autosynth-language: 8972866b016473559702424205ce5569de47b34d
139139
refs/heads/autosynth-os-login: daa910328b954bbe87068f684a3088ed910f1ddf
140140
refs/heads/autosynth-redis: 4c68cb0fbc599124e717ab3f24bd8a8a5d085ca9
141141
refs/heads/autosynth-scheduler: 2f0fe714a8541dc72f88b45bddd8748e5f21cf29
142-
refs/heads/autosynth-securitycenter: 74a4517cc99b2a3d5c3505baeb607e249f7aab82
142+
refs/heads/autosynth-securitycenter: 37955a9bc91b6a17a8ddbbe8369e7f36a799715e
143143
refs/heads/autosynth-spanner: 1804eb46dd34a05b47163758d376a7fac49188f1
144144
refs/heads/autosynth-speech: 631df42a628621fe42eb4974c9eb725b2fe8e473
145145
refs/heads/autosynth-tasks: afc9f4da54964dea5e7f3a9b164db282fc35db5c

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