Skip to content
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

replace validate_* with assert_type in init.pp #275

Merged
merged 1 commit into from Dec 30, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions manifests/init.pp
Expand Up @@ -251,12 +251,12 @@
if ! has_key($ajp, 'port') {
fail('You need to specify a valid port for the AJP connector.')
} else {
validate_re($ajp['port'], '^\d+$')
assert_type(Variant[Pattern[/^\d+$/], Stdlib::Port], $ajp['port'])
}
if ! has_key($ajp, 'protocol') {
fail('You need to specify a valid protocol for the AJP connector.')
} else {
validate_re($ajp['protocol'], ['^AJP/1.3$', '^org.apache.coyote.ajp'])
assert_type(Enum['AJP/1.3', 'org.apache.coyote.ajp', 'org.apache.coyote.ajp.AjpNioProtocol'], $ajp['protocol'])
}
}

Expand Down
64 changes: 5 additions & 59 deletions spec/classes/jira_init_spec.rb
Expand Up @@ -9,67 +9,13 @@
facts
end

context 'with javahome not set' do
it('fails') do
is_expected.to raise_error(Puppet::Error, %r{You need to specify a value for javahome})
end
let :params do
{
javahome: '/tmp/bla'
}
end
context 'ajp proxy' do
context 'without port' do
let(:params) do
{
version: '6.3.4a',
javahome: '/opt/java',
ajp: {
'protocol' => 'AJP/1.3'
}
}
end

it { is_expected.to raise_error(Puppet::Error, %r{You need to specify a valid port for the AJP connector\.}) }
end
context 'with invalid port' do
let(:params) do
{
version: '6.3.4a',
javahome: '/opt/java',
ajp: {
'port' => '80zeronine',
'protocol' => 'AJP/1.3'
}
}
end

it { is_expected.to raise_error(Puppet::Error, %r{validate_re\(\): "80zeronine" does not match}) }
end
context 'without protocol' do
let(:params) do
{
version: '6.3.4a',
javahome: '/opt/java',
ajp: {
'port' => '8009'
}
}
end

it { is_expected.to raise_error(Puppet::Error, %r{You need to specify a valid protocol for the AJP connector\.}) }
end
context 'with invalid protocol' do
let(:params) do
{
version: '6.3.4a',
javahome: '/opt/java',
ajp: {
'port' => '8009',
'protocol' => 'AJP'
}
}
end

it { is_expected.to raise_error(Puppet::Error, %r{validate_re\(\): "AJP" does not match}) }
end
end
it { is_expected.to compile.with_all_deps }
end
end
end
Expand Down