Skip to content

Commit aaf7d02

Browse files
committed
Fix validate_domain_name called without parameters
In #1345, the validate_domain_name() function was rewritten to the Puppet 4.x syntax, but the behaviour was slightly changed since we previously did not allow passing no parameter at all. Add code to assert as least one paramatter is passed to restore the previous behavior and raise an error when called without parameter.
1 parent a3abe3d commit aaf7d02

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Diff for: lib/puppet/functions/validate_domain_name.rb

+7-1
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,11 @@
2424
repeated_param 'Variant[Stdlib::Fqdn, Stdlib::Dns::Zone]', :values
2525
end
2626

27-
def validate_domain_name(*_values); end
27+
def validate_domain_name(*args)
28+
assert_arg_count(args)
29+
end
30+
31+
def assert_arg_count(args)
32+
raise(ArgumentError, 'validate_domain_name(): Wrong number of arguments need at least one') if args.empty?
33+
end
2834
end

Diff for: spec/functions/validate_domain_name_spec.rb

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
describe 'validate_domain_name' do
66
describe 'signature validation' do
77
it { is_expected.not_to eq(nil) }
8+
it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{wrong number of arguments}i) }
89
end
910

1011
describe 'valid inputs' do

0 commit comments

Comments
 (0)