Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use orginal url as audience for self signed jwt if scheme or host is null #642

Merged
merged 4 commits into from Apr 27, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -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 {
Expand Down
Expand Up @@ -181,6 +181,15 @@ public void getUriForSelfSignedJWT() {
assertEquals(expected, ServiceAccountJwtAccessCredentials.getUriForSelfSignedJWT(uri));
}

@Test
public void getUriForSelfSignedJWT_forStaticAudience_returnsURI() {
assertNull(ServiceAccountJwtAccessCredentials.getUriForSelfSignedJWT(null));

URI uri = URI.create("compute.googleapis.com");
URI expected = URI.create("compute.googleapis.com");
assertEquals(expected, ServiceAccountJwtAccessCredentials.getUriForSelfSignedJWT(uri));
}

arithmetic1728 marked this conversation as resolved.
Show resolved Hide resolved
@Test
public void hasRequestMetadata_returnsTrue() throws IOException {
Credentials credentials =
Expand Down