Skip to content

Fix validate_domain_name called without parameters #1351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/puppet/functions/validate_domain_name.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,11 @@
repeated_param 'Variant[Stdlib::Fqdn, Stdlib::Dns::Zone]', :values
end

def validate_domain_name(*_values); end
def validate_domain_name(*args)
assert_arg_count(args)
end

def assert_arg_count(args)
raise(ArgumentError, 'validate_domain_name(): Wrong number of arguments need at least one') if args.empty?
end
end
1 change: 1 addition & 0 deletions spec/functions/validate_domain_name_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
describe 'validate_domain_name' do
describe 'signature validation' do
it { is_expected.not_to eq(nil) }
it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{wrong number of arguments}i) }
end

describe 'valid inputs' do
Expand Down