Project

General

Profile

« Previous | Next » 

Revision 45b8161d

Added by Daniel Lobato GarcĂ­a over 7 years ago

Fixes #17631 - Validate puppetrun and realm providers

This commit adds checks for the puppetrun/realms providers so that they
have to be compliant with a certain regex in order to be accepted as
parameters.

View differences:

manifests/init.pp
# type:Foreman_proxy::ListenOn
#
# $puppetrun_provider:: Provider for running/kicking Puppet agents
# type:Optional[String]
# type:Optional[Enum['puppetrun', 'mcollective', 'ssh', 'salt', 'customrun']]
#
# $puppetrun_cmd:: Puppet run/kick command to be allowed in sudoers
# type:String
......
# type:Foreman_proxy::ListenOn
#
# $bmc_default_provider:: BMC default provider.
# type:String
# type:Enum['ipmitool', 'freeipmi', 'shell']
#
# $keyfile:: DNS server keyfile path
# type:Stdlib::Absolutepath
......
# type:Foreman_proxy::ListenOn
#
# $realm_provider:: Realm management provider
# type:String
# type:Enum['freeipa']
#
# $realm_keytab:: Kerberos keytab path to authenticate realm updates
# type:Stdlib::Absolutepath
......
}
if $puppetrun_provider {
validate_string($puppetrun_provider)
validate_re($puppetrun_provider, '^puppetrun|mcollective|ssh|salt|customrun$', 'Invalid provider: choose puppetrun, mcollective, ssh, salt or customrun')
}
# Validate template params
......
# Validate realm params
validate_bool($freeipa_remove_dns)
validate_string($realm_provider, $realm_principal)
validate_re($realm_provider, '^freeipa$', 'Invalid provider: choose freeipa')
validate_absolute_path($realm_keytab)
$real_registered_proxy_url = pick($registered_proxy_url, "https://${::fqdn}:${ssl_port}")
spec/classes/foreman_proxy__config__spec.rb
end
end
context 'with invalid realm provider' do
let :pre_condition do
'class {"foreman_proxy":
realm => true,
realm_provider => "invalid",
}'
end
it { expect { subject.call } .to raise_error(/Invalid provider: choose freeipa/) }
end
context 'with tftp_managed enabled and tftp_syslinux_filenames set' do
let :pre_condition do
'class {"foreman_proxy":
......
end
end
context 'when puppetrun_provider => invalid' do
let :pre_condition do
'class {"foreman_proxy":
puppetrun_provider => "invalid",
}'
end
it { expect { subject.call } .to raise_error(/Invalid provider: choose puppetrun, mcollective, ssh, salt or customrun/) }
end
context 'with puppet use_cache enabled' do
let :pre_condition do
'class {"foreman_proxy":

Also available in: Unified diff