-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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 mongo connections #63053
Merged
Merged
Fix mongo connections #63053
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
75c8a9b
Add mongo.uri to mongo ext_pillar and remove depr. pymongo function
genaumann e6e86e3
Add mongo.uri to docs
genaumann 4f70f7f
Remove depr. pymongo function from mongo returner
genaumann 8b12157
Add testcases for mongo ext_pillar and returner
genaumann 61f9254
Add changelog for 63058
genaumann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Fix mongo authentication for mongo ext_pillar and mongo returner | ||
|
||
This fix also include the ability to use the mongo connection string for mongo ext_pillar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import pytest | ||
|
||
import salt.exceptions | ||
import salt.pillar.mongo as mongo | ||
from tests.support.mock import patch | ||
|
||
|
||
@pytest.fixture | ||
def configure_loader_modules(): | ||
|
||
return { | ||
mongo: { | ||
"__opts__": { | ||
"mongo.uri": "mongodb://root:pass@localhost27017/salt?authSource=admin" | ||
} | ||
} | ||
} | ||
|
||
|
||
def test_config_exception(): | ||
opts = { | ||
"mongo.host": "localhost", | ||
"mongo.port": 27017, | ||
"mongo.user": "root", | ||
"mongo.password": "pass", | ||
"mongo.uri": "mongodb://root:pass@localhost27017/salt?authSource=admin", | ||
} | ||
with patch.dict(mongo.__opts__, opts): | ||
with pytest.raises(salt.exceptions.SaltConfigurationError): | ||
mongo.ext_pillar("minion1", {}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import pytest | ||
|
||
import salt.exceptions | ||
import salt.returners.mongo_future_return as mongo | ||
from tests.support.mock import patch | ||
|
||
|
||
@pytest.fixture | ||
def configure_loader_modules(): | ||
|
||
return { | ||
mongo: { | ||
"__opts__": { | ||
"mongo.uri": "mongodb://root:pass@localhost27017/salt?authSource=admin" | ||
} | ||
} | ||
} | ||
|
||
|
||
@patch("salt.returners.mongo_future_return.PYMONGO_VERSION", "4.3.2", create=True) | ||
def test_config_exception(): | ||
opts = { | ||
"mongo.host": "localhost", | ||
"mongo.port": 27017, | ||
"mongo.user": "root", | ||
"mongo.password": "pass", | ||
"mongo.uri": "mongodb://root:pass@localhost27017/salt?authSource=admin", | ||
} | ||
with patch.dict(mongo.__opts__, opts): | ||
with pytest.raises(salt.exceptions.SaltConfigurationError): | ||
mongo.returner({}) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need the username and password for the above client declarations? Line 177 here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, otherwise pymongo throws the following exception:
pymongo.errors.OperationFailure: command insert requires authentication, full error: {'ok': 0.0, 'errmsg': 'command insert requires authentication', 'code': 13, 'codeName': 'Unauthorized'}