|
22 | 22 | describe JavaBuildpack::Framework::ContainerSecurityProvider do
|
23 | 23 | include_context 'with component help'
|
24 | 24 |
|
25 |
| - it 'always detects' do |
26 |
| - expect(component.detect).to eq("container-security-provider=#{version}") |
| 25 | + let(:java_home) do |
| 26 | + java_home = JavaBuildpack::Component::MutableJavaHome.new |
| 27 | + java_home.version = version_8 |
| 28 | + return java_home |
27 | 29 | end
|
28 | 30 |
|
29 |
| - it 'adds extension directory' do |
30 |
| - component.release |
| 31 | + let(:version_8) { JavaBuildpack::Util::TokenizedVersion.new('1.8.0_162') } |
31 | 32 |
|
32 |
| - expect(extension_directories).to include(droplet.sandbox) |
| 33 | + let(:version_9) { JavaBuildpack::Util::TokenizedVersion.new('9.0.4_11') } |
| 34 | + |
| 35 | + it 'does not detect if not enabled' do |
| 36 | + expect(component.detect).to be_nil |
33 | 37 | end
|
34 | 38 |
|
35 |
| - it 'adds security provider', |
36 |
| - cache_fixture: 'stub-container-security-provider.jar' do |
| 39 | + context 'when enabled' do |
37 | 40 |
|
38 |
| - component.compile |
39 |
| - expect(security_providers[1]).to eq('org.cloudfoundry.security.CloudFoundryContainerProvider') |
40 |
| - end |
| 41 | + let(:configuration) { { 'enabled' => true } } |
41 | 42 |
|
42 |
| - context do |
| 43 | + it 'detects if enabled' do |
| 44 | + expect(component.detect).to eq("container-security-provider=#{version}") |
| 45 | + end |
43 | 46 |
|
44 |
| - let(:java_home_delegate) do |
45 |
| - delegate = JavaBuildpack::Component::MutableJavaHome.new |
46 |
| - delegate.root = app_dir + '.test-java-home' |
47 |
| - delegate.version = JavaBuildpack::Util::TokenizedVersion.new('9.0.0') |
| 47 | + it 'adds extension directory' do |
| 48 | + component.release |
48 | 49 |
|
49 |
| - delegate |
| 50 | + expect(extension_directories).to include(droplet.sandbox) |
50 | 51 | end
|
51 | 52 |
|
52 |
| - it 'adds JAR to classpath during compile in Java 9', |
| 53 | + it 'adds security provider', |
53 | 54 | cache_fixture: 'stub-container-security-provider.jar' do
|
54 | 55 |
|
55 | 56 | component.compile
|
56 | 57 |
|
57 |
| - expect(additional_libraries).to include(droplet.sandbox + "container_security_provider-#{version}.jar") |
| 58 | + expect(security_providers[1]).to eq('org.cloudfoundry.security.CloudFoundryContainerProvider') |
58 | 59 | end
|
59 | 60 |
|
60 |
| - it 'adds JAR to classpath during release in Java 9' do |
61 |
| - component.release |
| 61 | + context 'when java 9' do |
62 | 62 |
|
63 |
| - expect(additional_libraries).to include(droplet.sandbox + "container_security_provider-#{version}.jar") |
64 |
| - end |
| 63 | + it 'adds JAR to classpath during compile in Java 9', |
| 64 | + cache_fixture: 'stub-container-security-provider.jar' do |
65 | 65 |
|
66 |
| - it 'adds does not add extension directory in Java 9' do |
67 |
| - component.release |
| 66 | + java_home.version = version_9 |
| 67 | + |
| 68 | + component.compile |
| 69 | + |
| 70 | + expect(additional_libraries).to include(droplet.sandbox + "container_security_provider-#{version}.jar") |
| 71 | + end |
| 72 | + |
| 73 | + it 'adds JAR to classpath during release in Java 9' do |
| 74 | + java_home.version = version_9 |
| 75 | + |
| 76 | + component.release |
| 77 | + |
| 78 | + expect(additional_libraries).to include(droplet.sandbox + "container_security_provider-#{version}.jar") |
| 79 | + end |
| 80 | + |
| 81 | + it 'adds does not add extension directory in Java 9' do |
| 82 | + java_home.version = version_9 |
| 83 | + |
| 84 | + component.release |
| 85 | + |
| 86 | + expect(extension_directories).not_to include(droplet.sandbox) |
| 87 | + end |
68 | 88 |
|
69 |
| - expect(extension_directories).not_to include(droplet.sandbox) |
70 | 89 | end
|
71 | 90 |
|
72 | 91 | end
|
|
0 commit comments