Skip to content

Commit 98c8214

Browse files
(PDB-4764) Fixed rubocop complaints
1 parent 807d5b6 commit 98c8214

9 files changed

Lines changed: 101 additions & 103 deletions

File tree

manifests/server/read_database.pp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@
8686

8787
if $postgresql_ssl_on {
8888
$subname = @("EOT"/L)
89-
${subname_default}?\
90-
ssl=true&sslfactory=org.postgresql.ssl.LibPQFactory&\
91-
sslmode=verify-full&sslrootcert=${ssl_ca_cert_path}&\
92-
sslkey=${ssl_key_pk8_path}&sslcert=${ssl_cert_path}\
93-
| EOT
89+
${subname_default}?\
90+
ssl=true&sslfactory=org.postgresql.ssl.LibPQFactory&\
91+
sslmode=verify-full&sslrootcert=${ssl_ca_cert_path}&\
92+
sslkey=${ssl_key_pk8_path}&sslcert=${ssl_cert_path}\
93+
| EOT
9494
} else {
9595
$subname = $subname_default
9696
}

spec/acceptance/basic_spec.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class { 'puppetdb::master::config': puppetdb_port => '8080', puppetdb_server =>
2727

2828
describe 'single node with ssl' do
2929
pp = <<-EOS
30-
class { 'puppetdb': postgresql_ssl_on => true,
30+
class { 'puppetdb': postgresql_ssl_on => true,
3131
database_listen_address => '0.0.0.0',
3232
database_host => $facts['fqdn'],}
3333
EOS
@@ -46,13 +46,12 @@ class { 'puppetdb': postgresql_ssl_on => true,
4646
value => 'random_password',
4747
notify => Service[puppetdb]
4848
}
49-
49+
5050
service { 'puppetdb':
5151
ensure => 'running',
5252
}
5353
EOS
5454
it 'make sure it starts with wrong password' do
55-
5655
apply_manifest(ini_pp, catch_errors: true)
5756
apply_manifest(ini_pp, catch_changes: true)
5857
end

spec/unit/classes/database/ssl_configuration_spec.rb

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,51 +43,51 @@
4343
it 'has server.key file' do
4444
is_expected.to contain_file('postgres private key')
4545
.with(
46-
'ensure' => 'present',
47-
'owner' => 'postgres',
48-
'mode' => '0600',
49-
'path' => "#{datadir_path}/server.key"
46+
ensure: 'present',
47+
owner: 'postgres',
48+
mode: '0600',
49+
path: "#{datadir_path}/server.key",
5050
)
5151
.that_requires('Package[postgresql-server]')
5252
end
5353

5454
it 'has server.crt file' do
5555
is_expected.to contain_file('postgres public key')
5656
.with(
57-
'ensure' => 'present',
58-
'owner' => 'postgres',
59-
'mode' => '0600',
60-
'path' => "#{datadir_path}/server.crt"
57+
ensure: 'present',
58+
owner: 'postgres',
59+
mode: '0600',
60+
path: "#{datadir_path}/server.crt",
6161
)
6262
.that_requires('Package[postgresql-server]')
6363
end
6464

65-
it 'has ssl config attibute' do
65+
it 'has ssl config attribute' do
6666
is_expected.to contain_postgresql__server__config_entry('ssl')
6767
.with_value('on').with_ensure('present')
68-
.that_requires("File[postgres private key]")
69-
.that_requires("File[postgres public key]")
68+
.that_requires('File[postgres private key]')
69+
.that_requires('File[postgres public key]')
7070
end
7171

72-
it 'has ssl_cert_file config attibute' do
72+
it 'has ssl_cert_file config attribute' do
7373
is_expected.to contain_postgresql__server__config_entry('ssl_cert_file')
7474
.with_value("#{datadir_path}/server.crt").with_ensure('present')
75-
.that_requires("File[postgres private key]")
76-
.that_requires("File[postgres public key]")
75+
.that_requires('File[postgres private key]')
76+
.that_requires('File[postgres public key]')
7777
end
7878

79-
it 'has ssl_key_file config attibute' do
79+
it 'has ssl_key_file config attribute' do
8080
is_expected.to contain_postgresql__server__config_entry('ssl_key_file')
8181
.with_value("#{datadir_path}/server.key").with_ensure('present')
82-
.that_requires("File[postgres private key]")
83-
.that_requires("File[postgres public key]")
82+
.that_requires('File[postgres private key]')
83+
.that_requires('File[postgres public key]')
8484
end
8585

86-
it 'has ssl_ca_file config attibute' do
86+
it 'has ssl_ca_file config attribute' do
8787
is_expected.to contain_postgresql__server__config_entry('ssl_ca_file')
8888
.with_value(params[:postgresql_ssl_ca_cert_path]).with_ensure('present')
89-
.that_requires("File[postgres private key]")
90-
.that_requires("File[postgres public key]")
89+
.that_requires('File[postgres private key]')
90+
.that_requires('File[postgres public key]')
9191
end
9292

9393
it 'has hba rule for ipv4' do

spec/unit/classes/init_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,11 @@ class { 'postgresql::server':
7070
context 'when using ssl certificates' do
7171
let(:params) do
7272
{
73-
'postgresql_ssl_on' => true,
73+
postgresql_ssl_on: true,
7474
}
7575
end
7676

7777
it { is_expected.to contain_class('puppetdb::server').with('postgresql_ssl_on' => true) }
78-
7978
it { is_expected.to contain_class('puppetdb::database::postgresql').with('postgresql_ssl_on' => true) }
8079
end
8180
end

spec/unit/classes/server/database_ini_spec.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -461,16 +461,16 @@
461461
it 'configures subname correctly' do
462462
is_expected.to contain_ini_setting('puppetdb_subname')
463463
.with(
464-
'ensure' => 'present',
465-
'path' => '/etc/puppetlabs/puppetdb/conf.d/database.ini',
466-
'section' => 'database',
467-
'setting' => 'subname',
468-
'value' => '//localhost:5432/puppetdb?' \
469-
'ssl=true&sslfactory=org.postgresql.ssl.LibPQFactory&' \
470-
'sslmode=verify-full&' \
471-
'sslrootcert=/etc/puppetlabs/puppetdb/ssl/ca.pem&' \
472-
'sslkey=/tmp/private_key.pk8&' \
473-
'sslcert=/etc/puppetlabs/puppetdb/ssl/public.pem',
464+
ensure: 'present',
465+
path: '/etc/puppetlabs/puppetdb/conf.d/database.ini',
466+
section: 'database',
467+
setting: 'subname',
468+
value: '//localhost:5432/puppetdb?' \
469+
'ssl=true&sslfactory=org.postgresql.ssl.LibPQFactory&' \
470+
'sslmode=verify-full&' \
471+
'sslrootcert=/etc/puppetlabs/puppetdb/ssl/ca.pem&' \
472+
'sslkey=/tmp/private_key.pk8&' \
473+
'sslcert=/etc/puppetlabs/puppetdb/ssl/public.pem',
474474
)
475475
end
476476
end

spec/unit/classes/server/db_connection_uri_spec.rb

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,49 +14,49 @@
1414
describe 'when passing jdbc subparams' do
1515
let(:params) do
1616
{
17-
'jdbc_ssl_properties' => '?ssl=true',
17+
jdbc_ssl_properties: '?ssl=true',
1818
}
1919
end
2020

2121
it {
2222
is_expected.to contain_ini_setting('puppetdb_subname')
2323
.with(
24-
'section' => 'database',
25-
'setting' => 'subname',
26-
'value' => '//localhost:5432/puppetdb?ssl=true',
24+
section: 'database',
25+
setting: 'subname',
26+
value: '//localhost:5432/puppetdb?ssl=true',
2727
)
2828
}
2929
end
3030

3131
describe 'when using ssl communication' do
3232
let(:params) do
3333
{
34-
'postgresql_ssl_on' => true,
35-
'ssl_key_pk8_path' => '/tmp/private_key.pk8',
34+
postgresql_ssl_on: true,
35+
ssl_key_pk8_path: '/tmp/private_key.pk8',
3636
}
3737
end
3838

3939
it 'configures subname correctly' do
4040
is_expected.to contain_ini_setting('puppetdb_subname')
4141
.with(
42-
'ensure' => 'present',
43-
'path' => '/etc/puppetlabs/puppetdb/conf.d/database.ini',
44-
'section' => 'database',
45-
'setting' => 'subname',
46-
'value' => '//localhost:5432/puppetdb?' \
47-
'ssl=true&sslfactory=org.postgresql.ssl.LibPQFactory&' \
48-
'sslmode=verify-full&' \
49-
'sslrootcert=/etc/puppetlabs/puppetdb/ssl/ca.pem&' \
50-
'sslkey=/tmp/private_key.pk8&' \
51-
'sslcert=/etc/puppetlabs/puppetdb/ssl/public.pem',
42+
ensure: 'present',
43+
path: '/etc/puppetlabs/puppetdb/conf.d/database.ini',
44+
section: 'database',
45+
setting: 'subname',
46+
value: '//localhost:5432/puppetdb?' \
47+
'ssl=true&sslfactory=org.postgresql.ssl.LibPQFactory&' \
48+
'sslmode=verify-full&' \
49+
'sslrootcert=/etc/puppetlabs/puppetdb/ssl/ca.pem&' \
50+
'sslkey=/tmp/private_key.pk8&' \
51+
'sslcert=/etc/puppetlabs/puppetdb/ssl/public.pem',
5252
)
5353
end
5454

5555
context 'when setting jdbc_ssl_properties as well' do
5656
let(:params) do
5757
{
58-
'jdbc_ssl_properties' => '?ssl=true',
59-
'postgresql_ssl_on' => true
58+
jdbc_ssl_properties: '?ssl=true',
59+
postgresql_ssl_on: true,
6060
}
6161
end
6262

spec/unit/classes/server/db_read_uri_spec.rb

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,52 +14,52 @@
1414
describe 'when passing jdbc subparams' do
1515
let(:params) do
1616
{
17-
'database_host' => 'localhost',
18-
'jdbc_ssl_properties' => '?ssl=true',
17+
database_host: 'localhost',
18+
jdbc_ssl_properties: '?ssl=true',
1919
}
2020
end
2121

2222
it {
2323
is_expected.to contain_ini_setting('puppetdb_read_subname')
2424
.with(
25-
'section' => 'read-database',
26-
'setting' => 'subname',
27-
'value' => '//localhost:5432/puppetdb?ssl=true',
25+
section: 'read-database',
26+
setting: 'subname',
27+
value: '//localhost:5432/puppetdb?ssl=true',
2828
)
2929
}
3030
end
3131

3232
describe 'when using ssl communication' do
3333
let(:params) do
3434
{
35-
'database_host' => 'cheery-rime.puppetlabs.net',
36-
'postgresql_ssl_on' => true,
37-
'ssl_key_pk8_path' => '/tmp/private_key.pk8',
35+
database_host: 'cheery-rime.puppetlabs.net',
36+
postgresql_ssl_on: true,
37+
ssl_key_pk8_path: '/tmp/private_key.pk8',
3838
}
3939
end
4040

4141
it 'configures subname correctly' do
4242
is_expected.to contain_ini_setting('puppetdb_read_subname')
4343
.with(
44-
'ensure' => 'present',
45-
'path' => '/etc/puppetlabs/puppetdb/conf.d/read_database.ini',
46-
'section' => 'read-database',
47-
'setting' => 'subname',
48-
'value' => '//cheery-rime.puppetlabs.net:5432/puppetdb?' \
49-
'ssl=true&sslfactory=org.postgresql.ssl.LibPQFactory&' \
50-
'sslmode=verify-full&' \
51-
'sslrootcert=/etc/puppetlabs/puppetdb/ssl/ca.pem&' \
52-
'sslkey=/tmp/private_key.pk8&' \
53-
'sslcert=/etc/puppetlabs/puppetdb/ssl/public.pem',
44+
ensure: 'present',
45+
path: '/etc/puppetlabs/puppetdb/conf.d/read_database.ini',
46+
section: 'read-database',
47+
setting: 'subname',
48+
value: '//cheery-rime.puppetlabs.net:5432/puppetdb?' \
49+
'ssl=true&sslfactory=org.postgresql.ssl.LibPQFactory&' \
50+
'sslmode=verify-full&' \
51+
'sslrootcert=/etc/puppetlabs/puppetdb/ssl/ca.pem&' \
52+
'sslkey=/tmp/private_key.pk8&' \
53+
'sslcert=/etc/puppetlabs/puppetdb/ssl/public.pem',
5454
)
5555
end
5656

5757
context 'when setting jdbc_ssl_properties as well' do
5858
let(:params) do
5959
{
60-
'database_host' => 'puppetdb',
61-
'jdbc_ssl_properties' => '?ssl=true',
62-
'postgresql_ssl_on' => true,
60+
database_host: 'puppetdb',
61+
jdbc_ssl_properties: '?ssl=true',
62+
postgresql_ssl_on: true,
6363
}
6464
end
6565

spec/unit/classes/server/read_database_ini_spec.rb

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -128,34 +128,34 @@
128128
context 'when using ssl communication' do
129129
let(:params) do
130130
{
131-
'database_host' => 'puppetdb',
132-
'postgresql_ssl_on' => true,
133-
'ssl_key_pk8_path' => '/tmp/private_key.pk8',
131+
database_host: 'puppetdb',
132+
postgresql_ssl_on: true,
133+
ssl_key_pk8_path: '/tmp/private_key.pk8',
134134
}
135135
end
136136

137137
it 'configures subname correctly' do
138138
is_expected.to contain_ini_setting('puppetdb_read_subname')
139139
.with(
140-
'ensure' => 'present',
141-
'path' => '/etc/puppetlabs/puppetdb/conf.d/read_database.ini',
142-
'section' => 'read-database',
143-
'setting' => 'subname',
144-
'value' => '//puppetdb:5432/puppetdb?' \
145-
'ssl=true&sslfactory=org.postgresql.ssl.LibPQFactory&' \
146-
'sslmode=verify-full&' \
147-
'sslrootcert=/etc/puppetlabs/puppetdb/ssl/ca.pem&' \
148-
'sslkey=/tmp/private_key.pk8&' \
149-
'sslcert=/etc/puppetlabs/puppetdb/ssl/public.pem',
140+
ensure: 'present',
141+
path: '/etc/puppetlabs/puppetdb/conf.d/read_database.ini',
142+
section: 'read-database',
143+
setting: 'subname',
144+
value: '//puppetdb:5432/puppetdb?' \
145+
'ssl=true&sslfactory=org.postgresql.ssl.LibPQFactory&' \
146+
'sslmode=verify-full&' \
147+
'sslrootcert=/etc/puppetlabs/puppetdb/ssl/ca.pem&' \
148+
'sslkey=/tmp/private_key.pk8&' \
149+
'sslcert=/etc/puppetlabs/puppetdb/ssl/public.pem',
150150
)
151151
end
152152

153153
context 'when setting jdbc_ssl_properties as well' do
154154
let(:params) do
155155
{
156-
'database_host' => 'puppetdb',
157-
'jdbc_ssl_properties' => '?ssl=true',
158-
'postgresql_ssl_on' => true
156+
database_host: 'puppetdb',
157+
jdbc_ssl_properties: '?ssl=true',
158+
postgresql_ssl_on: true,
159159
}
160160
end
161161

spec/unit/classes/server_spec.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@
173173
context 'when managing ssl communication' do
174174
let(:params) do
175175
{
176-
'postgresql_ssl_on' => true
176+
postgresql_ssl_on: true,
177177
}
178178
end
179179
let(:key_path) { '/etc/puppetlabs/puppetdb/ssl/private.pem' }
@@ -191,20 +191,20 @@
191191
it 'runs exec command' do
192192
is_expected.to contain_exec(key_pk8_path)
193193
.with(
194-
path: [ '/opt/puppetlabs/puppet/bin', facts[:path] ],
194+
path: ['/opt/puppetlabs/puppet/bin', facts[:path]],
195195
command: "openssl pkcs8 -topk8 -inform PEM -outform DER -in #{key_path} -out #{key_pk8_path} -nocrypt",
196-
onlyif: "test ! -e '#{key_pk8_path}' -o '#{key_pk8_path}' -ot '#{key_path}'",
197-
before: "File[#{key_pk8_path}]"
196+
onlyif: "test ! -e '#{key_pk8_path}' -o '#{key_pk8_path}' -ot '#{key_path}'",
197+
before: "File[#{key_pk8_path}]",
198198
)
199199
end
200200

201201
it 'contains file private.pk8' do
202202
is_expected.to contain_file('/etc/puppetlabs/puppetdb/ssl/private.pk8')
203203
.with(
204-
'ensure' => 'present',
205-
'owner' => 'puppetdb',
206-
'group' => 'puppetdb',
207-
'mode' => '0600',
204+
ensure: 'present',
205+
owner: 'puppetdb',
206+
group: 'puppetdb',
207+
mode: '0600',
208208
)
209209
end
210210
end

0 commit comments

Comments
 (0)