Skip to content

Commit 8882ec3

Browse files
committed
chore: cleanup header checks to use a common regex when validating headers
1 parent 816b160 commit 8882ec3

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITVersionHeaders.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,22 +240,18 @@ void testHttpJsonCompliance_userApiVersionSetSuccess() throws IOException {
240240

241241
@Test
242242
void testGrpcCall_sendsCorrectApiClientHeader() {
243-
Pattern defautlGrpcHeaderPattern =
244-
Pattern.compile("gl-java/.* gapic/.*?--protobuf-\\d.* gax/.* grpc/.* protobuf/\\d.*");
245243
grpcClient.echo(EchoRequest.newBuilder().build());
246244
String headerValue = grpcInterceptor.metadata.get(API_CLIENT_HEADER_KEY);
247-
assertTrue(defautlGrpcHeaderPattern.matcher(headerValue).matches());
245+
assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern().matcher(headerValue).matches());
248246
}
249247

250248
@Test
251249
void testHttpJson_sendsCorrectApiClientHeader() {
252-
Pattern defautlHttpHeaderPattern =
253-
Pattern.compile("gl-java/.* gapic/.*?--protobuf-\\d.* gax/.* rest/ protobuf/\\d.*");
254250
httpJsonClient.echo(EchoRequest.newBuilder().build());
255251
ArrayList<String> headerValues =
256252
(ArrayList<String>)
257253
httpJsonInterceptor.metadata.getHeaders().get(HTTP_CLIENT_API_HEADER_KEY);
258254
String headerValue = headerValues.get(0);
259-
assertTrue(defautlHttpHeaderPattern.matcher(headerValue).matches());
255+
assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern().matcher(headerValue).matches());
260256
}
261257
}

0 commit comments

Comments
 (0)