Skip to content

Commit

Permalink
chore: cleanup header checks to use a common regex when validating he…
Browse files Browse the repository at this point in the history
…aders
  • Loading branch information
ldetmer committed Nov 12, 2024
1 parent 816b160 commit 8882ec3
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -240,22 +240,18 @@ void testHttpJsonCompliance_userApiVersionSetSuccess() throws IOException {

@Test
void testGrpcCall_sendsCorrectApiClientHeader() {
Pattern defautlGrpcHeaderPattern =
Pattern.compile("gl-java/.* gapic/.*?--protobuf-\\d.* gax/.* grpc/.* protobuf/\\d.*");
grpcClient.echo(EchoRequest.newBuilder().build());
String headerValue = grpcInterceptor.metadata.get(API_CLIENT_HEADER_KEY);
assertTrue(defautlGrpcHeaderPattern.matcher(headerValue).matches());
assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern().matcher(headerValue).matches());
}

@Test
void testHttpJson_sendsCorrectApiClientHeader() {
Pattern defautlHttpHeaderPattern =
Pattern.compile("gl-java/.* gapic/.*?--protobuf-\\d.* gax/.* rest/ protobuf/\\d.*");
httpJsonClient.echo(EchoRequest.newBuilder().build());
ArrayList<String> headerValues =
(ArrayList<String>)
httpJsonInterceptor.metadata.getHeaders().get(HTTP_CLIENT_API_HEADER_KEY);
String headerValue = headerValues.get(0);
assertTrue(defautlHttpHeaderPattern.matcher(headerValue).matches());
assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern().matcher(headerValue).matches());
}
}

0 comments on commit 8882ec3

Please sign in to comment.