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

allow auth option #1529

Merged
merged 7 commits into from
Aug 2, 2017
Merged

allow auth option #1529

merged 7 commits into from
Aug 2, 2017

Conversation

vkarpov15
Copy link
Contributor

Based on my reading of url_parser.js looks like there's no reason why auth isn't a supported option. Having support for this option would be very helpful for issues like Automattic/mongoose#5419, otherwise we'd have to mutate the user-provided URI or ask users to not use those options anymore.

@mbroadst
Copy link
Member

mbroadst commented Jul 10, 2017

@vkarpov15 looks like this breaks all the builds! In my recent commit I did support merging user-provided options with the dbOptions, but not generically with the parsed object - this might be why this is failing?

@vkarpov15
Copy link
Contributor Author

Funny, the tests did pass locally for me. I'll debug in a bit but I'm curious about your recent commit. Is there already a way to pass username and password with options rather than through URI? That's all I want to get out of this PR, there's just no documentation on how to do so.

@mbroadst
Copy link
Member

mbroadst commented Jul 10, 2017

@yeah, that commit explicitly resolved this ticket: https://jira.mongodb.org/browse/NODE-1052. We were documenting that we supported readPreference, but not actually doing so. To that end, I'm fine with supporting user provided overrides for options supported in the URI, I just want to be very careful about (as I'm sure you know this is error prone).

There is not currently a way to do what you're asking for here, I think you'd have to assign the returned object, but I haven't looked too deep into this.

@vkarpov15
Copy link
Contributor Author

I took a closer look and haven't been able to figure out why my tests succeed locally but fail on travis. Any hints on how I might be able to repro test failures locally or fix the issue that's causing the tests to fail?

@mbroadst
Copy link
Member

@vkarpov15 truly bizarre. I have the same experience on my mac, as well as a number of linux VMs.. I put together a variant of your test, just copying and pasting the whole test with a few replacements and it worked that way: https://travis-ci.org/mongodb/node-mongodb-native/builds/252444817

Sorry for the trouble, but we're in the process of heavily grooming the tests for the driver right now. One of our interns is writing a mocha compat layer right now, so we'll be switching away from integra and hopefully catching a lot of small issues in the process.

@mbroadst
Copy link
Member

@vkarpov15 also, I modified the actual test as follows:

      var opts = { auth: { user: user, password: password } };
      connect(configuration.url('baduser', 'badpassword'), opts, connectionTester(test, 'testConnectGoodAuthWithOptions', function(db) {
        db.close();
        test.done();
      }));

The original way you were testing was with configuration.url(user, password) overridden with the same values - not sure there was much value to testing that

@mbroadst
Copy link
Member

@vkarpov15 would you mind refactoring the tests to reflect the changes I suggested? We can merge this as soon as it passes CI

@vkarpov15
Copy link
Contributor Author

@mbroadst so I made those changes and a few more, but still have not been able to figure out why auth fails on travis but not locally. I added a print statement and it looks like the _finalOptions that MongoClient passes down are identical, even on travis, but auth still fails for the latter. Do you have any other suggestions?

Also, I'm gonna be in NYC later this week, we should grab a coffee. Shoot me an email, [email protected].

@mbroadst
Copy link
Member

mbroadst commented Aug 1, 2017

@vkarpov15 sorry for the trouble, I think this is related to some problems with integra. The change I was referring to is generally encapsulated in this commit. Specifically, I think what you haven't tried yet is fully splitting the tests into two separate test cases, rather than using asOption(). I'm hoping our switch over to mocha will remedy these types of problems, thanks for the patience in the meantime.

@vkarpov15
Copy link
Contributor Author

Thanks for the suggestion, looks like the tests passed ☝️ what a weird issue 🤕

@mbroadst
Copy link
Member

mbroadst commented Aug 2, 2017

@vkarpov15 hooray 🎉

@mbroadst mbroadst merged commit fd686d7 into mongodb:2.2 Aug 2, 2017
@vkarpov15
Copy link
Contributor Author

🎉 any ETA on the next release?

@vkarpov15 vkarpov15 deleted the feat-allow-auth-option branch August 2, 2017 21:42
@mbroadst
Copy link
Member

mbroadst commented Aug 2, 2017

@vkarpov15 I'll be releasing 2.2.31 by EOW, just want to provide a little more time for some potential fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants