diff options
| author | Can Eldem <celdem@gitlab.com> | 2020-09-16 12:28:31 +0000 |
|---|---|---|
| committer | Can Eldem <celdem@gitlab.com> | 2020-09-16 12:28:31 +0000 |
| commit | 7a01aa5dba4b8df24419c2e45ead6efe5698a0a9 (patch) | |
| tree | 8f587d0cd6edb5c8706ac155448993f8c07b4f2e | |
| parent | b9f82cd57910e02bbe6cf5bd6ae36b28eb7b0e83 (diff) | |
| parent | aa53a1a3fc69f42965c1569ce4496aaccae265f9 (diff) | |
Merge branch 'java-11-keystore' into 'master'v3.25.7
Install x509 cert into Java 11 keystore
See merge request gitlab-org/security-products/license-management!221
| -rw-r--r-- | CHANGELOG.md | 4 | ||||
| -rw-r--r-- | Gemfile.lock | 2 | ||||
| -rw-r--r-- | lib/license/management/tool_box.rb | 8 | ||||
| -rw-r--r-- | lib/license/management/version.rb | 2 | ||||
| -rw-r--r-- | spec/integration/java/maven_spec.rb | 36 |
5 files changed, 30 insertions, 22 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c9da7e..e57de66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # GitLab License management changelog +## v3.25.7 + +- Fix path to Java 11 keystore !221 + ## v3.25.6 - Install `build-essential` for development !219 diff --git a/Gemfile.lock b/Gemfile.lock index 298ddce..e008f1d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,7 +8,7 @@ GIT PATH remote: . specs: - license-management (3.25.6) + license-management (3.25.7) license_finder (~> 6.7) GEM diff --git a/lib/license/management/tool_box.rb b/lib/license/management/tool_box.rb index 0e39a61..239f88f 100644 --- a/lib/license/management/tool_box.rb +++ b/lib/license/management/tool_box.rb @@ -26,7 +26,7 @@ module License shell.execute([:asdf, :reshim], env: env) end install_common_libraries(env: env) if C_BASED_TOOLS.include?(tool.to_sym) - install_certificates_into_java_keystore(env) if tool == :java + install_certificates_into_java_keystore(env, version) if tool == :java end def install_common_libraries(env: {}) @@ -116,10 +116,12 @@ module License asdf_detected_version_of(:java) end - def install_certificates_into_java_keystore(env) + def install_certificates_into_java_keystore(env, version) + java_home = Pathname.new(env['JAVA_HOME']) + keystore_path = java_home.join("8" == version ? "jre/lib/security/cacerts" : "lib/security/cacerts") + Dir.chdir shell.custom_certificate_path.dirname do Dir.glob('custom.*.crt').each do |path| - keystore_path = "#{env['JAVA_HOME']}/jre/lib/security/cacerts" shell.execute([:keytool, '-importcert', '-alias', Time.now.to_i, '-file', File.expand_path(path), '-trustcacerts', '-noprompt', '-storepass', 'changeit', '-keystore', keystore_path], env: env) shell.execute([:keytool, '-list', '-v', '-storepass changeit', '-keystore', keystore_path], env: env) end diff --git a/lib/license/management/version.rb b/lib/license/management/version.rb index cc17c36..8e2f460 100644 --- a/lib/license/management/version.rb +++ b/lib/license/management/version.rb @@ -2,6 +2,6 @@ module License module Management - VERSION = '3.25.6' + VERSION = '3.25.7' end end diff --git a/spec/integration/java/maven_spec.rb b/spec/integration/java/maven_spec.rb index 671243e..ca26d28 100644 --- a/spec/integration/java/maven_spec.rb +++ b/spec/integration/java/maven_spec.rb @@ -90,25 +90,27 @@ RSpec.describe "maven" do end end - context "when connecting to a custom package registry with a self signed certificate" do - let(:env) { { 'ADDITIONAL_CA_CERT_BUNDLE' => x509_certificate.read } } - - before do - runner.add_file('pom.xml') do - fixture_file_content('java/maven/pom-single.xml.erb', { - group_id: 'com.fasterxml.jackson.core', - artifact_id: 'jackson-core', - version: '2.10.0', - repository_id: 'custom', - repository_url: "https://maven.test/maven2" - }) + [8, 11].each do |java_version| + context "when connecting to a custom package registry with a self signed certificate using JAVA #{java_version}" do + let(:env) { { 'ADDITIONAL_CA_CERT_BUNDLE' => x509_certificate.read, 'LM_JAVA_VERSION' => java_version.to_s } } + + before do + runner.add_file('pom.xml') do + fixture_file_content('java/maven/pom-single.xml.erb', { + group_id: 'com.fasterxml.jackson.core', + artifact_id: 'jackson-core', + version: '2.10.0', + repository_id: 'custom', + repository_url: "https://maven.test/maven2" + }) + end end - end - specify do - expect(subject).to match_schema - expect(subject.dependency_names).to match_array(['jackson-core']) - expect(subject.licenses_for('jackson-core')).to match_array(['Apache-2.0']) + specify do + expect(subject).to match_schema + expect(subject.dependency_names).to match_array(['jackson-core']) + expect(subject.licenses_for('jackson-core')).to match_array(['Apache-2.0']) + end end end |
