Skip to content

Commit 0588fe7

Browse files
authored
Merge pull request #1515 from cruelsmith/fix_role_password_encryption
Fix password_encryption for DBVERSION in server::role
2 parents 55faf08 + b26a4cc commit 0588fe7

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

manifests/server/role.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
$_hash = if $hash {
143143
$hash
144144
} elsif $connect_settings != undef and 'DBVERSION' in $connect_settings {
145-
if (versioncmp($version, '14') >= 0) { 'scram-sha-256' } else { undef }
145+
versioncmp($version, '14') ? { -1 => 'md5', default => 'scram-sha-256' }
146146
} else {
147147
$postgresql::server::password_encryption
148148
}

spec/acceptance/server/role_spec.rb

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# frozen_string_literal: true
2+
3+
require 'spec_helper_acceptance'
4+
5+
describe 'postgresql::server::role' do
6+
let(:user) { 'foo' }
7+
let(:password) { 'bar' }
8+
9+
it 'with different DBVERSION in connect_settings' do
10+
pp_role = <<-MANIFEST
11+
$user = '#{user}'
12+
$password = '#{password}'
13+
14+
class { 'postgresql::server': }
15+
16+
postgresql::server::role { $user:
17+
password_hash => $password,
18+
connect_settings => {
19+
'DBVERSION' => '13',
20+
},
21+
}
22+
MANIFEST
23+
24+
if Gem::Version.new(postgresql_version) >= Gem::Version.new('14')
25+
idempotent_apply(pp_role)
26+
27+
# verify that password_encryption selectio is based on 'DBVERSION' and not on postgresql::serverglobals::version
28+
psql("--command=\"SELECT 1 FROM pg_shadow WHERE usename = '#{user}' AND passwd = 'md596948aad3fcae80c08a35c9b5958cd89'\"") do |r|
29+
expect(r.stdout).to match(%r{\(1 row\)})
30+
expect(r.stderr).to eq('')
31+
end
32+
end
33+
end
34+
end

0 commit comments

Comments
 (0)