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

Authentication fails when not adding database name at the end of uri #35

Closed
StephaneColson opened this issue May 17, 2023 · 3 comments
Closed

Comments

@StephaneColson
Copy link

StephaneColson commented May 17, 2023

Hi,

I have an issue when passing a password with a character '?' needing to be percent encoded (as specified in https://www.mongodb.com/docs/manual/reference/connection-string/)

When using this in cypress.config.ts with escaped '?'

mongodb: {        
	uri: 'mongodb://myLogin:passwd%3F1234@server.interne.fr',
        database: 'mydatabase',
        collection: 'mycollection',
      },

I get error authentication failed when using cy.mindMany

Screenshot 2023-05-17 at 10 08 49

When using this in cypress.config.ts with unescaped '?'

      mongodb: {
        uri: 'mongodb://myLogin:passwd?1234@server.interne.fr',
        database: 'mydatabase',
        collection: 'mycollection',
      },

I get error Password contains unescaped characters when using cy.mindMany

Screenshot 2023-05-17 at 10 12 18

I can connect to the mongodb using Studio 3T with no problem:
Screenshot 2023-05-17 at 10 20 28

Environment:

  • Cypress: 12.8.1
  • cypress-mongodb: 5.3.0
  • TypeScript: 4.9.5
  • mongoDB: 5.0.6

Is escaping of chars in password supported?
Thx

@StephaneColson
Copy link
Author

I finally managed to make it work by adding database name at the end of uri like this

      mongodb: {
        uri: 'mongodb://myLogin:passwd%3F1234@server.interne.fr/mydatabase',
        database: 'mydatabase',
        collection: 'mycollection',
      },

Is it me that missed something in the documentation?

@StephaneColson StephaneColson changed the title Authentication fails when having an encoded character in password Authentication fails when not adding database name at the end of uri May 19, 2023
@Zaista
Copy link
Owner

Zaista commented May 23, 2023

Hi, I do not think you did anything wrong, I'll have to investigate. Thank you for posting a workaround in the meantime

@StephaneColson
Copy link
Author

I don't know (neither understand) why, but it's working without the workaround. Maybe that the mongodb configuration (or version) changed.
So this ticket can be closed.

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

No branches or pull requests

2 participants