Context:

EmbeddedMongoAutoConfiguration

I'm trying to setup embedded-mongo using authentication on integration tests. As I have some custom mongodb configuration using authentication and would like not to change them in order to use embedded-mongo, it would be nice if the Spring Auto Configuration could handle authentication. It looks like someone filled a PR on embedded-mongo repository in order to provide authentication setup

Proposal:

As of the PR, you should notice that they've included a Map<String, String> params(); on their IMongodConfig, therefore it could be a property params on Spring's EmbeddedMongoProperties. Doing so, settings spring.mongodb.embedded.params.UserName and spring.mongodb.embedded.params.Password should enable Mongo's --auth mode.

Comment From: ashastr

Hi, I would be glad to work on this issue.

Comment From: snicoll

@anandshah123 thank you!

Comment From: ashastr

@p1Machado @snicoll Looks like passing the username and password in the params is not enabling the Auth mode. I looked into the source code of embedded mongo repo and what I have found out so far is, Auth mode is disabled by default in the MongoCmdOptionsBuilder and enableAuth() method to set the auth mode is never used. Please let me know if I am missing something.

I have made a work in progress commit, which has failing tests. Error message: "BadValue: Illegal --setParameter parameter: "Password"".

Comment From: Lacritz

@anandshastri1990 I've added a request on de.flapdoodle.embed.mongo (issue-link) Probably they are adding a proper way to activate the --auth programmatically.

Comment From: SeifMostafa

Hello, Any help?

Comment From: somayaj

hi, what's the status on this? Can it be worked on?

Comment From: snicoll

Thanks for asking @somayaj. The issue is already assigned but we haven't heard from them in a while. @anandshastri1990 how is it going?

Comment From: ashastr

@snicoll if you see the comment from @Lacritz the fix has to happen on "de.flapdoodle.embed.mongo" side. Looks like that's still open: https://github.com/flapdoodle-oss/de.flapdoodle.embed.mongo/issues/311

Once that fix is done, I can push the necessary changes needed on Spring boot side.

Comment From: snicoll

I missed that @anandshastri1990, thank you very much. I am going to add the blocked label to make that a bit more obvious.

Comment From: wilkinsona

These days, we generally recommend the use of Testcontainers for managing services needed for integration testing rather than bespoke service-specific projects. Furthermore, the embedded Mongo issue is still open so there's nothing we can do here anyway.