Skip to content

Commit

Permalink
Merge pull request #615 from xepa/issue.upstream#614
Browse files Browse the repository at this point in the history
Add mongo 5.0 debian / ubuntu apt key
  • Loading branch information
bastelfreak authored Oct 21, 2021
2 parents 7ded295 + 9e5c471 commit 61b00f2
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 1 deletion.
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

0 comments on commit 61b00f2

Please sign in to comment.