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

Added retry logic for authentication with Okta #1661

Closed
wants to merge 11 commits into from

Conversation

sfc-gh-ext-simba-jf
Copy link
Collaborator

Overview

SNOW-916942

Pre-review self checklist

  • PR branch is updated with all the changes from master branch
  • The code is correctly formatted (run mvn -P check-style validate)
  • New public API is not unnecessary exposed (run mvn verify and inspect target/japicmp/japicmp.html)
  • The pull request name is prefixed with SNOW-XXXX:

External contributors - please answer these questions before submitting a pull request. Thanks!

  1. What GitHub issue is this PR addressing? Make sure that there is an accompanying issue to your PR.

Fixes https://github.com/snowflakedb/snowflake-sdks-drivers-issues-teamwork/issues/652

  1. Fill out the following pre-review checklist:

    • I am adding a new automated test(s) to verify correctness of my new code
    • I am adding new logging messages
    • I am modifying authorization mechanisms
    • I am adding new credentials
    • I am modifying OCSP code
    • I am adding a new dependency or upgrading an existing one
    • I am adding new public/protected component not marked with @SnowflakeJdbcInternalApi (note that public/protected methods/fields in classes marked with this annotation are already internal)
  2. Please describe how your code solves the related issue.

    Added logic to get a new unique token when retrying with Okta

@sfc-gh-ext-simba-jf sfc-gh-ext-simba-jf requested a review from a team as a code owner March 7, 2024 11:00
SFLoginInput loginInput = createOktaLoginInput();
Map<SFSessionProperty, Object> connectionPropertiesMap = initConnectionPropertiesMap();
SnowflakeSQLException ex =
new SnowflakeSQLException(ErrorCode.AUTHENTICATOR_REQUEST_TIMEOUT, 0, true, 0);
Copy link
Collaborator

Choose a reason for hiding this comment

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

this exception is thrown when timeouts are reached - what about testing 429 error code? I think that there should be a test with NETWORK_ERROR and code 429 thrown during execution

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Everything around checking retry related to the 429 error code happens within RestRequest.execute(). When it detects a 429 error code it eventually throws the AUTHENTICATOR_REQUEST_TIMEOUT here which is what we're testing for in this case. I've tried to see if I could set up the test to show the whole flow from a 429 error being thrown then eventually leading to getting a new Okta token, but the mocking set up gets very quickly complicated because of the level of mocks you need to set up. So what I've done instead is I've added a new test in RestRequestTest to show that it throws the AUTHENTICATOR_REQUEST_TIMEOUT when it encounters a 429 error.

Does that seem like enough test support?

@github-actions github-actions bot locked and limited conversation to collaborators Apr 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants