Skip to content

Commit 8008e96

Browse files
committed
(MODULES-10357) Fix proxy => absent
The provider is expecting `absent` to be a symbol. From https://puppet.com/docs/puppet/latest/custom_types.html > The default munge method converts any values that are specifically allowed into symbols. If you override either of these methods, note that you lose this value handling and symbol conversion, which you’ll have to call super for.
1 parent e502b63 commit 8008e96

File tree

3 files changed

+65
-6
lines changed

3 files changed

+65
-6
lines changed

lib/puppet/type/yumrepo.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@
321321

322322
munge do |value|
323323
return '' if Facter.value(:operatingsystemmajrelease).to_i >= 8 && value.to_s == '_none_'
324-
value.to_s
324+
super(value)
325325
end
326326
end
327327

spec/acceptance/tests/yumrepo_spec.rb

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,5 +90,65 @@ def resource(host, type, name)
9090
assert_match(res['descr'], 'Puppet Labs Products El 7 - $basearch')
9191
end
9292
end
93+
94+
describe '`proxy` property' do
95+
context 'when set to a URL' do
96+
it 'applies idempotently' do
97+
pp = <<-MANIFEST
98+
yumrepo {'proxied-repo':
99+
baseurl => 'http://myownmirror',
100+
proxy => 'http://proxy.example.com:3128',
101+
}
102+
MANIFEST
103+
104+
apply_manifest(pp, catch_failures: true)
105+
apply_manifest(pp, catch_changes: true)
106+
end
107+
108+
describe file('/etc/yum.repos.d/proxied-repo.repo') do
109+
its(:content) { is_expected.to contain('proxy=http://proxy.example.com:3128') }
110+
end
111+
end
112+
context 'when set to `absent`' do
113+
it 'applies idempotently' do
114+
pp = <<-MANIFEST
115+
yumrepo {'proxied-repo':
116+
baseurl => 'http://myownmirror',
117+
proxy => absent,
118+
}
119+
MANIFEST
120+
121+
apply_manifest(pp, catch_failures: true)
122+
apply_manifest(pp, catch_changes: true)
123+
end
124+
125+
describe file('/etc/yum.repos.d/proxied-repo.repo') do
126+
its(:content) { is_expected.not_to contain('proxy') }
127+
end
128+
end
129+
context 'when set to `_none_`' do
130+
it 'applies idempotently' do
131+
pp = <<-MANIFEST
132+
yumrepo {'proxied-repo':
133+
baseurl => 'http://myownmirror',
134+
proxy => '_none_',
135+
}
136+
MANIFEST
137+
138+
apply_manifest(pp, catch_failures: true)
139+
apply_manifest(pp, catch_changes: true)
140+
end
141+
142+
if fact('os.release.major') == '8'
143+
describe file('/etc/yum.repos.d/proxied-repo.repo') do
144+
its(:content) { is_expected.to match(%r{^proxy=$}) }
145+
end
146+
else
147+
describe file('/etc/yum.repos.d/proxied-repo.repo') do
148+
its(:content) { is_expected.to match(%r{^proxy=_none_$}) }
149+
end
150+
end
151+
end
152+
end
93153
end
94154
end

spec/spec_helper_acceptance.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44

55
$LOAD_PATH << File.join(__dir__, 'acceptance/lib')
66

7+
run_puppet_install_helper unless ENV['BEAKER_provision'] == 'no'
8+
79
RSpec.configure do |c|
810
c.before :suite do
9-
unless ENV['BEAKER_provision'] == 'no'
10-
run_puppet_install_helper
11-
install_module_on(hosts)
12-
install_module_dependencies_on(hosts)
13-
end
11+
install_module
12+
install_module_dependencies
1413
end
1514
end

0 commit comments

Comments
 (0)