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

Fix password_encryption for DBVERSION in server::role #1515

Merged
merged 2 commits into from
Sep 15, 2023
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
2 changes: 1 addition & 1 deletion manifests/server/role.pp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
$_hash = if $hash {
$hash
} elsif $connect_settings != undef and 'DBVERSION' in $connect_settings {
if (versioncmp($version, '14') >= 0) { 'scram-sha-256' } else { undef }
versioncmp($version, '14') ? { -1 => 'md5', default => 'scram-sha-256' }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

derp, I missed that earlier :(

} else {
$postgresql::server::password_encryption
}
Expand Down
34 changes: 34 additions & 0 deletions spec/acceptance/server/role_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# frozen_string_literal: true

require 'spec_helper_acceptance'

describe 'postgresql::server::role' do
let(:user) { 'foo' }
let(:password) { 'bar' }

it 'with different DBVERSION in connect_settings' do
pp_role = <<-MANIFEST
$user = '#{user}'
$password = '#{password}'

class { 'postgresql::server': }

postgresql::server::role { $user:
password_hash => $password,
connect_settings => {
'DBVERSION' => '13',
},
}
MANIFEST

if Gem::Version.new(postgresql_version) >= Gem::Version.new('14')
idempotent_apply(pp_role)

# verify that password_encryption selectio is based on 'DBVERSION' and not on postgresql::serverglobals::version
psql("--command=\"SELECT 1 FROM pg_shadow WHERE usename = '#{user}' AND passwd = 'md596948aad3fcae80c08a35c9b5958cd89'\"") do |r|
expect(r.stdout).to match(%r{\(1 row\)})
expect(r.stderr).to eq('')
end
end
end
end