Skip to content

Commit 817ddac

Browse files
committed
Stop using legacy facts in tests
1 parent 028f9f7 commit 817ddac

11 files changed

+50
-50
lines changed

spec/classes/foreman_proxy__plugin__container_gateway_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
verify_exact_contents(catalogue, '/etc/foreman-proxy/settings.d/container_gateway.yml', [
1313
'---',
1414
':enabled: https',
15-
":pulp_endpoint: https://#{facts[:fqdn]}",
15+
":pulp_endpoint: https://#{facts[:networking]['fqdn']}",
1616
':sqlite_db_path: /var/lib/foreman-proxy/smart_proxy_container_gateway.db',
1717
':db_connection_string: postgres:///container_gateway'
1818
])

spec/classes/foreman_proxy__plugin__discovery_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
let(:facts) { facts }
77
let(:pre_condition) { 'include foreman_proxy' }
88
let(:tftproot) do
9-
case facts[:osfamily]
9+
case facts[:os]['family']
1010
when 'Debian'
1111
'/srv/tftp'
1212
when 'FreeBSD', 'DragonFly'
@@ -16,15 +16,15 @@
1616
end
1717
end
1818
let(:etc_dir) do
19-
case facts[:osfamily]
19+
case facts[:os]['family']
2020
when 'FreeBSD', 'DragonFly'
2121
'/usr/local/etc'
2222
else
2323
'/etc'
2424
end
2525
end
2626
let(:group) do
27-
case facts[:osfamily]
27+
case facts[:os]['family']
2828
when 'FreeBSD', 'DragonFly'
2929
'foreman_proxy'
3030
else

spec/classes/foreman_proxy__plugin__dynflow_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
context "on #{os}" do
66
let(:facts) { facts }
77
let(:pre_condition) { 'include foreman_proxy' }
8-
let(:etc_dir) { ['FreeBSD', 'DragonFly'].include?(facts[:osfamily]) ? '/usr/local/etc' : '/etc' }
8+
let(:etc_dir) { ['FreeBSD', 'DragonFly'].include?(facts[:os]['family']) ? '/usr/local/etc' : '/etc' }
99

1010
describe 'with default settings' do
1111
it { should compile.with_all_deps }

spec/classes/foreman_proxy__plugin__pulp_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
verify_exact_contents(catalogue, "#{etc_dir}/foreman-proxy/settings.d/pulpcore.yml", [
2121
'---',
2222
':enabled: https',
23-
":pulp_url: https://#{facts[:fqdn]}",
24-
":content_app_url: https://#{facts[:fqdn]}/pulp/content",
23+
":pulp_url: https://#{facts[:networking]['fqdn']}",
24+
":content_app_url: https://#{facts[:networking]['fqdn']}/pulp/content",
2525
':mirror: false',
2626
':client_authentication: ["client_certificate"]',
27-
":rhsm_url: https://#{facts[:fqdn]}/rhsm",
27+
":rhsm_url: https://#{facts[:networking]['fqdn']}/rhsm",
2828
])
2929
end
3030

spec/classes/foreman_proxy__proxydhcp__spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656

5757
it { should_not contain_class('dhcp::failover') }
5858

59-
context "as manager of ACLs for dhcp", unless: ['FreeBSD', 'DragonFly'].include?(os_facts[:osfamily]) do
59+
context "as manager of ACLs for dhcp", unless: ['FreeBSD', 'DragonFly'].include?(os_facts[:os]['family']) do
6060
let(:params) { super().merge(dhcp_manage_acls: true) }
6161

6262
it { is_expected.to contain_class('dhcp').with_conf_dir_mode('0750') }
@@ -67,7 +67,7 @@
6767
end
6868

6969
context "as manager of ACLs for dhcp for RedHat and Debian by default" do
70-
case os_facts[:osfamily]
70+
case os_facts[:os]['family']
7171
when 'RedHat', 'Debian'
7272
it do should contain_exec('Allow foreman-proxy to read /etc/dhcp').
7373
with_command('setfacl -m u:foreman-proxy:rx /etc/dhcp').

spec/classes/foreman_proxy__register__spec.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616

1717
it 'should register the proxy' do
1818
should contain_class('foreman_proxy::register')
19-
should contain_foreman_smartproxy(facts[:fqdn]).with({
19+
should contain_foreman_smartproxy(facts[:networking]['fqdn']).with({
2020
'ensure' => 'present',
21-
'base_url' => "https://#{facts[:fqdn]}",
21+
'base_url' => "https://#{facts[:networking]['fqdn']}",
2222
'effective_user' => 'admin',
23-
'url' => "https://#{facts[:fqdn]}:8443",
23+
'url' => "https://#{facts[:networking]['fqdn']}:8443",
2424
'consumer_key' => /\w+/,
2525
'consumer_secret' => /\w+/,
2626
'ssl_ca' => /\A\/.+\.pem\z/,
@@ -30,9 +30,9 @@
3030
it 'should collect features' do
3131
should contain_datacat_collector('foreman_proxy::enabled_features').with({
3232
'source_key' => 'features',
33-
'target_resource' => "Foreman_smartproxy[#{facts[:fqdn]}]",
33+
'target_resource' => "Foreman_smartproxy[#{facts[:networking]['fqdn']}]",
3434
'target_field' => 'features',
35-
}).that_comes_before("Foreman_smartproxy[#{facts[:fqdn]}]")
35+
}).that_comes_before("Foreman_smartproxy[#{facts[:networking]['fqdn']}]")
3636
end
3737

3838
context 'with datacat provider' do
@@ -44,7 +44,7 @@
4444
before { subject.resource('Datacat_collector[foreman_proxy::enabled_features]').provider.exists? }
4545

4646
it 'should populate features on foreman_smartproxy' do
47-
expect(subject.resource("Foreman_smartproxy[#{facts[:fqdn]}]").parameters[:features].should.sort).to match_array(["Logs", "Puppet", "Puppet CA"])
47+
expect(subject.resource("Foreman_smartproxy[#{facts[:networking]['fqdn']}]").parameters[:features].should.sort).to match_array(["Logs", "Puppet", "Puppet CA"])
4848
end
4949
end
5050
end
@@ -94,7 +94,7 @@
9494
'ensure' => 'present',
9595
'base_url' => 'https://foreman.example.com',
9696
'effective_user' => 'smartproxy',
97-
'url' => "https://#{facts[:fqdn]}:1234",
97+
'url' => "https://#{facts[:networking]['fqdn']}:1234",
9898
'consumer_key' => 'key',
9999
'consumer_secret' => 'secret',
100100
})
@@ -111,7 +111,7 @@
111111

112112
it 'should register the proxy' do
113113
should contain_class('foreman_proxy::register')
114-
should contain_foreman_smartproxy(facts[:fqdn]).with({
114+
should contain_foreman_smartproxy(facts[:networking]['fqdn']).with({
115115
'ensure' => 'present',
116116
'ssl_ca' => '/etc/foreman/ssl/ca.pem',
117117
})
@@ -128,7 +128,7 @@
128128

129129
it 'should register the proxy' do
130130
should contain_class('foreman_proxy::register')
131-
should contain_foreman_smartproxy(facts[:fqdn]).with({
131+
should contain_foreman_smartproxy(facts[:networking]['fqdn']).with({
132132
'ensure' => 'present',
133133
'ssl_ca' => '/etc/foreman/ssl/ca.pem',
134134
})
@@ -142,7 +142,7 @@
142142

143143
it 'should not register the proxy' do
144144
should contain_class('foreman_proxy::register')
145-
should_not contain_foreman_smartproxy(facts[:fqdn])
145+
should_not contain_foreman_smartproxy(facts[:networking]['fqdn'])
146146
should_not contain_datacat_collector('foreman_proxy::enabled_features')
147147
end
148148
end

spec/classes/foreman_proxy__spec.rb

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
let(:facts) { facts }
77
let(:params) { {} }
88

9-
case facts[:osfamily]
9+
case facts[:os]['family']
1010
when 'FreeBSD', 'DragonFly'
1111
dns_group = 'bind'
1212
etc_dir = '/usr/local/etc'
@@ -17,7 +17,7 @@
1717
puppet_path = '/usr/local/bin/puppet'
1818
ssl_dir = '/var/puppet/ssl'
1919
else
20-
dns_group = facts[:osfamily] == 'RedHat' ? 'named' : 'bind'
20+
dns_group = facts[:os]['family'] == 'RedHat' ? 'named' : 'bind'
2121
etc_dir = '/etc'
2222
puppet_etc_dir = "#{etc_dir}/puppetlabs/puppet"
2323
home_dir = '/usr/share/foreman-proxy'
@@ -28,7 +28,7 @@
2828
end
2929

3030
let(:tftp_root) do
31-
case facts[:osfamily]
31+
case facts[:os]['family']
3232
when 'Debian'
3333
'/srv/tftp'
3434
when 'FreeBSD', 'DragonFly'
@@ -128,11 +128,11 @@
128128
'---',
129129
":settings_directory: #{etc_dir}/foreman-proxy/settings.d",
130130
":ssl_ca_file: #{ssl_dir}/certs/ca.pem",
131-
":ssl_certificate: #{ssl_dir}/certs/#{facts[:fqdn]}.pem",
132-
":ssl_private_key: #{ssl_dir}/private_keys/#{facts[:fqdn]}.pem",
131+
":ssl_certificate: #{ssl_dir}/certs/#{facts[:networking]['fqdn']}.pem",
132+
":ssl_private_key: #{ssl_dir}/private_keys/#{facts[:networking]['fqdn']}.pem",
133133
':trusted_hosts:',
134-
" - #{facts[:fqdn]}",
135-
":foreman_url: https://#{facts[:fqdn]}",
134+
" - #{facts[:networking]['fqdn']}",
135+
":foreman_url: https://#{facts[:networking]['fqdn']}",
136136
":bind_host: '#{bind_host}'",
137137
':https_port: 8443',
138138
':log_file: /var/log/foreman-proxy/proxy.log',
@@ -162,7 +162,7 @@
162162
end
163163

164164
it 'should generate correct dns.yml' do
165-
dns_key = case facts[:osfamily]
165+
dns_key = case facts[:os]['family']
166166
when 'Debian'
167167
'/etc/bind/rndc.key'
168168
when 'FreeBSD', 'DragonFly'
@@ -200,7 +200,7 @@
200200
'---',
201201
':dns_server: 127.0.0.1',
202202
":dns_tsig_keytab: #{etc_dir}/foreman-proxy/dns.keytab",
203-
":dns_tsig_principal: foremanproxy/#{facts[:fqdn]}@EXAMPLE.COM",
203+
":dns_tsig_principal: foremanproxy/#{facts[:networking]['fqdn']}@EXAMPLE.COM",
204204
])
205205
end
206206

@@ -214,10 +214,10 @@
214214
it 'should generate correct puppet_proxy_puppet_api.yml' do
215215
verify_exact_contents(catalogue, "#{etc_dir}/foreman-proxy/settings.d/puppet_proxy_puppet_api.yml", [
216216
'---',
217-
":puppet_url: https://#{facts[:fqdn]}:8140",
217+
":puppet_url: https://#{facts[:networking]['fqdn']}:8140",
218218
":puppet_ssl_ca: #{ssl_dir}/certs/ca.pem",
219-
":puppet_ssl_cert: #{ssl_dir}/certs/#{facts[:fqdn]}.pem",
220-
":puppet_ssl_key: #{ssl_dir}/private_keys/#{facts[:fqdn]}.pem",
219+
":puppet_ssl_cert: #{ssl_dir}/certs/#{facts[:networking]['fqdn']}.pem",
220+
":puppet_ssl_key: #{ssl_dir}/private_keys/#{facts[:networking]['fqdn']}.pem",
221221
":api_timeout: 30",
222222
])
223223
end
@@ -234,10 +234,10 @@
234234
it 'should generate correct puppetca_http_api.yml' do
235235
verify_exact_contents(catalogue, "#{etc_dir}/foreman-proxy/settings.d/puppetca_http_api.yml", [
236236
'---',
237-
":puppet_url: https://#{facts[:fqdn]}:8140",
237+
":puppet_url: https://#{facts[:networking]['fqdn']}:8140",
238238
":puppet_ssl_ca: #{ssl_dir}/certs/ca.pem",
239-
":puppet_ssl_cert: #{ssl_dir}/certs/#{facts[:fqdn]}.pem",
240-
":puppet_ssl_key: #{ssl_dir}/private_keys/#{facts[:fqdn]}.pem",
239+
":puppet_ssl_cert: #{ssl_dir}/certs/#{facts[:networking]['fqdn']}.pem",
240+
":puppet_ssl_key: #{ssl_dir}/private_keys/#{facts[:networking]['fqdn']}.pem",
241241
])
242242
end
243243

@@ -300,7 +300,7 @@
300300
verify_exact_contents(catalogue, "#{etc_dir}/foreman-proxy/settings.d/templates.yml", [
301301
'---',
302302
':enabled: false',
303-
":template_url: http://#{facts[:fqdn]}:8000",
303+
":template_url: http://#{facts[:networking]['fqdn']}:8000",
304304
])
305305
end
306306

@@ -595,7 +595,7 @@
595595
let(:facts) { super().merge(ipaddress_eth0: '192.168.0.2', netmask_eth0: '255.255.255.0') }
596596

597597
let(:nsupdate_pkg) do
598-
case facts[:osfamily]
598+
case facts[:os]['family']
599599
when 'RedHat'
600600
'bind-utils'
601601
when 'FreeBSD', 'DragonFly'
@@ -642,7 +642,7 @@
642642
'---',
643643
':dns_server: 127.0.0.1',
644644
":dns_tsig_keytab: #{etc_dir}/foreman-proxy/dns.keytab",
645-
":dns_tsig_principal: foremanproxy/#{facts[:fqdn]}@EXAMPLE.COM",
645+
":dns_tsig_principal: foremanproxy/#{facts[:networking]['fqdn']}@EXAMPLE.COM",
646646
])
647647
end
648648
end
@@ -870,7 +870,7 @@
870870
let(:params) { super().merge(dhcp_interface: 'dhcpif') }
871871
let(:facts) { override_facts(super(), networking: {interfaces: {dhcpif: {ip: '192.0.2.1', network: '192.0.2.0', netmask: '255.255.255.0'}}}) }
872872

873-
case facts[:osfamily]
873+
case facts[:os]['family']
874874
when 'FreeBSD', 'DragonFly'
875875
dhcp_leases = '/var/db/dhcpd/dhcpd.leases'
876876
dhcp_config = "#{etc_dir}/dhcpd.conf"
@@ -998,8 +998,8 @@
998998
should contain_file("#{ssl_dir}").with_group('puppet')
999999
should contain_file("#{ssl_dir}/private_keys").with_group('puppet')
10001000
should contain_file("#{ssl_dir}/certs/ca.pem").with_group('puppet')
1001-
should contain_file("#{ssl_dir}/certs/#{facts[:fqdn]}.pem").with_group('puppet')
1002-
should contain_file("#{ssl_dir}/private_keys/#{facts[:fqdn]}.pem").with_group('puppet')
1001+
should contain_file("#{ssl_dir}/certs/#{facts[:networking]['fqdn']}.pem").with_group('puppet')
1002+
should contain_file("#{ssl_dir}/private_keys/#{facts[:networking]['fqdn']}.pem").with_group('puppet')
10031003
end
10041004

10051005
context 'when puppet group is already being managed' do
@@ -1023,7 +1023,7 @@
10231023
end
10241024
end
10251025

1026-
context 'with foreman::repo included', unless: ['FreeBSD', 'DragonFly'].include?(facts[:operatingsystem]) do
1026+
context 'with foreman::repo included', unless: ['FreeBSD', 'DragonFly'].include?(facts[:os]['family']) do
10271027
let(:pre_condition) do
10281028
<<-PUPPET
10291029
class { 'foreman::repo':

spec/classes/foreman_proxy__tftp__netboot_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
with_ensure('link').with_target("../boot")
1919
end
2020

21-
if facts[:osfamily] == 'Debian'
21+
if facts[:os]['family'] == 'Debian'
2222
it { is_expected.to contain_class('foreman_proxy::tftp::netboot').with_grub_installation_type('debian') }
2323
it { should contain_package('grub-common').with_ensure('installed') }
2424
it { should contain_package('grub-efi-amd64-bin').with_ensure('installed') }
@@ -32,7 +32,7 @@
3232
end
3333
it { should contain_file("/tftproot/grub2/shimx64.efi").with_ensure('link') }
3434
it { should contain_file("/tftproot/grub2/shim.efi").with_ensure('link') }
35-
elsif facts[:osfamily] == 'RedHat'
35+
elsif facts[:os]['family'] == 'RedHat'
3636
it { is_expected.to contain_class('foreman_proxy::tftp::netboot').with_grub_installation_type('redhat') }
3737
it { should contain_package('grub2-efi-x64').with_ensure('installed') }
3838
it { should contain_package('grub2-efi-x64-modules').with_ensure('installed') }

spec/classes/foreman_proxy__tftp_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
it { is_expected.to contain_class('foreman_proxy::tftp::netboot') }
1717

18-
case facts[:osfamily]
18+
case facts[:os]['family']
1919
when 'Debian'
2020
tftp_root = '/srv/tftp'
2121
names = {
@@ -60,7 +60,7 @@
6060

6161
it { is_expected.to contain_class('foreman_proxy::tftp::netboot').with_root(tftp_root) }
6262

63-
case facts[:osfamily]
63+
case facts[:os]['family']
6464
when 'FreeBSD', 'DragonFly'
6565
it { should contain_file("#{tftp_root}/grub2/grub.cfg").with_mode('0644').with_owner('foreman_proxy') }
6666
else

spec/defines/foreman_proxy_plugin_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
context 'no parameters' do
1111
let(:package) do
12-
if facts[:osfamily] == 'Debian'
12+
if facts[:os]['family'] == 'Debian'
1313
'ruby-smart-proxy-myplugin'
1414
else
1515
'rubygem-smart_proxy_myplugin'
@@ -47,7 +47,7 @@
4747
:package => 'my_fun_plugin',
4848
} end
4949

50-
case os_facts[:osfamily]
50+
case os_facts[:os]['family']
5151
when 'Debian'
5252
it 'should use hyphens' do
5353
should contain_package('my-fun-plugin').with_ensure('installed')

0 commit comments

Comments
 (0)