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(NODE-3795): unexpected No auth provider for DEFAULT defined error #3092

Merged
merged 10 commits into from Jan 21, 2022

Conversation

syz99
Copy link
Contributor

@syz99 syz99 commented Jan 5, 2022

Description

Adding test case and fix for a specified authSource but no further credentials provided.
The spec states that authSource can be ignored when no other credentials are given, we have a check that is throwing in this specific scenario because we still have an empty credentials object making it down to the connection creation layer.

What is changing?

This PR removes the credentials from the options object in this specific scenario and tests for it.

Double check the following

  • Ran npm run check:lint script
  • Self-review completed using the steps outlined here
  • PR title follows the correct format: <type>(NODE-xxxx)<!>: <description>
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket

@syz99 syz99 requested a review from nbbeeken January 5, 2022 20:25
@syz99 syz99 self-assigned this Jan 5, 2022
@@ -334,5 +334,19 @@ describe('Connection String', function () {
expect(options).property('credentials').to.equal(credentials);
expect(options).to.have.nested.property('credentials.source', 'admin');
});

it('should retain specified authSource with no provided credentials', async function () {
makeStub('authSource=thisShouldBeAuthSource');
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have a similar test for a non-srv connection string?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

just added + added extra assertions on the DEFAULT mechanism to clearly test the specified error scenario in the ticket

@nbbeeken nbbeeken added the Primary Review In Review with primary reviewer, not yet ready for team's eyes label Jan 6, 2022
@syz99 syz99 marked this pull request as draft January 10, 2022 18:27
@nbbeeken nbbeeken force-pushed the NODE-3795/fix-no-authProvider-for-default-error branch from cc0fdd9 to dbaf782 Compare January 19, 2022 16:20
@nbbeeken nbbeeken marked this pull request as ready for review January 19, 2022 16:20
@dariakp dariakp self-requested a review January 19, 2022 19:35
src/connection_string.ts Show resolved Hide resolved
test/unit/connection_string.test.ts Show resolved Hide resolved
@dariakp dariakp requested a review from nbbeeken January 19, 2022 19:47
@dariakp dariakp dismissed nbbeeken’s stale review January 19, 2022 19:48

Dismissing review since Neal is taking over the implementation

@nbbeeken nbbeeken changed the title test(NODE-3795):add test for 'no auth provider for DEFAULT defined' error fix(NODE-3795):add test for 'no auth provider for DEFAULT defined' error Jan 19, 2022
@nbbeeken nbbeeken changed the title fix(NODE-3795):add test for 'no auth provider for DEFAULT defined' error fix(NODE-3795): unexpected No auth provider for DEFAULT defined error Jan 19, 2022
@nbbeeken nbbeeken requested a review from dariakp January 19, 2022 20:18
Copy link
Contributor

@dariakp dariakp left a comment

Choose a reason for hiding this comment

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

Just a small suggestion because I think the goal of the test, if I understand it, is to make sure that we don't fail in the wrong place, but there's nothing invalid about the setup - we only fail because there isn't a proper server, not because we specified an authSource, right?

test/unit/connection_string.test.ts Outdated Show resolved Hide resolved
@dariakp dariakp added Team Review Needs review from team and removed Primary Review In Review with primary reviewer, not yet ready for team's eyes labels Jan 19, 2022
Co-authored-by: Daria Pardue <daria.pardue@mongodb.com>
dariakp
dariakp previously approved these changes Jan 19, 2022
@dariakp dariakp requested a review from durran January 19, 2022 21:13
@@ -89,6 +94,39 @@ describe('Connection String', function () {
expect(options.credentials.source).to.equal('$external');
});

it('should retain user-specified authSource with no credentials for non-srv URI', function () {
Copy link
Member

Choose a reason for hiding this comment

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

This test is failing on evg as it expects an empty username but the property does not exist.

…hub.com:mongodb/node-mongodb-native into NODE-3795/fix-no-authProvider-for-default-error
test/unit/connection_string.test.ts Outdated Show resolved Hide resolved
@dariakp dariakp merged commit fb38a56 into main Jan 21, 2022
@dariakp dariakp deleted the NODE-3795/fix-no-authProvider-for-default-error branch January 21, 2022 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team Review Needs review from team
Projects
None yet
4 participants