Skip to content

Commit

Permalink
Verify authsource during MongoDB authentication test
Browse files Browse the repository at this point in the history
Relates to
celery@4923175
  • Loading branch information
georgepsarakis authored and auvipy committed May 26, 2019
1 parent 8d77fc9 commit 7eb6e30
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions celery/backends/mongodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,9 @@ def _get_database(self):
conn = self._get_connection()
db = conn[self.database_name]
if self.user and self.password:
source = self.options.get('authsource',
self.database_name or 'admin'
source = self.options.get(
'authsource',
self.database_name or 'admin'
)
if not db.authenticate(self.user, self.password, source=source):
raise ImproperlyConfigured(
Expand Down
3 changes: 2 additions & 1 deletion t/unit/backends/test_mongodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,8 @@ def test_get_database_authfailure(self):
x.password = 'cere4l'
with pytest.raises(ImproperlyConfigured):
x._get_database()
db.authenticate.assert_called_with('jerry', 'cere4l')
db.authenticate.assert_called_with('jerry', 'cere4l',
source=x.database_name)

def test_prepare_client_options(self):
with patch('pymongo.version_tuple', new=(3, 0, 3)):
Expand Down

0 comments on commit 7eb6e30

Please sign in to comment.