Skip to content

[IAC-1735] Fix test suite #1291

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

Merged
merged 2 commits into from
Aug 16, 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
8 changes: 4 additions & 4 deletions spec/unit/classes/server/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
end

it 'has SELinux port defined' do
is_expected.to contain_package('policycoreutils-python') .with(ensure: 'present')
is_expected.to contain_package('policycoreutils-python').with(ensure: 'installed')

is_expected.to contain_exec('/usr/sbin/semanage port -a -t postgresql_port_t -p tcp 5432')
.with(unless: '/usr/sbin/semanage port -l | grep -qw 5432')
Expand Down Expand Up @@ -141,7 +141,7 @@ class { 'postgresql::server': }
end

it 'has SELinux port defined' do
is_expected.to contain_package('policycoreutils-python-utils') .with(ensure: 'present')
is_expected.to contain_package('policycoreutils-python-utils').with(ensure: 'installed')

is_expected.to contain_exec('/usr/sbin/semanage port -a -t postgresql_port_t -p tcp 5432')
.with(unless: '/usr/sbin/semanage port -l | grep -qw 5432')
Expand Down Expand Up @@ -214,7 +214,7 @@ class { 'postgresql::server': }
end

it 'has SELinux port defined' do
is_expected.to contain_package('policycoreutils-python-utils') .with(ensure: 'present')
is_expected.to contain_package('policycoreutils-python-utils').with(ensure: 'installed')

is_expected.to contain_exec('/usr/sbin/semanage port -a -t postgresql_port_t -p tcp 5432')
.with(unless: '/usr/sbin/semanage port -l | grep -qw 5432')
Expand Down Expand Up @@ -282,7 +282,7 @@ class { 'postgresql::server': }
end

it 'has SELinux port defined' do
is_expected.to contain_package('policycoreutils') .with(ensure: 'present')
is_expected.to contain_package('policycoreutils').with(ensure: 'installed')

is_expected.to contain_exec('/usr/sbin/semanage port -a -t postgresql_port_t -p tcp 5432')
.with(unless: '/usr/sbin/semanage port -l | grep -qw 5432')
Expand Down
71 changes: 29 additions & 42 deletions spec/unit/defines/server/default_privileges_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

require 'spec_helper'
require 'spec_helper_acceptance'

describe 'postgresql::server::default_privileges', type: :define do
let :facts do
Expand Down Expand Up @@ -65,13 +64,11 @@
"class {'postgresql::server':}"
end

if Gem::Version.new(postgresql_version) >= Gem::Version.new('9.6')
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_postgresql__server__default_privileges('test') }
it do
is_expected.to contain_postgresql_psql('default_privileges:test')
.with_command('ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO "test"')
end
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_postgresql__server__default_privileges('test') }
it do
is_expected.to contain_postgresql_psql('default_privileges:test')
.with_command('ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO "test"')
end
end

Expand All @@ -90,9 +87,7 @@
"class {'postgresql::server':}"
end

if Gem::Version.new(postgresql_version) >= Gem::Version.new('9.6')
it { is_expected.to compile.and_raise_error(%r{parameter 'object_type' expects a match for Pattern}) }
end
it { is_expected.to compile.and_raise_error(%r{parameter 'object_type' expects a match for Pattern}) }
end
end

Expand All @@ -111,16 +106,14 @@
"class {'postgresql::server':}"
end

if Gem::Version.new(postgresql_version) >= Gem::Version.new('9.6')
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_postgresql__server__default_privileges('test') }
it do
# rubocop:disable Layout/LineLength
is_expected.to contain_postgresql_psql('default_privileges:test')
.with_command('ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO "test"')
.with_unless("SELECT 1 WHERE EXISTS (SELECT * FROM pg_default_acl AS da JOIN pg_namespace AS n ON da.defaclnamespace = n.oid WHERE 'test=arwdDxt' = ANY (defaclacl) AND nspname = 'public' and defaclobjtype = 'r')")
# rubocop:enable Layout/LineLength
end
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_postgresql__server__default_privileges('test') }
it do
# rubocop:disable Layout/LineLength
is_expected.to contain_postgresql_psql('default_privileges:test')
.with_command('ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO "test"')
.with_unless("SELECT 1 WHERE EXISTS (SELECT * FROM pg_default_acl AS da JOIN pg_namespace AS n ON da.defaclnamespace = n.oid WHERE 'test=arwdDxt' = ANY (defaclacl) AND nspname = 'public' and defaclobjtype = 'r')")
# rubocop:enable Layout/LineLength
end
end

Expand All @@ -138,9 +131,7 @@
"class {'postgresql::server':}"
end

if Gem::Version.new(postgresql_version) >= Gem::Version.new('9.6')
it { is_expected.to compile.and_raise_error(%r{Illegal value for \$privilege parameter}) }
end
it { is_expected.to compile.and_raise_error(%r{Illegal value for \$privilege parameter}) }
end
end

Expand Down Expand Up @@ -225,16 +216,14 @@
"class {'postgresql::server':}"
end

if Gem::Version.new(postgresql_version) >= Gem::Version.new('9.6')
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_postgresql__server__default_privileges('test') }
it do
# rubocop:disable Layout/LineLength
is_expected.to contain_postgresql_psql('default_privileges:test')
.with_command('ALTER DEFAULT PRIVILEGES IN SCHEMA my_schema GRANT ALL ON TABLES TO "test"')
.with_unless("SELECT 1 WHERE EXISTS (SELECT * FROM pg_default_acl AS da JOIN pg_namespace AS n ON da.defaclnamespace = n.oid WHERE 'test=arwdDxt' = ANY (defaclacl) AND nspname = 'my_schema' and defaclobjtype = 'r')")
# rubocop:enable Layout/LineLength
end
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_postgresql__server__default_privileges('test') }
it do
# rubocop:disable Layout/LineLength
is_expected.to contain_postgresql_psql('default_privileges:test')
.with_command('ALTER DEFAULT PRIVILEGES IN SCHEMA my_schema GRANT ALL ON TABLES TO "test"')
.with_unless("SELECT 1 WHERE EXISTS (SELECT * FROM pg_default_acl AS da JOIN pg_namespace AS n ON da.defaclnamespace = n.oid WHERE 'test=arwdDxt' = ANY (defaclacl) AND nspname = 'my_schema' and defaclobjtype = 'r')")
# rubocop:enable Layout/LineLength
end
end

Expand All @@ -255,14 +244,12 @@ class {'postgresql::server':}
EOS
end

if Gem::Version.new(postgresql_version) >= Gem::Version.new('9.6')
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_postgresql__server__default_privileges('test') }
it { is_expected.to contain_postgresql__server__role('test') }
it do
is_expected.to contain_postgresql_psql('default_privileges:test') \
.that_requires(['Service[postgresqld]', 'Postgresql::Server::Role[test]'])
end
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_postgresql__server__default_privileges('test') }
it { is_expected.to contain_postgresql__server__role('test') }
it do
is_expected.to contain_postgresql_psql('default_privileges:test') \
.that_requires(['Service[postgresqld]', 'Postgresql::Server::Role[test]'])
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/unit/defines/server/extension_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

it {
is_expected.to contain_package('postgis')
.with(ensure: 'present', name: 'postgis').that_comes_before('Postgresql_psql[template_postgis: CREATE EXTENSION "postgis"]')
.with(ensure: 'installed', name: 'postgis').that_comes_before('Postgresql_psql[template_postgis: CREATE EXTENSION "postgis"]')
}
end

Expand Down Expand Up @@ -86,7 +86,7 @@

it {
is_expected.to contain_package('postgis')
.with(ensure: 'present', name: 'postgis').that_requires('Postgresql_psql[template_postgis: DROP EXTENSION "postgis"]')
.with(ensure: 'installed', name: 'postgis').that_requires('Postgresql_psql[template_postgis: DROP EXTENSION "postgis"]')
}
end
end
Expand Down