Skip to content

Commit 9bbc75d

Browse files
lunajrqchingor13
authored andcommitted
---
yaml --- r: 33723 b: refs/heads/autosynth-redis c: 720d901 h: refs/heads/master i: 33721: 675baaa 33719: 14198e6
1 parent 7d5ffdc commit 9bbc75d

3 files changed

Lines changed: 224 additions & 1 deletion

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ refs/heads/autosynth-iot: 044be280805a59e06d09658688c9ee474a9815ad
135135
refs/heads/autosynth-kms: d31449d6621a50fb16a4bef4f30f0f3051d27d7c
136136
refs/heads/autosynth-language: 6130869312f99a1e7d3aa0485759172a23333cc5
137137
refs/heads/autosynth-os-login: 49028d40ac477fca5f948cc5a3ce7422729fdb67
138-
refs/heads/autosynth-redis: 6b9f0b2cb37d5427135451d3e8cac357c55e83cb
138+
refs/heads/autosynth-redis: 720d90171cd515c21a21f9f8f17d638ff67ec09c
139139
refs/heads/autosynth-scheduler: 57f9fdb1e7de30c85f4ec7198931a07f50603e55
140140
refs/heads/autosynth-spanner: de02ca32edea133b68b51052e325359a3704b5d2
141141
refs/heads/autosynth-speech: 64692f6db11364f663921be02c08072b966b6e7b
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
/*
2+
* Copyright 2019 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.cloud.trace.v1;
18+
19+
import com.google.api.gax.rpc.PermissionDeniedException;
20+
import com.google.devtools.cloudtrace.v1.Traces;
21+
import org.junit.Assert;
22+
import org.junit.Assume;
23+
import org.junit.BeforeClass;
24+
import org.junit.Test;
25+
26+
@javax.annotation.Generated("by Google")
27+
public class VPCServiceControlTest {
28+
private abstract class Delay {
29+
public abstract void eval();
30+
}
31+
32+
private static boolean isRejected(Delay delayed) {
33+
try {
34+
delayed.eval();
35+
} catch (PermissionDeniedException e) {
36+
return e.getMessage().contains("Request is prohibited by organization's policy");
37+
} catch (Exception e) {
38+
}
39+
return false;
40+
}
41+
42+
static final String PROJECT_OUTSIDE =
43+
System.getenv("GOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_PROJECT");
44+
static final String PROJECT_INSIDE = System.getenv("PROJECT_ID");
45+
static final String IS_INSIDE_VPCSC = System.getenv("GOOGLE_CLOUD_TESTS_IN_VPCSC");
46+
47+
@BeforeClass
48+
public static void setUpClass() {
49+
Assume.assumeTrue(
50+
"GOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_PROJECT environment variable needs to be set to a GCP project that is outside the VPC perimeter",
51+
PROJECT_OUTSIDE != null && !PROJECT_OUTSIDE.isEmpty());
52+
Assume.assumeTrue(
53+
"PROJECT_ID environment variable needs to be set to a GCP project that is inside the VPC perimeter",
54+
PROJECT_INSIDE != null && !PROJECT_INSIDE.isEmpty());
55+
}
56+
57+
@Test
58+
@SuppressWarnings("all")
59+
public void listTracesTest() throws Exception {
60+
final TraceServiceClient client = TraceServiceClient.create();
61+
Delay delayedInside =
62+
new Delay() {
63+
@Override
64+
public void eval() {
65+
client.listTraces(PROJECT_INSIDE);
66+
}
67+
};
68+
69+
Delay delayedOutside =
70+
new Delay() {
71+
@Override
72+
public void eval() {
73+
client.listTraces(PROJECT_OUTSIDE);
74+
}
75+
};
76+
77+
Assert.assertTrue(!isRejected(delayedInside));
78+
Assert.assertTrue(isRejected(delayedOutside));
79+
80+
client.close();
81+
}
82+
83+
@Test
84+
@SuppressWarnings("all")
85+
public void getTraceTest() throws Exception {
86+
final TraceServiceClient client = TraceServiceClient.create();
87+
Delay delayedInside =
88+
new Delay() {
89+
@Override
90+
public void eval() {
91+
client.getTrace(PROJECT_INSIDE, "");
92+
}
93+
};
94+
95+
Delay delayedOutside =
96+
new Delay() {
97+
@Override
98+
public void eval() {
99+
client.getTrace(PROJECT_OUTSIDE, "");
100+
}
101+
};
102+
103+
Assert.assertTrue(!isRejected(delayedInside));
104+
Assert.assertTrue(isRejected(delayedOutside));
105+
106+
client.close();
107+
}
108+
109+
@Test
110+
@SuppressWarnings("all")
111+
public void patchTracesTest() throws Exception {
112+
final TraceServiceClient client = TraceServiceClient.create();
113+
final Traces traces = Traces.newBuilder().build();
114+
115+
Delay delayedInside =
116+
new Delay() {
117+
@Override
118+
public void eval() {
119+
client.patchTraces(PROJECT_INSIDE, traces);
120+
}
121+
};
122+
123+
Delay delayedOutside =
124+
new Delay() {
125+
@Override
126+
public void eval() {
127+
client.patchTraces(PROJECT_OUTSIDE, traces);
128+
}
129+
};
130+
131+
Assert.assertTrue(!isRejected(delayedInside));
132+
Assert.assertTrue(isRejected(delayedOutside));
133+
134+
client.close();
135+
}
136+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
* Copyright 2019 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.cloud.trace.v2;
18+
19+
import com.google.api.gax.rpc.PermissionDeniedException;
20+
import com.google.devtools.cloudtrace.v2.*;
21+
import java.util.ArrayList;
22+
import java.util.List;
23+
import org.junit.Assert;
24+
import org.junit.Assume;
25+
import org.junit.BeforeClass;
26+
import org.junit.Test;
27+
28+
@javax.annotation.Generated("by Google")
29+
public class VPCServiceControlTest {
30+
private abstract class Delay {
31+
public abstract void eval();
32+
}
33+
34+
private static boolean isRejected(Delay delayed) {
35+
try {
36+
delayed.eval();
37+
} catch (PermissionDeniedException e) {
38+
return e.getMessage().contains("Request is prohibited by organization's policy");
39+
} catch (Exception e) {
40+
}
41+
return false;
42+
}
43+
44+
static final String PROJECT_OUTSIDE =
45+
System.getenv("GOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_PROJECT");
46+
static final String PROJECT_INSIDE = System.getenv("PROJECT_ID");
47+
static final String IS_INSIDE_VPCSC = System.getenv("GOOGLE_CLOUD_TESTS_IN_VPCSC");
48+
49+
@BeforeClass
50+
public static void setUpClass() {
51+
Assume.assumeTrue(
52+
"GOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_PROJECT environment variable needs to be set to a GCP project that is outside the VPC perimeter",
53+
PROJECT_OUTSIDE != null && !PROJECT_OUTSIDE.isEmpty());
54+
Assume.assumeTrue(
55+
"PROJECT_ID environment variable needs to be set to a GCP project that is inside the VPC perimeter",
56+
PROJECT_INSIDE != null && !PROJECT_INSIDE.isEmpty());
57+
}
58+
59+
@Test
60+
@SuppressWarnings("all")
61+
public void patchTracesTest() throws Exception {
62+
final TraceServiceClient client = TraceServiceClient.create();
63+
final List<Span> spans = new ArrayList<>();
64+
spans.add(Span.newBuilder().build());
65+
66+
Delay delayedInside =
67+
new Delay() {
68+
@Override
69+
public void eval() {
70+
client.batchWriteSpans(PROJECT_INSIDE, spans);
71+
}
72+
};
73+
74+
Delay delayedOutside =
75+
new Delay() {
76+
@Override
77+
public void eval() {
78+
client.batchWriteSpans(PROJECT_OUTSIDE, spans);
79+
}
80+
};
81+
82+
Assert.assertTrue(!isRejected(delayedInside));
83+
Assert.assertTrue(isRejected(delayedOutside));
84+
85+
client.close();
86+
}
87+
}

0 commit comments

Comments
 (0)