Skip to content

Commit

Permalink
Add mechanism (default SHA1) to password_hash command
Browse files Browse the repository at this point in the history
According the ussie voxpupuli#649, the module ignore changes in passwrd hashes.
Add the mechanism parameter to the password_hash command
Changed unit test to mongodb_user due to new expected line generated for
password_hash command.
  • Loading branch information
Aleksandr Makhov committed Oct 27, 2022
1 parent d46d3ef commit 6d3cc73
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/puppet/provider/mongodb_user/mongodb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def password_hash=(_value)
pwd: @resource[:password_hash],
digestPassword: false
}
command[:mechanisms] = ['SCRAM-SHA-1']
command[:mechanisms] = @resource[:auth_mechanism] == :scram_sha_1 ? ['SCRAM-SHA-1'] : ['SCRAM-SHA-256']

mongo_eval("db.runCommand(#{command.to_json})", @resource[:database])
else
Expand Down
3 changes: 2 additions & 1 deletion spec/unit/puppet/provider/mongodb_user/mongodb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@
{
"updateUser":"new_user",
"pwd":"pass",
"digestPassword":false
"digestPassword":false,
"mechanisms":["SCRAM-SHA-1"]
}
EOS
allow(provider).to receive(:mongo_eval).
Expand Down

0 comments on commit 6d3cc73

Please sign in to comment.