Skip to content

Commit 67f007d

Browse files
committed
simplify tests
1 parent 15e2618 commit 67f007d

File tree

1 file changed

+0
-35
lines changed

1 file changed

+0
-35
lines changed

default/serverspec/postgresql_spec.rb

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -37,104 +37,71 @@
3737
postgres_config_file = "#{config_path}/postgresql.conf"
3838
psql_command = "sudo -u postgres -i PGPASSWORD='#{ENV['PGPASSWORD']}' psql"
3939

40-
4140
describe command('sudo -i psql -V') do
4241
its(:stdout) { should_not match(/RC/) }
4342
its(:stdout) { should_not match(/DEVEL/) }
4443
its(:stdout) { should_not match(/BETA/) }
4544
end
4645

47-
4846
describe command("ps aux | grep #{task_name} | grep -v grep | wc -l") do
4947
its(:stdout) { should match(/^1/) }
5048
end
5149

5250
describe 'Checking Postgres-databases for risky entries' do
5351

54-
5552
describe command("#{psql_command} -d postgres -c \"SELECT count (*) FROM pg_language WHERE lanpltrusted = 'f' AND lanname!='internal' AND lanname!='c';\" | tail -n3 | head -n1 | tr -d ' '") do
5653
its(:stdout) { should match(/^0/) }
5754
end
5855

59-
6056
describe command("#{psql_command} -d postgres -c \"SELECT * FROM pg_shadow WHERE passwd IS NULL;\" | tail -n2 | head -n1 | cut -d '(' -f2 | cut -d ' ' -f1") do
6157
its(:stdout) { should match(/^0/) }
6258
end
6359

64-
6560
describe command("#{psql_command} -d psql -d postgres -c \"SELECT passwd FROM pg_shadow;\" | tail -n+3 | head -n-2 | grep -v \"md5\" -c") do
6661
its(:stdout) { should match(/^0/) }
6762
end
6863

69-
7064
describe command("#{psql_command} -d postgres -c \"SELECT rolname,rolsuper,rolcreaterole,rolcreatedb FROM pg_roles WHERE rolsuper IS TRUE OR rolcreaterole IS TRUE or rolcreatedb IS TRUE;\" | tail -n+3 | head -n-2 | wc -l") do
7165
its(:stdout) { should match(/^1/) }
7266
end
7367

74-
7568
describe command("#{psql_command} -d postgres -c \"\\dp pg_catalog.pg_authid\" | grep pg_catalog | wc -l") do
7669
its(:stdout) { should match(/^1/) }
7770
end
78-
7971
end
8072

81-
8273
describe 'Postgres FS-permissions' do
83-
8474
describe command("sudo find #{postgres_home} -user #{user_name} -group #{user_name} -perm /go=rwx | wc -l") do
8575
its(:stdout) { should match(/^0/) }
8676
end
87-
8877
end
8978

9079
describe 'Parsing configfiles' do
9180

92-
9381
describe file(postgres_config_file) do
9482
its(:content) { should match_key_value('ssl', 'off') }
95-
end
96-
97-
98-
describe file(postgres_config_file) do
9983
its(:content) { should match_key_value('ssl_ciphers', "'ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH'") }
100-
end
101-
102-
103-
describe file(postgres_config_file) do
10484
its(:content) { should match_key_value('password_encryption', 'on') }
10585
end
10686

107-
10887
describe 'require MD5 for ALL users, peers in pg_hba.conf' do
109-
11088
describe file(hba_config_file) do
11189
its(:content) { should match(/local\s.*?all\s.*?all\s.*?md5/) }
112-
end
113-
114-
describe file(hba_config_file) do
11590
its(:content) { should match(%r{/host\s.*?all\s.*?all\s.*?127.0.0.1\/32\s.*?md5/}) }
116-
end
117-
118-
describe file(hba_config_file) do
11991
its(:content) { should match(%r{/host\s.*?all\s.*?all\s.*?::1\/128\s.*?md5/}) }
12092
end
12193

122-
12394
# We accept one peer and one ident for now (chef automation)
124-
12595
describe command("sudo -i cat #{hba_config_file} | egrep 'peer|ident' | wc -l") do
12696
its(:stdout) { should match(/^[2|1]/) }
12797
end
12898

12999
describe command("sudo -i cat #{hba_config_file} | egrep 'trust|password|crypt' | wc -l") do
130100
its(:stdout) { should match(/^0/) }
131101
end
132-
133102
end
134103

135-
136104
describe 'System Monitoring' do
137-
138105
describe file(postgres_config_file) do
139106
its(:content) { should match_key_value('logging_collector', 'on') }
140107
its(:content) { should match(/log_directory\s.*?pg_log/) } # match pg_log and 'pg_log'
@@ -144,7 +111,5 @@
144111
its(:content) { should match_key_value('log_hostname', 'on') }
145112
its(:content) { should match_key_value('log_line_prefix', "'%t %u %d %h'") }
146113
end
147-
148114
end
149-
150115
end

0 commit comments

Comments
 (0)