diff --git a/lib/puppet/provider/mongodb_user/mongodb.rb b/lib/puppet/provider/mongodb_user/mongodb.rb index 07762fd57..513169e26 100644 --- a/lib/puppet/provider/mongodb_user/mongodb.rb +++ b/lib/puppet/provider/mongodb_user/mongodb.rb @@ -103,6 +103,7 @@ def password_hash=(_value) pwd: @resource[:password_hash], digestPassword: false } + command[:mechanisms] = @resource[:auth_mechanism] == :scram_sha_1 ? ['SCRAM-SHA-1'] : ['SCRAM-SHA-256'] mongo_eval("db.runCommand(#{command.to_json})", @resource[:database]) else diff --git a/spec/unit/puppet/provider/mongodb_user/mongodb_spec.rb b/spec/unit/puppet/provider/mongodb_user/mongodb_spec.rb index 197605108..677db7e00 100644 --- a/spec/unit/puppet/provider/mongodb_user/mongodb_spec.rb +++ b/spec/unit/puppet/provider/mongodb_user/mongodb_spec.rb @@ -93,7 +93,8 @@ { "updateUser":"new_user", "pwd":"pass", - "digestPassword":false + "digestPassword":false, + "mechanisms":["SCRAM-SHA-1"] } EOS allow(provider).to receive(:mongo_eval).