Skip to content
Permalink
Browse files
fix: use orginal url as audience for self signed jwt if scheme or hos…
…t is null (#642)
  • Loading branch information
arithmetic1728 committed Apr 27, 2021
1 parent 07d6cbc commit b4e6f1a0bd17dd31edc85ed4879cea75857fd747
@@ -339,7 +339,7 @@ public boolean hasRequestMetadataOnly() {
*/
@VisibleForTesting
static URI getUriForSelfSignedJWT(URI uri) {
if (uri == null) {
if (uri == null || uri.getScheme() == null || uri.getHost() == null) {
return uri;
}
try {
@@ -181,6 +181,20 @@ public void getUriForSelfSignedJWT() {
assertEquals(expected, ServiceAccountJwtAccessCredentials.getUriForSelfSignedJWT(uri));
}

@Test
public void getUriForSelfSignedJWT_noHost() {
URI uri = URI.create("file:foo");
URI expected = URI.create("file:foo");
assertEquals(expected, ServiceAccountJwtAccessCredentials.getUriForSelfSignedJWT(uri));
}

@Test
public void getUriForSelfSignedJWT_forStaticAudience_returnsURI() {
URI uri = URI.create("compute.googleapis.com");
URI expected = URI.create("compute.googleapis.com");
assertEquals(expected, ServiceAccountJwtAccessCredentials.getUriForSelfSignedJWT(uri));
}

@Test
public void hasRequestMetadata_returnsTrue() throws IOException {
Credentials credentials =

0 comments on commit b4e6f1a

Please sign in to comment.