diff --git a/manifests/oracle.pp b/manifests/oracle.pp index 36313b8e..7a6fdc55 100644 --- a/manifests/oracle.pp +++ b/manifests/oracle.pp @@ -87,6 +87,9 @@ # Directory hash used by the download.oracle.com site. This value is a 32 character string # which is part of the file URL returned by the JDK download site. # +# [*jce*] +# Install Oracles Java Cryptographic Extensions into the JRE or JDK +# # ### Author # mike@marseglia.org # @@ -101,6 +104,7 @@ $proxy_type = undef, $url = undef, $url_hash = undef, + $jce = false, ) { # archive module is used to download the java package @@ -111,6 +115,15 @@ fail('Java SE must be either jre or jdk.') } + if $jce { + $jce_download = $version ? { + '8' => 'http://download.oracle.com/otn-pub/java/jce/8/jce_policy-8.zip', + '7' => 'http://download.oracle.com/otn-pub/java/jce/7/UnlimitedJCEPolicyJDK7.zip', + '6' => 'http://download.oracle.com/otn-pub/java/jce_policy/6/jce_policy-6.zip', + default => undef + } + } + # determine Oracle Java major and minor version, and installation path if $version_major and $version_minor { @@ -121,7 +134,7 @@ if $release_major =~ /(\d+)u(\d+)/ { # Required for CentOS systems where Java8 update number is >= 171 to ensure # the package is visible to Puppet - if $facts['os']['name'] == 'CentOS' and $2 >= '171' { + if $facts['os']['family'] == 'RedHat' and $2 >= '171' { $install_path = "${java_se}1.${1}.0_${2}-amd64" } else { $install_path = "${java_se}1.${1}.0_${2}" @@ -187,6 +200,11 @@ fail ( "unsupported platform ${$facts['kernel']}" ) } } + # Install required unzip packages for jce + if $jce { + ensure_resource('package', 'unzip', { 'ensure' => 'present' }) + } + # set java architecture nomenclature case $facts['os']['architecture'] { 'i386' : { $arch = 'i586' } @@ -269,20 +287,44 @@ } case $facts['kernel'] { 'Linux' : { - exec { "Install Oracle java_se ${java_se} ${version}" : + case $facts['os']['family'] { + 'Debian' : { + ensure_resource('file', '/usr/lib/jvm', { + ensure => directory, + }) + $install_requires = [Archive[$destination], File['/usr/lib/jvm']] + } + default : { + $install_requires = [Archive[$destination]] + } + } + exec { "Install Oracle java_se ${java_se} ${version} ${release_major} ${release_minor}" : path => '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin', command => $install_command, creates => $creates_path, - require => Archive[$destination] + require => $install_requires } - case $facts['os']['family'] { - 'Debian' : { - file{'/usr/lib/jvm': - ensure => directory, - before => Exec["Install Oracle java_se ${java_se} ${version}"] - } + + if ($jce and $jce_download != undef) { + $jce_path = $java_se ? { + 'jre' => "${creates_path}/lib/security", + 'jdk' => "${creates_path}/jre/lib/security" + } + archive { "/tmp/jce-${version}.zip": + source => $jce_download, + cookie => 'gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie', + extract => true, + extract_path => $jce_path, + extract_flags => '-oj', + creates => "${jce_path}/US_export_policy.jar", + cleanup => false, + proxy_server => $proxy_server, + proxy_type => $proxy_type, + require => [ + Package['unzip'], + Exec["Install Oracle java_se ${java_se} ${version} ${release_major} ${release_minor}"] + ] } - default : { } } } default : { diff --git a/manifests/params.pp b/manifests/params.pp index e302bcaf..8da61228 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -74,18 +74,23 @@ 'amd64' => 'x64', default => $::architecture } + $openjdk_architecture = $::architecture ? { + 'aarch64' => 'arm64', + 'armv7l' => 'armhf', + default => $::architecture + } case $::lsbdistcodename { 'lenny', 'squeeze', 'lucid', 'natty': { $java = { 'jdk' => { 'package' => 'openjdk-6-jdk', - 'alternative' => "java-6-openjdk-${::architecture}", + 'alternative' => "java-6-openjdk-${openjdk_architecture}", 'alternative_path' => '/usr/lib/jvm/java-6-openjdk/jre/bin/java', 'java_home' => '/usr/lib/jvm/java-6-openjdk/jre/', }, 'jre' => { 'package' => 'openjdk-6-jre-headless', - 'alternative' => "java-6-openjdk-${::architecture}", + 'alternative' => "java-6-openjdk-${openjdk_architecture}", 'alternative_path' => '/usr/lib/jvm/java-6-openjdk/jre/bin/java', 'java_home' => '/usr/lib/jvm/java-6-openjdk/jre/', }, @@ -107,15 +112,15 @@ $java = { 'jdk' => { 'package' => 'openjdk-7-jdk', - 'alternative' => "java-1.7.0-openjdk-${::architecture}", - 'alternative_path' => "/usr/lib/jvm/java-1.7.0-openjdk-${::architecture}/bin/java", - 'java_home' => "/usr/lib/jvm/java-1.7.0-openjdk-${::architecture}/", + 'alternative' => "java-1.7.0-openjdk-${openjdk_architecture}", + 'alternative_path' => "/usr/lib/jvm/java-1.7.0-openjdk-${openjdk_architecture}/bin/java", + 'java_home' => "/usr/lib/jvm/java-1.7.0-openjdk-${openjdk_architecture}/", }, 'jre' => { 'package' => 'openjdk-7-jre-headless', 'alternative' => "java-1.7.0-openjdk-${::architecture}", - 'alternative_path' => "/usr/lib/jvm/java-1.7.0-openjdk-${::architecture}/bin/java", - 'java_home' => "/usr/lib/jvm/java-1.7.0-openjdk-${::architecture}/", + 'alternative_path' => "/usr/lib/jvm/java-1.7.0-openjdk-${openjdk_architecture}/bin/java", + 'java_home' => "/usr/lib/jvm/java-1.7.0-openjdk-${openjdk_architecture}/", }, 'oracle-jre' => { 'package' => 'oracle-j2re1.7', @@ -155,19 +160,35 @@ }, } } - 'stretch', 'vivid', 'wily', 'xenial', 'yakkety', 'zesty', 'artful', 'bionic': { + 'stretch', 'vivid', 'wily', 'xenial', 'yakkety', 'zesty', 'artful': { $java = { 'jdk' => { 'package' => 'openjdk-8-jdk', - 'alternative' => "java-1.8.0-openjdk-${::architecture}", - 'alternative_path' => "/usr/lib/jvm/java-1.8.0-openjdk-${::architecture}/bin/java", - 'java_home' => "/usr/lib/jvm/java-1.8.0-openjdk-${::architecture}/", + 'alternative' => "java-1.8.0-openjdk-${openjdk_architecture}", + 'alternative_path' => "/usr/lib/jvm/java-1.8.0-openjdk-${openjdk_architecture}/bin/java", + 'java_home' => "/usr/lib/jvm/java-1.8.0-openjdk-${openjdk_architecture}/", }, 'jre' => { 'package' => 'openjdk-8-jre-headless', - 'alternative' => "java-1.8.0-openjdk-${::architecture}", - 'alternative_path' => "/usr/lib/jvm/java-1.8.0-openjdk-${::architecture}/bin/java", - 'java_home' => "/usr/lib/jvm/java-1.8.0-openjdk-${::architecture}/", + 'alternative' => "java-1.8.0-openjdk-${openjdk_architecture}", + 'alternative_path' => "/usr/lib/jvm/java-1.8.0-openjdk-${openjdk_architecture}/bin/java", + 'java_home' => "/usr/lib/jvm/java-1.8.0-openjdk-${openjdk_architecture}/", + } + } + } + 'bionic': { + $java = { + 'jdk' => { + 'package' => 'openjdk-11-jdk', + 'alternative' => "java-1.11.0-openjdk-${openjdk_architecture}", + 'alternative_path' => "/usr/lib/jvm/java-1.11.0-openjdk-${openjdk_architecture}/bin/java", + 'java_home' => "/usr/lib/jvm/java-1.11.0-openjdk-${openjdk_architecture}/", + }, + 'jre' => { + 'package' => 'openjdk-11-jre-headless', + 'alternative' => "java-1.11.0-openjdk-${openjdk_architecture}", + 'alternative_path' => "/usr/lib/jvm/java-1.11.0-openjdk-${openjdk_architecture}/bin/java", + 'java_home' => "/usr/lib/jvm/java-1.11.0-openjdk-${openjdk_architecture}/", } } } diff --git a/spec/acceptance/install_spec.rb b/spec/acceptance/install_spec.rb index 32fca8b3..88915945 100644 --- a/spec/acceptance/install_spec.rb +++ b/spec/acceptance/install_spec.rb @@ -1,5 +1,7 @@ require 'spec_helper_acceptance' +include Unix::File + # RedHat, CentOS, Scientific, Oracle prior to 5.0 : Sun Java JDK/JRE 1.6 # RedHat, CentOS, Scientific, Oracle 5.0 < x < 6.3 : OpenJDK Java JDK/JRE 1.6 # RedHat, CentOS, Scientific, Oracle after 6.3 : OpenJDK Java JDK/JRE 1.7 @@ -79,6 +81,62 @@ " java_alternative_path => '/whatever',\n"\ '}' +# Oracle installs are disabled by default, because the links to valid oracle installations +# change often. Look the parameters up from the Oracle download URLs at https://java.oracle.com and +# enable the tests: + +oracle_enabled = false +oracle_version_major = '8' +oracle_version_minor = '181' +oracle_version_build = '13' +oracle_hash = '96a7b8442fe848ef90c96a2fad6ed6d1' + +install_oracle_jre = < '#{oracle_version_major}', + version_major => '#{oracle_version_major}u#{oracle_version_minor}', + version_minor => 'b#{oracle_version_build}', + url_hash => '#{oracle_hash}', + java_se => 'jre', + } +EOL + +install_oracle_jdk = < '#{oracle_version_major}', + version_major => '#{oracle_version_major}u#{oracle_version_minor}', + version_minor => 'b#{oracle_version_build}', + url_hash => '#{oracle_hash}', + java_se => 'jdk', + } +EOL + +install_oracle_jre_jce = < '#{oracle_version_major}', + version_major => '#{oracle_version_major}u#{oracle_version_minor}', + version_minor => 'b#{oracle_version_build}', + url_hash => '#{oracle_hash}', + java_se => 'jre', + jce => true, + } +EOL + +install_oracle_jdk_jce = < '#{oracle_version_major}', + version_major => '#{oracle_version_major}u#{oracle_version_minor}', + version_minor => 'b#{oracle_version_build}', + url_hash => '#{oracle_hash}', + java_se => 'jdk', + jce => true, + } +EOL + context 'installing java jre', unless: UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do it 'installs jre' do apply_manifest(java_class_jre, catch_failures: true) @@ -155,3 +213,37 @@ end end end + +# Test oracle java installs +context 'java::oracle', if: oracle_enabled, unless: UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do + install_path = '/usr/lib/jvm' + version_suffix = '' + if fact('osfamily') == 'RedHat' || fact('osfamily') == 'Amazon' + install_path = '/usr/java' + version_suffix = '-amd64' + end + it 'installs oracle jdk' do + apply_manifest(install_oracle_jdk, catch_failures: true) + apply_manifest(install_oracle_jdk, catch_changes: true) + result = shell("test ! -e #{install_path}/jdk1.#{oracle_version_major}.0_#{oracle_version_minor}#{version_suffix}/jre/lib/security/local_policy.jar") + expect(result.exit_code).to eq(0) + end + it 'installs oracle jre' do + apply_manifest(install_oracle_jre, catch_failures: true) + apply_manifest(install_oracle_jre, catch_changes: true) + result = shell("test ! -e #{install_path}/jre1.#{oracle_version_major}.0_#{oracle_version_minor}#{version_suffix}/lib/security/local_policy.jar") + expect(result.exit_code).to eq(0) + end + it 'installs oracle jdk with jce' do + apply_manifest(install_oracle_jdk_jce, catch_failures: true) + apply_manifest(install_oracle_jdk_jce, catch_changes: true) + result = shell("test -e #{install_path}/jdk1.#{oracle_version_major}.0_#{oracle_version_minor}#{version_suffix}/jre/lib/security/local_policy.jar") + expect(result.exit_code).to eq(0) + end + it 'installs oracle jre with jce' do + apply_manifest(install_oracle_jre_jce, catch_failures: true) + apply_manifest(install_oracle_jre_jce, catch_changes: true) + result = shell("test -e #{install_path}/jre1.#{oracle_version_major}.0_#{oracle_version_minor}#{version_suffix}/lib/security/local_policy.jar") + expect(result.exit_code).to eq(0) + end +end diff --git a/spec/classes/java_spec.rb b/spec/classes/java_spec.rb index a82850bc..2764b8f8 100644 --- a/spec/classes/java_spec.rb +++ b/spec/classes/java_spec.rb @@ -69,6 +69,22 @@ it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64/') } end + context 'when select jdk for Ubuntu xenial (16.04) on ARM' do + let(:facts) { { osfamily: 'Debian', operatingsystem: 'Ubuntu', lsbdistcodename: 'xenial', operatingsystemrelease: '16.04', architecture: 'armv7l' } } + let(:params) { { 'distribution' => 'jdk' } } + + it { is_expected.to contain_package('java').with_name('openjdk-8-jdk') } + it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-armhf/') } + end + + context 'when select jdk for Ubuntu xenial (16.04) on ARM64' do + let(:facts) { { osfamily: 'Debian', operatingsystem: 'Ubuntu', lsbdistcodename: 'xenial', operatingsystemrelease: '16.04', architecture: 'aarch64' } } + let(:params) { { 'distribution' => 'jdk' } } + + it { is_expected.to contain_package('java').with_name('openjdk-8-jdk') } + it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-arm64/') } + end + context 'when select openjdk for Amazon Linux' do let(:facts) { { osfamily: 'RedHat', operatingsystem: 'Amazon', operatingsystemrelease: '3.4.43-43.43.amzn1.x86_64', architecture: 'x86_64' } } diff --git a/spec/defines/oracle_spec.rb b/spec/defines/oracle_spec.rb index afa85cf1..9e97b5f8 100644 --- a/spec/defines/oracle_spec.rb +++ b/spec/defines/oracle_spec.rb @@ -11,8 +11,8 @@ let(:title) { 'jdk6' } it { is_expected.to contain_archive('/tmp/jdk-6u45-linux-x64-rpm.bin') } - it { is_expected.to contain_exec('Install Oracle java_se jdk 6').with_command('sh /tmp/jdk-6u45-linux-x64-rpm.bin -x; rpm --force -iv sun*.rpm; rpm --force -iv jdk*.rpm') } - it { is_expected.to contain_exec('Install Oracle java_se jdk 6').that_requires('Archive[/tmp/jdk-6u45-linux-x64-rpm.bin]') } + it { is_expected.to contain_exec('Install Oracle java_se jdk 6 6u45 b06').with_command('sh /tmp/jdk-6u45-linux-x64-rpm.bin -x; rpm --force -iv sun*.rpm; rpm --force -iv jdk*.rpm') } + it { is_expected.to contain_exec('Install Oracle java_se jdk 6 6u45 b06').that_requires('Archive[/tmp/jdk-6u45-linux-x64-rpm.bin]') } end context 'when Oracle Java SE 7 JDK' do @@ -20,8 +20,8 @@ let(:title) { 'jdk7' } it { is_expected.to contain_archive('/tmp/jdk-7u80-linux-x64.rpm') } - it { is_expected.to contain_exec('Install Oracle java_se jdk 7').with_command('rpm --force -iv /tmp/jdk-7u80-linux-x64.rpm') } - it { is_expected.to contain_exec('Install Oracle java_se jdk 7').that_requires('Archive[/tmp/jdk-7u80-linux-x64.rpm]') } + it { is_expected.to contain_exec('Install Oracle java_se jdk 7 7u80 b15').with_command('rpm --force -iv /tmp/jdk-7u80-linux-x64.rpm') } + it { is_expected.to contain_exec('Install Oracle java_se jdk 7 7u80 b15').that_requires('Archive[/tmp/jdk-7u80-linux-x64.rpm]') } end context 'when Oracle Java SE 8 JDK' do @@ -29,8 +29,8 @@ let(:title) { 'jdk8' } it { is_expected.to contain_archive('/tmp/jdk-8u131-linux-x64.rpm') } - it { is_expected.to contain_exec('Install Oracle java_se jdk 8').with_command('rpm --force -iv /tmp/jdk-8u131-linux-x64.rpm') } - it { is_expected.to contain_exec('Install Oracle java_se jdk 8').that_requires('Archive[/tmp/jdk-8u131-linux-x64.rpm]') } + it { is_expected.to contain_exec('Install Oracle java_se jdk 8 8u131 b11').with_command('rpm --force -iv /tmp/jdk-8u131-linux-x64.rpm') } + it { is_expected.to contain_exec('Install Oracle java_se jdk 8 8u131 b11').that_requires('Archive[/tmp/jdk-8u131-linux-x64.rpm]') } end context 'when Oracle Java SE 6 JRE' do @@ -38,8 +38,8 @@ let(:title) { 'jre6' } it { is_expected.to contain_archive('/tmp/jre-6u45-linux-x64-rpm.bin') } - it { is_expected.to contain_exec('Install Oracle java_se jre 6').with_command('sh /tmp/jre-6u45-linux-x64-rpm.bin -x; rpm --force -iv sun*.rpm; rpm --force -iv jre*.rpm') } - it { is_expected.to contain_exec('Install Oracle java_se jre 6').that_requires('Archive[/tmp/jre-6u45-linux-x64-rpm.bin]') } + it { is_expected.to contain_exec('Install Oracle java_se jre 6 6u45 b06').with_command('sh /tmp/jre-6u45-linux-x64-rpm.bin -x; rpm --force -iv sun*.rpm; rpm --force -iv jre*.rpm') } + it { is_expected.to contain_exec('Install Oracle java_se jre 6 6u45 b06').that_requires('Archive[/tmp/jre-6u45-linux-x64-rpm.bin]') } end context 'when Oracle Java SE 7 JRE' do @@ -47,8 +47,8 @@ let(:title) { 'jre7' } it { is_expected.to contain_archive('/tmp/jre-7u80-linux-x64.rpm') } - it { is_expected.to contain_exec('Install Oracle java_se jre 7').with_command('rpm --force -iv /tmp/jre-7u80-linux-x64.rpm') } - it { is_expected.to contain_exec('Install Oracle java_se jre 7').that_requires('Archive[/tmp/jre-7u80-linux-x64.rpm]') } + it { is_expected.to contain_exec('Install Oracle java_se jre 7 7u80 b15').with_command('rpm --force -iv /tmp/jre-7u80-linux-x64.rpm') } + it { is_expected.to contain_exec('Install Oracle java_se jre 7 7u80 b15').that_requires('Archive[/tmp/jre-7u80-linux-x64.rpm]') } end context 'when select Oracle Java SE 8 JRE' do @@ -56,8 +56,8 @@ let(:title) { 'jre8' } it { is_expected.to contain_archive('/tmp/jre-8u131-linux-x64.rpm') } - it { is_expected.to contain_exec('Install Oracle java_se jre 8').with_command('rpm --force -iv /tmp/jre-8u131-linux-x64.rpm') } - it { is_expected.to contain_exec('Install Oracle java_se jre 8').that_requires('Archive[/tmp/jre-8u131-linux-x64.rpm]') } + it { is_expected.to contain_exec('Install Oracle java_se jre 8 8u131 b11').with_command('rpm --force -iv /tmp/jre-8u131-linux-x64.rpm') } + it { is_expected.to contain_exec('Install Oracle java_se jre 8 8u131 b11').that_requires('Archive[/tmp/jre-8u131-linux-x64.rpm]') } end context 'when passing URL to url parameter' do @@ -93,6 +93,54 @@ it { is_expected.to contain_archive('/tmp/jdk-8u131-linux-x64.rpm').with_source('http://download.oracle.com/otn-pub/java/jdk//8u131-b11/abcdef01234567890/jdk-8u131-linux-x64.rpm') } end + + context 'when installing multiple versions' do + let(:params) do + { + ensure: 'present', + version_major: '8u131', + version_minor: 'b11', + java_se: 'jdk', + url_hash: 'abcdef01234567890', + } + end + let(:title) { 'jdk8' } + + let(:pre_condition) do + <<-EOL + java::oracle { + 'jdk8121': + ensure => 'present', + version_major => '8u121', + version_minor => 'b11', + java_se => 'jdk', + url_hash => 'fiewojgfuiowfniweof', + } + EOL + end + + it { is_expected.to compile } + end + + context 'when installing Oracle Java SE 6 JRE with JCE' do + let(:params) { { ensure: 'present', jce: true, version: '6', version_major: '6u99', version_minor: '99', java_se: 'jre' } } + let(:title) { 'jre6jce' } + + it do + is_expected.to contain_archive('/tmp/jce-6.zip').with_source('http://download.oracle.com/otn-pub/java/jce_policy/6/jce_policy-6.zip') + is_expected.to contain_archive('/tmp/jce-6.zip').with_extract_path('/usr/java/jre1.6.0_99-amd64/lib/security') + end + end + + context 'when installing Oracle Java SE 6 JDK with JCE' do + let(:params) { { ensure: 'present', jce: true, version: '6', version_major: '6u99', version_minor: '99', java_se: 'jdk' } } + let(:title) { 'jre6jce' } + + it do + is_expected.to contain_archive('/tmp/jce-6.zip').with_source('http://download.oracle.com/otn-pub/java/jce_policy/6/jce_policy-6.zip') + is_expected.to contain_archive('/tmp/jce-6.zip').with_extract_path('/usr/java/jdk1.6.0_99-amd64/jre/lib/security') + end + end end context 'when on CentOS 32-bit' do @@ -103,8 +151,8 @@ let(:title) { 'jdk6' } it { is_expected.to contain_archive('/tmp/jdk-6u45-linux-i586-rpm.bin') } - it { is_expected.to contain_exec('Install Oracle java_se jdk 6').with_command('sh /tmp/jdk-6u45-linux-i586-rpm.bin -x; rpm --force -iv sun*.rpm; rpm --force -iv jdk*.rpm') } - it { is_expected.to contain_exec('Install Oracle java_se jdk 6').that_requires('Archive[/tmp/jdk-6u45-linux-i586-rpm.bin]') } + it { is_expected.to contain_exec('Install Oracle java_se jdk 6 6u45 b06').with_command('sh /tmp/jdk-6u45-linux-i586-rpm.bin -x; rpm --force -iv sun*.rpm; rpm --force -iv jdk*.rpm') } + it { is_expected.to contain_exec('Install Oracle java_se jdk 6 6u45 b06').that_requires('Archive[/tmp/jdk-6u45-linux-i586-rpm.bin]') } end context 'when selecting Oracle Java SE 7 JDK on RedHat family, 32-bit' do @@ -112,8 +160,8 @@ let(:title) { 'jdk7' } it { is_expected.to contain_archive('/tmp/jdk-7u80-linux-i586.rpm') } - it { is_expected.to contain_exec('Install Oracle java_se jdk 7').with_command('rpm --force -iv /tmp/jdk-7u80-linux-i586.rpm') } - it { is_expected.to contain_exec('Install Oracle java_se jdk 7').that_requires('Archive[/tmp/jdk-7u80-linux-i586.rpm]') } + it { is_expected.to contain_exec('Install Oracle java_se jdk 7 7u80 b15').with_command('rpm --force -iv /tmp/jdk-7u80-linux-i586.rpm') } + it { is_expected.to contain_exec('Install Oracle java_se jdk 7 7u80 b15').that_requires('Archive[/tmp/jdk-7u80-linux-i586.rpm]') } end context 'when selecting Oracle Java SE 8 JDK on RedHat family, 32-bit' do @@ -121,8 +169,8 @@ let(:title) { 'jdk8' } it { is_expected.to contain_archive('/tmp/jdk-8u131-linux-i586.rpm') } - it { is_expected.to contain_exec('Install Oracle java_se jdk 8').with_command('rpm --force -iv /tmp/jdk-8u131-linux-i586.rpm') } - it { is_expected.to contain_exec('Install Oracle java_se jdk 8').that_requires('Archive[/tmp/jdk-8u131-linux-i586.rpm]') } + it { is_expected.to contain_exec('Install Oracle java_se jdk 8 8u131 b11').with_command('rpm --force -iv /tmp/jdk-8u131-linux-i586.rpm') } + it { is_expected.to contain_exec('Install Oracle java_se jdk 8 8u131 b11').that_requires('Archive[/tmp/jdk-8u131-linux-i586.rpm]') } end context 'when selecting Oracle Java SE 6 JRE on RedHat family, 32-bit' do @@ -130,8 +178,8 @@ let(:title) { 'jdk6' } it { is_expected.to contain_archive('/tmp/jre-6u45-linux-i586-rpm.bin') } - it { is_expected.to contain_exec('Install Oracle java_se jre 6').with_command('sh /tmp/jre-6u45-linux-i586-rpm.bin -x; rpm --force -iv sun*.rpm; rpm --force -iv jre*.rpm') } - it { is_expected.to contain_exec('Install Oracle java_se jre 6').that_requires('Archive[/tmp/jre-6u45-linux-i586-rpm.bin]') } + it { is_expected.to contain_exec('Install Oracle java_se jre 6 6u45 b06').with_command('sh /tmp/jre-6u45-linux-i586-rpm.bin -x; rpm --force -iv sun*.rpm; rpm --force -iv jre*.rpm') } + it { is_expected.to contain_exec('Install Oracle java_se jre 6 6u45 b06').that_requires('Archive[/tmp/jre-6u45-linux-i586-rpm.bin]') } end context 'when select Oracle Java SE 7 JRE on RedHat family, 32-bit' do @@ -139,8 +187,8 @@ let(:title) { 'jdk7' } it { is_expected.to contain_archive('/tmp/jre-7u80-linux-i586.rpm') } - it { is_expected.to contain_exec('Install Oracle java_se jre 7').with_command('rpm --force -iv /tmp/jre-7u80-linux-i586.rpm') } - it { is_expected.to contain_exec('Install Oracle java_se jre 7').that_requires('Archive[/tmp/jre-7u80-linux-i586.rpm]') } + it { is_expected.to contain_exec('Install Oracle java_se jre 7 7u80 b15').with_command('rpm --force -iv /tmp/jre-7u80-linux-i586.rpm') } + it { is_expected.to contain_exec('Install Oracle java_se jre 7 7u80 b15').that_requires('Archive[/tmp/jre-7u80-linux-i586.rpm]') } end context 'when select Oracle Java SE 8 JRE on RedHat family, 32-bit' do @@ -148,8 +196,56 @@ let(:title) { 'jdk8' } it { is_expected.to contain_archive('/tmp/jre-8u131-linux-i586.rpm') } - it { is_expected.to contain_exec('Install Oracle java_se jre 8').with_command('rpm --force -iv /tmp/jre-8u131-linux-i586.rpm') } - it { is_expected.to contain_exec('Install Oracle java_se jre 8').that_requires('Archive[/tmp/jre-8u131-linux-i586.rpm]') } + it { is_expected.to contain_exec('Install Oracle java_se jre 8 8u131 b11').with_command('rpm --force -iv /tmp/jre-8u131-linux-i586.rpm') } + it { is_expected.to contain_exec('Install Oracle java_se jre 8 8u131 b11').that_requires('Archive[/tmp/jre-8u131-linux-i586.rpm]') } + end + + context 'when installing multiple versions' do + let(:params) do + { + ensure: 'present', + version_major: '8u131', + version_minor: 'b11', + java_se: 'jdk', + url_hash: 'abcdef01234567890', + } + end + let(:title) { 'jdk8' } + + let(:pre_condition) do + <<-EOL + java::oracle { + 'jdk8121': + ensure => 'present', + version_major => '8u121', + version_minor => 'b11', + java_se => 'jdk', + url_hash => 'fiewojgfuiowfniweof', + } + EOL + end + + it { is_expected.to compile } + end + + context 'when installing Oracle Java SE 6 JRE with JCE' do + let(:params) { { ensure: 'present', jce: true, version: '6', version_major: '6u99', version_minor: '99', java_se: 'jre' } } + let(:title) { 'jre6jce' } + + it do + is_expected.to contain_archive('/tmp/jce-6.zip').with_source('http://download.oracle.com/otn-pub/java/jce_policy/6/jce_policy-6.zip') + is_expected.to contain_archive('/tmp/jce-6.zip').with_extract_path('/usr/java/jre1.6.0_99-amd64/lib/security') + end + end + + context 'when installing Oracle Java SE 6 JDK with JCE' do + let(:params) { { ensure: 'present', jce: true, version: '6', version_major: '6u99', version_minor: '99', java_se: 'jdk' } } + let(:title) { 'jre6jce' } + + it do + is_expected.to contain_archive('/tmp/jce-6.zip').with_source('http://download.oracle.com/otn-pub/java/jce_policy/6/jce_policy-6.zip') + is_expected.to contain_archive('/tmp/jce-6.zip').with_extract_path('/usr/java/jdk1.6.0_99-amd64/jre/lib/security') + end end end @@ -161,8 +257,8 @@ let(:title) { 'jdk6' } it { is_expected.to contain_archive('/tmp/jdk-6u45-linux-x64.tar.gz') } - it { is_expected.to contain_exec('Install Oracle java_se jdk 6').with_command('tar -zxf /tmp/jdk-6u45-linux-x64.tar.gz -C /usr/lib/jvm') } - it { is_expected.to contain_exec('Install Oracle java_se jdk 6').that_requires('Archive[/tmp/jdk-6u45-linux-x64.tar.gz]') } + it { is_expected.to contain_exec('Install Oracle java_se jdk 6 6u45 b06').with_command('tar -zxf /tmp/jdk-6u45-linux-x64.tar.gz -C /usr/lib/jvm') } + it { is_expected.to contain_exec('Install Oracle java_se jdk 6 6u45 b06').that_requires('Archive[/tmp/jdk-6u45-linux-x64.tar.gz]') } end context 'with Oracle Java SE 7 JDK' do @@ -170,8 +266,8 @@ let(:title) { 'jdk7' } it { is_expected.to contain_archive('/tmp/jdk-7u80-linux-x64.tar.gz') } - it { is_expected.to contain_exec('Install Oracle java_se jdk 7').with_command('tar -zxf /tmp/jdk-7u80-linux-x64.tar.gz -C /usr/lib/jvm') } - it { is_expected.to contain_exec('Install Oracle java_se jdk 7').that_requires('Archive[/tmp/jdk-7u80-linux-x64.tar.gz]') } + it { is_expected.to contain_exec('Install Oracle java_se jdk 7 7u80 b15').with_command('tar -zxf /tmp/jdk-7u80-linux-x64.tar.gz -C /usr/lib/jvm') } + it { is_expected.to contain_exec('Install Oracle java_se jdk 7 7u80 b15').that_requires('Archive[/tmp/jdk-7u80-linux-x64.tar.gz]') } end context 'with Oracle Java SE 8 JDK' do @@ -179,8 +275,8 @@ let(:title) { 'jdk8' } it { is_expected.to contain_archive('/tmp/jdk-8u131-linux-x64.tar.gz') } - it { is_expected.to contain_exec('Install Oracle java_se jdk 8').with_command('tar -zxf /tmp/jdk-8u131-linux-x64.tar.gz -C /usr/lib/jvm') } - it { is_expected.to contain_exec('Install Oracle java_se jdk 8').that_requires('Archive[/tmp/jdk-8u131-linux-x64.tar.gz]') } + it { is_expected.to contain_exec('Install Oracle java_se jdk 8 8u131 b11').with_command('tar -zxf /tmp/jdk-8u131-linux-x64.tar.gz -C /usr/lib/jvm') } + it { is_expected.to contain_exec('Install Oracle java_se jdk 8 8u131 b11').that_requires('Archive[/tmp/jdk-8u131-linux-x64.tar.gz]') } end context 'with Oracle Java SE 6 JRE' do @@ -188,8 +284,8 @@ let(:title) { 'jre6' } it { is_expected.to contain_archive('/tmp/jre-6u45-linux-x64.tar.gz') } - it { is_expected.to contain_exec('Install Oracle java_se jre 6').with_command('tar -zxf /tmp/jre-6u45-linux-x64.tar.gz -C /usr/lib/jvm') } - it { is_expected.to contain_exec('Install Oracle java_se jre 6').that_requires('Archive[/tmp/jre-6u45-linux-x64.tar.gz]') } + it { is_expected.to contain_exec('Install Oracle java_se jre 6 6u45 b06').with_command('tar -zxf /tmp/jre-6u45-linux-x64.tar.gz -C /usr/lib/jvm') } + it { is_expected.to contain_exec('Install Oracle java_se jre 6 6u45 b06').that_requires('Archive[/tmp/jre-6u45-linux-x64.tar.gz]') } end context 'when Oracle Java SE 7 JRE' do @@ -197,8 +293,8 @@ let(:title) { 'jre7' } it { is_expected.to contain_archive('/tmp/jre-7u80-linux-x64.tar.gz') } - it { is_expected.to contain_exec('Install Oracle java_se jre 7').with_command('tar -zxf /tmp/jre-7u80-linux-x64.tar.gz -C /usr/lib/jvm') } - it { is_expected.to contain_exec('Install Oracle java_se jre 7').that_requires('Archive[/tmp/jre-7u80-linux-x64.tar.gz]') } + it { is_expected.to contain_exec('Install Oracle java_se jre 7 7u80 b15').with_command('tar -zxf /tmp/jre-7u80-linux-x64.tar.gz -C /usr/lib/jvm') } + it { is_expected.to contain_exec('Install Oracle java_se jre 7 7u80 b15').that_requires('Archive[/tmp/jre-7u80-linux-x64.tar.gz]') } end context 'when Oracle Java SE 8 JRE' do @@ -206,8 +302,8 @@ let(:title) { 'jre8' } it { is_expected.to contain_archive('/tmp/jre-8u131-linux-x64.tar.gz') } - it { is_expected.to contain_exec('Install Oracle java_se jre 8').with_command('tar -zxf /tmp/jre-8u131-linux-x64.tar.gz -C /usr/lib/jvm') } - it { is_expected.to contain_exec('Install Oracle java_se jre 8').that_requires('Archive[/tmp/jre-8u131-linux-x64.tar.gz]') } + it { is_expected.to contain_exec('Install Oracle java_se jre 8 8u131 b11').with_command('tar -zxf /tmp/jre-8u131-linux-x64.tar.gz -C /usr/lib/jvm') } + it { is_expected.to contain_exec('Install Oracle java_se jre 8 8u131 b11').that_requires('Archive[/tmp/jre-8u131-linux-x64.tar.gz]') } end context 'when passing URL to url parameter' do @@ -216,6 +312,54 @@ it { is_expected.to contain_archive('/tmp/jdk-8u131-linux-x64.tar.gz') } end + + context 'when installing multiple versions' do + let(:params) do + { + ensure: 'present', + version_major: '8u131', + version_minor: 'b11', + java_se: 'jdk', + url_hash: 'abcdef01234567890', + } + end + let(:title) { 'jdk8' } + + let(:pre_condition) do + <<-EOL + java::oracle { + 'jdk8121': + ensure => 'present', + version_major => '8u121', + version_minor => 'b11', + java_se => 'jdk', + url_hash => 'fiewojgfuiowfniweof', + } + EOL + end + + it { is_expected.to compile } + end + + context 'when installing Oracle Java SE 6 JRE with JCE' do + let(:params) { { ensure: 'present', jce: true, version: '6', version_major: '6u99', version_minor: '99', java_se: 'jre' } } + let(:title) { 'jre6jce' } + + it do + is_expected.to contain_archive('/tmp/jce-6.zip').with_source('http://download.oracle.com/otn-pub/java/jce_policy/6/jce_policy-6.zip') + is_expected.to contain_archive('/tmp/jce-6.zip').with_extract_path('/usr/lib/jvm/jre1.6.0_99/lib/security') + end + end + + context 'when installing Oracle Java SE 6 JDK with JCE' do + let(:params) { { ensure: 'present', jce: true, version: '6', version_major: '6u99', version_minor: '99', java_se: 'jdk' } } + let(:title) { 'jre6jce' } + + it do + is_expected.to contain_archive('/tmp/jce-6.zip').with_source('http://download.oracle.com/otn-pub/java/jce_policy/6/jce_policy-6.zip') + is_expected.to contain_archive('/tmp/jce-6.zip').with_extract_path('/usr/lib/jvm/jdk1.6.0_99/jre/lib/security') + end + end end describe 'incompatible OSes' do [