Skip to content

chore: Add test for non-2xx responses from idTokenWithAudience calls#1656

Merged
lqiu96 merged 7 commits intomainfrom
fix-parsing-token
Feb 7, 2025
Merged

chore: Add test for non-2xx responses from idTokenWithAudience calls#1656
lqiu96 merged 7 commits intomainfrom
fix-parsing-token

Conversation

@lqiu96
Copy link
Copy Markdown
Member

@lqiu96 lqiu96 commented Feb 4, 2025

I believe the issue that was reported in #1027 was actually resolved in #1636.

This PR is to add more tests to ensure that receiving non-2xx status codes back from the idTokenWithAudience are correctly caught.

Fixes #1027

@lqiu96 lqiu96 requested a review from zhumin8 February 4, 2025 22:25
@product-auto-label product-auto-label bot added the size: m Pull request size is medium. label Feb 4, 2025
@lqiu96 lqiu96 marked this pull request as ready for review February 5, 2025 16:43
@lqiu96 lqiu96 requested review from a team February 5, 2025 16:43
public void idTokenWithAudience_oauthEndpoint_non2XXStatusCode() throws IOException {
String universeDomain = "test.com";
MockTokenServerTransportFactory transportFactory = new MockTokenServerTransportFactory();
transportFactory.transport.setError(new IOException("404 Not Found"));
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TokenServerTransportFactory sets an error response with setError(IOException). This could be refactored in the future to be similar to below .addStatusCodeAndMessage(HttpStatusCodes.STATUS_CODE_NOT_FOUND, "Not Found");.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Feb 6, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
E Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@lqiu96 lqiu96 merged commit ee98666 into main Feb 7, 2025
@lqiu96 lqiu96 deleted the fix-parsing-token branch February 7, 2025 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: m Pull request size is medium.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IllegalArgumentException when parsing token

3 participants