|
16 | 16 |
|
17 | 17 | require 'spec_helper'
|
18 | 18 | require 'component_helper'
|
| 19 | +require 'fileutils' |
19 | 20 | require 'java_buildpack/framework/container_certificate_trust_store'
|
20 | 21 |
|
21 | 22 | describe JavaBuildpack::Framework::ContainerCertificateTrustStore do
|
|
44 | 45 | it 'creates truststore',
|
45 | 46 | cache_fixture: 'stub-container-customizer.jar' do
|
46 | 47 |
|
| 48 | + allow(component).to receive(:ca_certificates).and_return(ca_certificates) |
| 49 | + allow(component).to receive(:shell).with("#{java_home.root}/bin/java -jar " \ |
| 50 | + "#{sandbox}/container_certificate_trust_store-0.0.0.jar " \ |
| 51 | + "--container-source #{ca_certificates} " \ |
| 52 | + "--destination #{sandbox}/truststore.jks " \ |
| 53 | + '--destination-password java-buildpack-trust-store-password') |
| 54 | + |
| 55 | + component.compile |
| 56 | + end |
| 57 | + |
| 58 | + it 'creates truststore with jre source', |
| 59 | + cache_fixture: 'stub-container-customizer.jar' do |
| 60 | + |
| 61 | + cacerts = java_home.root + 'lib/security/cacerts' |
| 62 | + FileUtils.mkdir_p(cacerts.parent) |
| 63 | + FileUtils.touch(cacerts) |
| 64 | + |
47 | 65 | allow(component).to receive(:ca_certificates).and_return(ca_certificates)
|
48 | 66 | allow(component).to receive(:shell).with("#{java_home.root}/bin/java -jar " \
|
49 | 67 | "#{sandbox}/container_certificate_trust_store-0.0.0.jar " \
|
|
56 | 74 | component.compile
|
57 | 75 | end
|
58 | 76 |
|
| 77 | + it 'creates truststore with server jre source', |
| 78 | + cache_fixture: 'stub-container-customizer.jar' do |
| 79 | + |
| 80 | + cacerts = java_home.root + 'jre/lib/security/cacerts' |
| 81 | + FileUtils.mkdir_p(cacerts.parent) |
| 82 | + FileUtils.touch(cacerts) |
| 83 | + |
| 84 | + allow(component).to receive(:ca_certificates).and_return(ca_certificates) |
| 85 | + allow(component).to receive(:shell).with("#{java_home.root}/bin/java -jar " \ |
| 86 | + "#{sandbox}/container_certificate_trust_store-0.0.0.jar " \ |
| 87 | + "--container-source #{ca_certificates} " \ |
| 88 | + "--destination #{sandbox}/truststore.jks " \ |
| 89 | + '--destination-password java-buildpack-trust-store-password ' \ |
| 90 | + "--jre-source #{java_home.root}/jre/lib/security/cacerts " \ |
| 91 | + '--jre-source-password changeit') |
| 92 | + |
| 93 | + component.compile |
| 94 | + end |
| 95 | + |
59 | 96 | it 'adds truststore properties' do
|
60 | 97 | component.release
|
61 | 98 | expect(java_opts).to include('-Djavax.net.ssl.trustStore=$PWD/.java-buildpack/container_certificate_trust_store/' \
|
|
0 commit comments