Skip to content

Commit 19ca3a2

Browse files
committed
Merge branch '552-security-provider-flag'
2 parents e8f680f + acab25d commit 19ca3a2

File tree

5 files changed

+54
-26
lines changed

5 files changed

+54
-26
lines changed

.idea/inspectionProfiles/Project_Default.xml

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/container_security_provider.yml

+1
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@
1717
---
1818
version: 1.+
1919
repository_root: "{default.repository.root}/container-security-provider"
20+
enabled: true

docs/framework-container_security_provider.md

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ The framework can be configured by modifying the [`config/container_security_pro
2222
| ---- | -----------
2323
| `repository_root` | The URL of the Container Customizer repository index ([details][repositories]).
2424
| `version` | The version of Container Customizer to use. Candidate versions can be found in [this listing][].
25+
| `enabled` | Whether to enable the `SecurityProvider`
2526

2627
## Security Provider
2728
The [security provider][] added by this framework contributes two types, a `TrustManagerFactory` and a `KeyManagerFactory`. The `TrustManagerFactory` adds an additional new `TrustManager` after the configured system `TrustManager` which reads the contents of `/etc/ssl/certs/ca-certificates.crt` which is where [BOSH trusted certificates][] are placed. The `KeyManagerFactory` adds an additional `KeyManager` after the configured system `KeyManager` which reads the contents of the files specified by `$CF_INSTANCE_CERT` and `$CF_INSTANCE_KEY` which are set by Diego to give each container a unique cryptographic identity. These `TrustManager`s and `KeyManager`s are used transparently by any networking library that reads standard system SSL configuration and can be used to enable system-wide trust and [mutual TLS authentication][].

lib/java_buildpack/framework/container_security_provider.rb

+7-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,13 @@ def release
4444

4545
# (see JavaBuildpack::Component::VersionedDependencyComponent#supports?)
4646
def supports?
47-
true
47+
enabled?
48+
end
49+
50+
private
51+
52+
def enabled?
53+
@configuration['enabled']
4854
end
4955

5056
end

spec/java_buildpack/framework/container_security_provider_spec.rb

+44-25
Original file line numberDiff line numberDiff line change
@@ -22,51 +22,70 @@
2222
describe JavaBuildpack::Framework::ContainerSecurityProvider do
2323
include_context 'with component help'
2424

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
2729
end
2830

29-
it 'adds extension directory' do
30-
component.release
31+
let(:version_8) { JavaBuildpack::Util::TokenizedVersion.new('1.8.0_162') }
3132

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
3337
end
3438

35-
it 'adds security provider',
36-
cache_fixture: 'stub-container-security-provider.jar' do
39+
context 'when enabled' do
3740

38-
component.compile
39-
expect(security_providers[1]).to eq('org.cloudfoundry.security.CloudFoundryContainerProvider')
40-
end
41+
let(:configuration) { { 'enabled' => true } }
4142

42-
context do
43+
it 'detects if enabled' do
44+
expect(component.detect).to eq("container-security-provider=#{version}")
45+
end
4346

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
4849

49-
delegate
50+
expect(extension_directories).to include(droplet.sandbox)
5051
end
5152

52-
it 'adds JAR to classpath during compile in Java 9',
53+
it 'adds security provider',
5354
cache_fixture: 'stub-container-security-provider.jar' do
5455

5556
component.compile
5657

57-
expect(additional_libraries).to include(droplet.sandbox + "container_security_provider-#{version}.jar")
58+
expect(security_providers[1]).to eq('org.cloudfoundry.security.CloudFoundryContainerProvider')
5859
end
5960

60-
it 'adds JAR to classpath during release in Java 9' do
61-
component.release
61+
context 'when java 9' do
6262

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
6565

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
6888

69-
expect(extension_directories).not_to include(droplet.sandbox)
7089
end
7190

7291
end

0 commit comments

Comments
 (0)