Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a helper method defaultTokenUrlForUniverse to resolve the default token URL based on the universe domain, and updates the Builder constructor to reset tokenUrl to null if it matches the default URL. It also adds comprehensive unit tests to verify this behavior. The review comments correctly identify potential NullPointerException risks if universeDomain is null or if defaultTokenUrlForUniverse returns null during the equality check in the builder.
9d67db5 to
f67d00e
Compare
… toBuilder When cloning an ExternalAccountCredentials instance via toBuilder(), clear tokenUrl if it equals the default STS URL for the credential's current universe domain so build() recomputes https://sts.<universeDomain>/v1/token for the updated universe domain. Non-default custom token URLs and explicit setTokenUrl() overrides on the builder are preserved regardless of setter ordering.
f67d00e to
42390b7
Compare
| // default STS URL for credentials.getUniverseDomain() (from builder defaults or gcloud JSON). | ||
| // Clear tokenUrl to null when it equals that universe default so the configured | ||
| // universeDomain | ||
| // on toBuilder() can recompute it. Any non-default tokenUrl (e.g. mTLS STS or proxy) stays |
There was a problem hiding this comment.
Because defaultTokenUrlForUniverse() only matches the non-mTLS URL, an mTLS credential (https://sts.mtls.googleapis.com/v1/token) gets treated as a custom override and stays pointed at sts.mtls.googleapis.com if someone calls toBuilder().setUniverseDomain(...) without also overriding tokenUrl. Is leaving the mTLS STS URL pinned intentional, or should it also recompute to https://sts.mtls.<universe>/v1/token?
There was a problem hiding this comment.
Since STS is supported in multiple universes, https://sts.mtls.<universe>/v1/token is also valid. I don't think it should be pinned when changing universes.
… cover GDU plain toBuilder().build()
nbayati
left a comment
There was a problem hiding this comment.
LGTM on the changes and test updates. Leaving the mTLS STS endpoint question open while we verify whether non-default universes support it.
Added some new changes. Re-requesting new approval
Updates
ExternalAccountCredentials.Builder(ExternalAccountCredentials)to cleartokenUrlwhen it matches the default STS URL for the credential's current universe domain sotoBuilder().setUniverseDomain(...)recomputes the default STS URL for the updated universe domain. CustomtokenUrlvalues and explicitsetTokenUrl(...)overrides always take precedence over the universe domain default.