Skip to content

Commit ca1da97

Browse files
johnfmikhailchingor13
authored andcommitted
---
yaml --- r: 13957 b: refs/heads/autosynth-container c: 37955a9 h: refs/heads/master i: 13955: ff3c4cb
1 parent bd1dd18 commit ca1da97

2 files changed

Lines changed: 32 additions & 1 deletion

File tree

  • branches/autosynth-container/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
@@ -113,7 +113,7 @@ refs/tags/v0.65.0: 10939381ffe0b8da32db4fe3087c86e3aa7f3e55
113113
refs/tags/v0.66.0: ed6a3f57cbdaa20339a1995f7d7d53b172a5b8ef
114114
refs/tags/v0.67.0: 30b56f02092efc6f3c3667650ea8b8825003e0b7
115115
refs/heads/autosynth-compute: 8e86445e504cea6f99b9fb237bfd7f0e5ef8b3ce
116-
refs/heads/autosynth-container: 74a4517cc99b2a3d5c3505baeb607e249f7aab82
116+
refs/heads/autosynth-container: 37955a9bc91b6a17a8ddbbe8369e7f36a799715e
117117
refs/heads/autosynth-dataproc: bc74a8841bc1693d7945d991d15979df550b1fd1
118118
refs/heads/autosynth-monitoring: 120f508e0065f4ce39cf0e6a69a08138773f2cfb
119119
refs/heads/autosynth-pubsub: ed3340e32d13bb1a42ca4431cb1ad9bdaf550aa4

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