Showing with 44 additions and 6 deletions.
  1. +1 −1 .travis.yml
  2. +8 −0 CHANGELOG.md
  3. +9 −3 lib/puppet/type/yumrepo.rb
  4. +1 −1 metadata.json
  5. +25 −1 spec/unit/type/yumrepo_spec.rb
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cache: bundler
before_install:
- bundle -v
- rm -f Gemfile.lock
- gem update --system $RUBYGEMS_VERSION
- yes | gem update --system $RUBYGEMS_VERSION
- gem --version
- bundle -v
script:
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org).

## [1.0.5](https://github.com/puppetlabs/puppetlabs-yumrepo_core/tree/1.0.5) (2019-12-18)

[Full Changelog](https://github.com/puppetlabs/puppetlabs-yumrepo_core/compare/1.0.4...1.0.5)

### Fixed

- \(MODULES-10246\) Proxy settings allow empty string [\#22](https://github.com/puppetlabs/puppetlabs-yumrepo_core/pull/22) ([Dorin-Pleava](https://github.com/Dorin-Pleava))

## [1.0.4](https://github.com/puppetlabs/puppetlabs-yumrepo_core/tree/1.0.4) (2019-10-31)

[Full Changelog](https://github.com/puppetlabs/puppetlabs-yumrepo_core/compare/1.0.3...1.0.4)
Expand Down
12 changes: 9 additions & 3 deletions lib/puppet/type/yumrepo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -304,19 +304,25 @@

newproperty(:proxy) do
desc "URL of a proxy server that Yum should use when accessing this repository.
This attribute can also be set to `'_none_'`, which will make Yum bypass any
global proxy settings when accessing this repository.
This attribute can also be set to '_none_' (or '' for EL >= 8 only),
which will make Yum bypass any global proxy settings when accessing this repository.
#{ABSENT_DOC}"

newvalues(%r{.*}, :absent)
validate do |value|
next if value.to_s =~ %r{^(absent|_none_)$}
parsed = URI.parse(value)
next if value.to_s.empty? && Facter.value(:operatingsystemmajrelease).to_i >= 8

parsed = URI.parse(value)
unless VALID_SCHEMES.include?(parsed.scheme)
raise _('Must be a valid URL')
end
end

munge do |value|
return '' if Facter.value(:operatingsystemmajrelease).to_i >= 8 && value.to_s == '_none_'
value.to_s
end
end

newproperty(:proxy_username) do
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "puppetlabs-yumrepo_core",
"version": "1.0.4",
"version": "1.0.5",
"author": "puppetlabs",
"summary": "Manage client yum repo configurations by parsing yum INI configuration files.",
"license": "Apache-2.0",
Expand Down
26 changes: 25 additions & 1 deletion spec/unit/type/yumrepo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,37 @@

describe 'proxy' do
it_behaves_like 'a yumrepo parameter that can be absent', :proxy
it_behaves_like 'a yumrepo parameter that accepts a single URL', :proxy

it 'accepts _none_' do
described_class.new(
name: 'puppetlabs',
proxy: '_none_',
)
end
it_behaves_like 'a yumrepo parameter that accepts a single URL', :proxy

it 'accepts an empty string' do
described_class.new(
name: 'puppetlabs',
proxy: '',
)
end

it "munges '_none_' to empty string for EL >= 8" do
Facter.stubs(:value).with(:operatingsystemmajrelease).returns('8')
instance = described_class.new(name: 'puppetlabs', proxy: '_none_')
expect(instance[:proxy]).to eq ''
end

it "does not munges '_none_' to empty string for EL < 8" do
Facter.stubs(:value).with(:operatingsystemmajrelease).returns('7')
instance = described_class.new(name: 'puppetlabs', proxy: '_none_')
expect(instance[:proxy]).to eq '_none_'
end

it 'does not raise any errors' do
expect { described_class.new(name: 'puppetlabs', proxy: '') }.not_to raise_error
end
end

describe 'proxy_username' do
Expand Down