Merge pull request #59 from puppetlabs/more_tests
Add some validation and more tests
This commit is contained in:
@@ -47,6 +47,9 @@ class java(
|
|||||||
include java::params
|
include java::params
|
||||||
|
|
||||||
validate_re($version, 'present|installed|latest|^[.+_0-9a-zA-Z:-]+$')
|
validate_re($version, 'present|installed|latest|^[.+_0-9a-zA-Z:-]+$')
|
||||||
|
if $package != undef {
|
||||||
|
validate_slength($package,255,1)
|
||||||
|
}
|
||||||
|
|
||||||
if has_key($java::params::java, $distribution) {
|
if has_key($java::params::java, $distribution) {
|
||||||
$default_package_name = $java::params::java[$distribution]['package']
|
$default_package_name = $java::params::java[$distribution]['package']
|
||||||
|
|||||||
@@ -24,23 +24,6 @@ require 'spec_helper_acceptance'
|
|||||||
# C14722
|
# C14722
|
||||||
describe "installing java", :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
|
describe "installing java", :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
|
||||||
describe "jre" do
|
describe "jre" do
|
||||||
#case "#{fact('osfamily')} #{fact('operatingsystemrelease')}"
|
|
||||||
#when /RedHat 4/
|
|
||||||
# # How does it work? yum is not present...
|
|
||||||
#when /RedHat 5/
|
|
||||||
# java_version = 'java version "1.6.0'
|
|
||||||
#when /RedHat (6|7)/
|
|
||||||
# java_version = 'java version "1.7.0'
|
|
||||||
#when /Debian (5|6|10|11)/
|
|
||||||
# java_version = 'java version "1.6.0'
|
|
||||||
#when /Debian (7|jesse|12|14)6/
|
|
||||||
# java_version = 'java version "1.7.0'
|
|
||||||
#when /Solaris /
|
|
||||||
# java_version =
|
|
||||||
#when /Suse/
|
|
||||||
# java_version =
|
|
||||||
#end
|
|
||||||
|
|
||||||
it 'should install jre' do
|
it 'should install jre' do
|
||||||
pp = <<-EOS
|
pp = <<-EOS
|
||||||
class { 'java':
|
class { 'java':
|
||||||
@@ -125,7 +108,90 @@ describe 'oracle', :if => (fact('operatingsystem') == 'Debian' and fact('operati
|
|||||||
describe 'jdk' do
|
describe 'jdk' do
|
||||||
it 'should install oracle-jdk' do
|
it 'should install oracle-jdk' do
|
||||||
pp = <<-EOS
|
pp = <<-EOS
|
||||||
class { 'java': }
|
class { 'java':
|
||||||
|
distribution => 'oracle-jdk',
|
||||||
|
}
|
||||||
|
EOS
|
||||||
|
|
||||||
|
apply_manifest(pp, :expect_failures => true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'failure cases' do
|
||||||
|
# C14711
|
||||||
|
it 'should fail to install java with an incorrect version' do
|
||||||
|
pp = <<-EOS
|
||||||
|
class { 'java':
|
||||||
|
version => '14.5',
|
||||||
|
}
|
||||||
|
EOS
|
||||||
|
|
||||||
|
apply_manifest(pp, :expect_failures => true)
|
||||||
|
end
|
||||||
|
|
||||||
|
# C14712
|
||||||
|
it 'should fail to install java with a blank version' do
|
||||||
|
pp = <<-EOS
|
||||||
|
class { 'java':
|
||||||
|
version => '',
|
||||||
|
}
|
||||||
|
EOS
|
||||||
|
|
||||||
|
apply_manifest(pp, :expect_failures => true)
|
||||||
|
end
|
||||||
|
|
||||||
|
# C14713
|
||||||
|
it 'should fail to install java with an incorrect distribution' do
|
||||||
|
pp = <<-EOS
|
||||||
|
class { 'java':
|
||||||
|
distribution => 'xyz',
|
||||||
|
}
|
||||||
|
EOS
|
||||||
|
|
||||||
|
apply_manifest(pp, :expect_failures => true)
|
||||||
|
end
|
||||||
|
|
||||||
|
# C14714
|
||||||
|
it 'should fail to install java with a blank distribution' do
|
||||||
|
pp = <<-EOS
|
||||||
|
class { 'java':
|
||||||
|
distribution => '',
|
||||||
|
}
|
||||||
|
EOS
|
||||||
|
|
||||||
|
apply_manifest(pp, :expect_failures => true)
|
||||||
|
end
|
||||||
|
|
||||||
|
# C14715
|
||||||
|
it 'should fail to install java with an incorrect package' do
|
||||||
|
pp = <<-EOS
|
||||||
|
class { 'java':
|
||||||
|
package => 'xyz',
|
||||||
|
}
|
||||||
|
EOS
|
||||||
|
|
||||||
|
apply_manifest(pp, :expect_failures => true)
|
||||||
|
end
|
||||||
|
|
||||||
|
# C14716
|
||||||
|
it 'should fail to install java with a blank package' do
|
||||||
|
pp = <<-EOS
|
||||||
|
class { 'java':
|
||||||
|
package => '',
|
||||||
|
}
|
||||||
|
EOS
|
||||||
|
|
||||||
|
apply_manifest(pp, :expect_failures => true)
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'non-debian systems', :if => fact('osfamily') != 'Debian' do
|
||||||
|
# C14717
|
||||||
|
it 'should fail to install java with a blank package' do
|
||||||
|
pp = <<-EOS
|
||||||
|
class { 'java':
|
||||||
|
package => '',
|
||||||
|
}
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
apply_manifest(pp, :expect_failures => true)
|
apply_manifest(pp, :expect_failures => true)
|
||||||
|
|||||||
@@ -112,4 +112,43 @@ describe 'java', :type => :class do
|
|||||||
it { should contain_package('java').with_name('java-1_7_0-openjdk-devel')}
|
it { should contain_package('java').with_name('java-1_7_0-openjdk-devel')}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'incompatible OSs' do
|
||||||
|
[
|
||||||
|
{
|
||||||
|
# C14706
|
||||||
|
:osfamily => 'windows',
|
||||||
|
:operatingsystem => 'windows',
|
||||||
|
:operatingsystemrelease => '8.1',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
# C14707
|
||||||
|
:osfamily => 'Darwin',
|
||||||
|
:operatingsystem => 'Darwin',
|
||||||
|
:operatingsystemrelease => '13.3.0',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
# C14708
|
||||||
|
:osfamily => 'AIX',
|
||||||
|
:operatingsystem => 'AIX',
|
||||||
|
:operatingsystemrelease => '7100-02-00-000',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
# C14708
|
||||||
|
:osfamily => 'AIX',
|
||||||
|
:operatingsystem => 'AIX',
|
||||||
|
:operatingsystemrelease => '6100-07-04-1216',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
# C14708
|
||||||
|
:osfamily => 'AIX',
|
||||||
|
:operatingsystem => 'AIX',
|
||||||
|
:operatingsystemrelease => '5300-12-01-1016',
|
||||||
|
},
|
||||||
|
].each do |facts|
|
||||||
|
let(:facts) { facts }
|
||||||
|
it "should fail on #{facts[:operatingsystem]} #{facts[:operatingsystemrelease]}" do
|
||||||
|
expect { subject }.to raise_error Puppet::Error, /unsupported platform/
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user