-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refs #37604 - Normalize DNS forwarders to an array
Previously the documentation showed an example that abused an internal implementation detail that's no longer allowed with the stricter input validation.
- Loading branch information
Showing
4 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
config/foreman-proxy-content.migrations/240715095211-normalize-dns-forwarders.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# forwarders was always an array, but previously it was documented as | ||
# --foreman-proxy-dns-forwarders "192.0.2.1; 192.0.2.2" | ||
fp_mod = answers['foreman_proxy'] | ||
if fp_mod.is_a?(Hash) && fp_mod['forwarders'] | ||
fp_mod['forwarders'] = fp_mod['forwarders'].flat_map do |forwarder| | ||
forwarder.split(';').map(&:strip) | ||
end | ||
end |
8 changes: 8 additions & 0 deletions
8
config/foreman.migrations/20240715095211_normalize_dns_forwarders.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# forwarders was always an array, but previously it was documented as | ||
# --foreman-proxy-dns-forwarders "192.0.2.1; 192.0.2.2" | ||
fp_mod = answers['foreman_proxy'] | ||
if fp_mod.is_a?(Hash) && fp_mod['forwarders'] | ||
fp_mod['forwarders'] = fp_mod['forwarders'].flat_map do |forwarder| | ||
forwarder.split(';').map(&:strip) | ||
end | ||
end |
8 changes: 8 additions & 0 deletions
8
config/katello.migrations/240715095211-normalize-dns-forwarders.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# forwarders was always an array, but previously it was documented as | ||
# --foreman-proxy-dns-forwarders "192.0.2.1; 192.0.2.2" | ||
fp_mod = answers['foreman_proxy'] | ||
if fp_mod.is_a?(Hash) && fp_mod['forwarders'] | ||
fp_mod['forwarders'] = fp_mod['forwarders'].flat_map do |forwarder| | ||
forwarder.split(';').map(&:strip) | ||
end | ||
end |
33 changes: 33 additions & 0 deletions
33
spec/migrations/20240715095211_normalize_dns_forwarders_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
require 'spec_helper' | ||
|
||
migration '20240715095211_normalize_dns_forwarders' do | ||
scenarios %w[foreman katello foreman-proxy-content] do | ||
context 'valid array' do | ||
let(:answers) do | ||
{ | ||
'foreman_proxy' => { | ||
'forwarders' => ['192.0.2.1', '192.0.2.2'], | ||
}, | ||
} | ||
end | ||
|
||
it 'leaves the answers untouched' do | ||
expect(migrated_answers['foreman_proxy']['forwarders']).to eq(['192.0.2.1', '192.0.2.2']) | ||
end | ||
end | ||
|
||
context 'semicolon separated value' do | ||
let(:answers) do | ||
{ | ||
'foreman_proxy' => { | ||
'forwarders' => ['192.0.2.1; 192.0.2.2'], | ||
}, | ||
} | ||
end | ||
|
||
it 'leaves the answers untouched' do | ||
expect(migrated_answers['foreman_proxy']['forwarders']).to eq(['192.0.2.1', '192.0.2.2']) | ||
end | ||
end | ||
end | ||
end |