Skip to content

Commit

Permalink
Add cacerts parameter, which can copy existing cacerts into JDK
Browse files Browse the repository at this point in the history
  • Loading branch information
mdvorak committed Mar 16, 2022
1 parent d53b046 commit 0d42bca
Show file tree
Hide file tree
Showing 11 changed files with 2,167 additions and 2,075 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
41 changes: 41 additions & 0 deletions __tests__/distributors/base-installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
JavaInstallerOptions,
JavaInstallerResults
} from '../../src/distributions/base-models';
import fs from "fs";

class EmptyJavaBase extends JavaBase {
constructor(installerOptions: JavaInstallerOptions) {
Expand Down Expand Up @@ -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'))
});
});
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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`'
Expand Down
Loading

0 comments on commit 0d42bca

Please sign in to comment.