Skip to content
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

Add mongo 5.0 debian / ubuntu apt key #615

Merged
merged 1 commit into from
Oct 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/puppet/provider/mongodb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,13 @@ def self.mongo_4?
def mongo_4?
self.class.mongo_4?
end

def self.mongo_5?
v = mongo_version
!v[%r{^5\.}].nil?
end

def mongo_5?
self.class.mongo_5?
end
end
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 @@ -61,7 +61,7 @@ def create
digestPassword: false
}

if mongo_4?
if mongo_4? || mongo_5?
# SCRAM-SHA-256 requires digestPassword to be true.
command[:mechanisms] = ['SCRAM-SHA-1']
end
Expand Down
1 change: 1 addition & 0 deletions manifests/repo.pp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
default => undef
}
$key = "${mongover[0]}.${mongover[1]}" ? {
'5.0' => 'F5679A222C647C87527C2F8CB00A0BD1E2C63C11',
'4.4' => '20691EEC35216C63CAF66CE1656408E390CFB1F5',
'4.2' => 'E162F504A20CDF15827F718D4B7C549A058F8B6B',
'4.0' => '9DA31620334BD75D9DCB49F368818C72E52529D4',
Expand Down
30 changes: 30 additions & 0 deletions spec/unit/puppet/provider/mongodb_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
require 'spec_helper'

require 'puppet/provider/mongodb'

provider_class = Puppet::Provider::Mongodb
describe provider_class do
before do
# Clear the cached version before each test
provider_class.remove_instance_variable(:@mongo_version) \
if provider_class.instance_variable_defined?(:@mongo_version)
end

describe 'mongo version detection' do
v = {
'2.6.x' => { '26' => true, '4' => false, '5' => false },
'4.x.x' => { '26' => false, '4' => true, '5' => false },
'5.x.x' => { '26' => false, '4' => false, '5' => true },
'x.x.x' => { '26' => false, '4' => false, '5' => false }
}

v.each do |key, results|
it "version detection for [#{key}]" do
allow(provider_class).to receive(:mongo_eval).with('db.version()').and_return(key)
expect(provider_class.mongo_26?).to be results['26']
expect(provider_class.mongo_4?).to be results['4']
expect(provider_class.mongo_5?).to be results['5']
end
end
end
end