Skip to content

Add cacerts parameter, which can copy existing cacerts into JDK #284

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -20,10 +20,10 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v2
- name: Setup Node.JS 12
- name: Setup Node.JS 16
uses: actions/setup-node@v2
with:
node-version: 12.x
node-version: 16.x
cache: npm
- run: npm ci
- run: npm run build
4 changes: 2 additions & 2 deletions .github/workflows/check-dist.yml
Original file line number Diff line number Diff line change
@@ -23,10 +23,10 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Set Node.js 12.x
- name: Set Node.js 16.x
uses: actions/setup-node@v1
with:
node-version: 12.x
node-version: 16.x

- name: Install dependencies
run: npm ci
2 changes: 1 addition & 1 deletion .github/workflows/licensed.yml
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ jobs:
- name: Install licensed
run: |
cd $RUNNER_TEMP
curl -Lfs -o licensed.tar.gz https://github.com/github/licensed/releases/download/3.3.1/licensed-3.3.1-linux-x64.tar.gz
curl -Lfs -o licensed.tar.gz https://github.com/github/licensed/releases/download/3.4.4/licensed-3.4.4-linux-x64.tar.gz
sudo tar -xzf licensed.tar.gz
sudo mv licensed /usr/local/bin/licensed
- run: licensed status

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .licenses/npm/node-fetch.dep.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -144,6 +144,7 @@ jobs:
- [Installing custom Java package type](docs/advanced-usage.md#Installing-custom-Java-package-type)
- [Installing custom Java architecture](docs/advanced-usage.md#Installing-custom-Java-architecture)
- [Installing custom Java distribution from local file](docs/advanced-usage.md#Installing-Java-from-local-file)
- [Using existing cacerts file](docs/advanced-usage.md#Using-existing-cacerts-file)
- [Testing against different Java distributions](docs/advanced-usage.md#Testing-against-different-Java-distributions)
- [Testing against different platforms](docs/advanced-usage.md#Testing-against-different-platforms)
- [Publishing using Apache Maven](docs/advanced-usage.md#Publishing-using-Apache-Maven)
41 changes: 41 additions & 0 deletions __tests__/distributors/base-installer.test.ts
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@ import {
JavaInstallerOptions,
JavaInstallerResults
} from '../../src/distributions/base-models';
import fs from "fs";

class EmptyJavaBase extends JavaBase {
constructor(installerOptions: JavaInstallerOptions) {
@@ -349,3 +350,43 @@ describe('getToolcacheVersionName', () => {
expect(actual).toBe(expected);
});
});

describe('initCacerts', () => {
const DummyJavaBase = JavaBase as any;

let spyFsCopyFileSync: jest.SpyInstance;

beforeEach(() => {
spyFsCopyFileSync = jest.spyOn(fs, 'copyFileSync').mockImplementation();
});

afterEach(() => {
jest.resetAllMocks();
jest.clearAllMocks();
jest.restoreAllMocks();
});

it('should do nothing when not set', () => {
const mockJavaBase = new EmptyJavaBase({
version: '11',
packageType: 'jdk',
architecture: 'x64',
checkLatest: false,
cacerts: '',
});
DummyJavaBase.prototype.initCacerts.call(mockJavaBase, '/tmp/dummy_jdk');
expect(spyFsCopyFileSync).not.toHaveBeenCalled()
});

it('should copy cacerts file', () => {
const mockJavaBase = new EmptyJavaBase({
version: '11',
packageType: 'jdk',
architecture: 'x64',
checkLatest: false,
cacerts: '/etc/ssl/certs/java/cacerts',
});
DummyJavaBase.prototype.initCacerts.call(mockJavaBase, '/tmp/dummy_jdk');
expect(spyFsCopyFileSync).toHaveBeenCalledWith('/etc/ssl/certs/java/cacerts', path.join('/tmp/dummy_jdk', 'lib/security/cacerts'))
});
});
5 changes: 4 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
@@ -24,6 +24,9 @@ inputs:
description: 'Set this option if you want the action to check for the latest available version that satisfies the version spec'
required: false
default: false
cacerts:
description: 'Copy cacerts file from given path into newly downloaded Java installation'
required: false
server-id:
description: 'ID of the distributionManagement repository in the pom.xml
file. Default is `github`'
@@ -67,6 +70,6 @@ outputs:
path:
description: 'Path to where the java environment has been installed (same as $JAVA_HOME)'
runs:
using: 'node12'
using: 'node16'
main: 'dist/setup/index.js'
post: 'dist/cleanup/index.js'
Loading