Skip to content

Commit

Permalink
Merge pull request #1405 from puppetlabs/unwrap-sensitive-values-for-…
Browse files Browse the repository at this point in the history
…testing
  • Loading branch information
smortex authored Jul 10, 2023
2 parents 11a4d35 + df215b2 commit 2bab88a
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions spec/defines/server/role_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@

it 'has create role for "test" user with password as ****' do
expect(subject).to contain_postgresql_psql('CREATE ROLE test ENCRYPTED PASSWORD ****')
.with('command' => 'Sensitive [value redacted]',
.with('command' => sensitive(%(CREATE ROLE "test" ENCRYPTED PASSWORD 'new-pa$s' LOGIN NOCREATEROLE NOCREATEDB NOSUPERUSER CONNECTION LIMIT -1)),
'sensitive' => 'true',
'unless' => "SELECT 1 FROM pg_roles WHERE rolname = 'test'",
'port' => '5432')
end

it 'has alter role for "test" user with password as ****' do
expect(subject).to contain_postgresql_psql('ALTER ROLE test ENCRYPTED PASSWORD ****')
.with('command' => 'Sensitive [value redacted]',
.with('command' => sensitive(%(ALTER ROLE "test" ENCRYPTED PASSWORD 'md5b6f7fcbbabb4befde4588a26c1cfd2fa')),
'sensitive' => 'true',
'unless' => 'Sensitive [value redacted]',
'unless' => sensitive(%(SELECT 1 FROM pg_shadow WHERE usename = 'test' AND passwd = 'md5b6f7fcbbabb4befde4588a26c1cfd2fa')),
'port' => '5432')
end
end
Expand All @@ -50,17 +50,19 @@

it 'has create role for "test" user with password as ****' do
expect(subject).to contain_postgresql_psql('CREATE ROLE test ENCRYPTED PASSWORD ****')
.with('command' => 'Sensitive [value redacted]',
.with('command' => sensitive(%(CREATE ROLE "test" ENCRYPTED PASSWORD 'new-pa$s' LOGIN NOCREATEROLE NOCREATEDB NOSUPERUSER CONNECTION LIMIT -1)),
'sensitive' => 'true',
'unless' => "SELECT 1 FROM pg_roles WHERE rolname = 'test'",
'port' => '5432')
end

it 'has alter role for "test" user with password as ****' do
expect(subject).to contain_postgresql_psql('ALTER ROLE test ENCRYPTED PASSWORD ****')
.with('command' => 'Sensitive [value redacted]',
.with('command' => sensitive(%(ALTER ROLE "test" ENCRYPTED PASSWORD 'Sensitive [value redacted]')),
# FIXME: This is obviously wrong ^^^^^^^^^^^^^^^^^^^^^^^^^^
'sensitive' => 'true',
'unless' => 'Sensitive [value redacted]',
'unless' => sensitive(%(SELECT 1 FROM pg_shadow WHERE usename = 'test' AND passwd = 'Sensitive [value redacted]')),
# FIXME: This is obviously wrong ^^^^^^^^^^^^^^^^^^^^^^^^^^
'port' => '5432')
end
end
Expand All @@ -84,7 +86,7 @@

it 'has create role for "test" user with password as ****' do
expect(subject).to contain_postgresql_psql('CREATE ROLE test ENCRYPTED PASSWORD ****')
.with_command('Sensitive [value redacted]')
.with_command(sensitive(%(CREATE ROLE "test" ENCRYPTED PASSWORD 'new-pa$s' LOGIN NOCREATEROLE NOCREATEDB NOSUPERUSER CONNECTION LIMIT -1)))
.with_sensitive('true')
.with_unless("SELECT 1 FROM pg_roles WHERE rolname = 'test'")
.with_port(5432)
Expand All @@ -94,8 +96,8 @@

it 'has alter role for "test" user with password as ****' do
expect(subject).to contain_postgresql_psql('ALTER ROLE test ENCRYPTED PASSWORD ****')
.with('command' => 'Sensitive [value redacted]', 'sensitive' => 'true',
'unless' => 'Sensitive [value redacted]', 'port' => '5432',
.with('command' => sensitive(%(ALTER ROLE "test" ENCRYPTED PASSWORD 'md5b6f7fcbbabb4befde4588a26c1cfd2fa')), 'sensitive' => 'true',
'unless' => sensitive(%(SELECT 1 FROM pg_shadow WHERE usename = 'test' AND passwd = 'md5b6f7fcbbabb4befde4588a26c1cfd2fa')), 'port' => '5432',
'connect_settings' => { 'PGHOST' => 'postgres-db-server', 'DBVERSION' => '9.1',
'PGUSER' => 'login-user', 'PGPASSWORD' => 'login-pass' })
end
Expand All @@ -121,16 +123,16 @@

it 'has create role for "test" user with password as ****' do
expect(subject).to contain_postgresql_psql('CREATE ROLE test ENCRYPTED PASSWORD ****')
.with('command' => 'Sensitive [value redacted]',
.with('command' => sensitive(%(CREATE ROLE "test" ENCRYPTED PASSWORD 'new-pa$s' LOGIN NOCREATEROLE NOCREATEDB NOSUPERUSER CONNECTION LIMIT -1)),
'sensitive' => 'true', 'unless' => "SELECT 1 FROM pg_roles WHERE rolname = 'test'",
'connect_settings' => { 'PGHOST' => 'postgres-db-server', 'DBVERSION' => '9.1',
'PGPORT' => '1234', 'PGUSER' => 'login-user', 'PGPASSWORD' => 'login-pass' })
end

it 'has alter role for "test" user with password as ****' do
expect(subject).to contain_postgresql_psql('ALTER ROLE test ENCRYPTED PASSWORD ****')
.with('command' => 'Sensitive [value redacted]', 'sensitive' => 'true',
'unless' => 'Sensitive [value redacted]',
.with('command' => sensitive(%(ALTER ROLE "test" ENCRYPTED PASSWORD 'md5b6f7fcbbabb4befde4588a26c1cfd2fa')), 'sensitive' => 'true',
'unless' => sensitive(%(SELECT 1 FROM pg_shadow WHERE usename = 'test' AND passwd = 'md5b6f7fcbbabb4befde4588a26c1cfd2fa')),
'connect_settings' => { 'PGHOST' => 'postgres-db-server', 'DBVERSION' => '9.1',
'PGPORT' => '1234', 'PGUSER' => 'login-user', 'PGPASSWORD' => 'login-pass' })
end
Expand Down

0 comments on commit 2bab88a

Please sign in to comment.