Skip to content

Commit 0d42bca

Browse files
committed
Add cacerts parameter, which can copy existing cacerts into JDK
1 parent d53b046 commit 0d42bca

11 files changed

Lines changed: 2167 additions & 2075 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ jobs:
144144
- [Installing custom Java package type](docs/advanced-usage.md#Installing-custom-Java-package-type)
145145
- [Installing custom Java architecture](docs/advanced-usage.md#Installing-custom-Java-architecture)
146146
- [Installing custom Java distribution from local file](docs/advanced-usage.md#Installing-Java-from-local-file)
147+
- [Using existing cacerts file](docs/advanced-usage.md#Using-existing-cacerts-file)
147148
- [Testing against different Java distributions](docs/advanced-usage.md#Testing-against-different-Java-distributions)
148149
- [Testing against different platforms](docs/advanced-usage.md#Testing-against-different-platforms)
149150
- [Publishing using Apache Maven](docs/advanced-usage.md#Publishing-using-Apache-Maven)

__tests__/distributors/base-installer.test.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
JavaInstallerOptions,
1212
JavaInstallerResults
1313
} from '../../src/distributions/base-models';
14+
import fs from "fs";
1415

1516
class EmptyJavaBase extends JavaBase {
1617
constructor(installerOptions: JavaInstallerOptions) {
@@ -349,3 +350,43 @@ describe('getToolcacheVersionName', () => {
349350
expect(actual).toBe(expected);
350351
});
351352
});
353+
354+
describe('initCacerts', () => {
355+
const DummyJavaBase = JavaBase as any;
356+
357+
let spyFsCopyFileSync: jest.SpyInstance;
358+
359+
beforeEach(() => {
360+
spyFsCopyFileSync = jest.spyOn(fs, 'copyFileSync').mockImplementation();
361+
});
362+
363+
afterEach(() => {
364+
jest.resetAllMocks();
365+
jest.clearAllMocks();
366+
jest.restoreAllMocks();
367+
});
368+
369+
it('should do nothing when not set', () => {
370+
const mockJavaBase = new EmptyJavaBase({
371+
version: '11',
372+
packageType: 'jdk',
373+
architecture: 'x64',
374+
checkLatest: false,
375+
cacerts: '',
376+
});
377+
DummyJavaBase.prototype.initCacerts.call(mockJavaBase, '/tmp/dummy_jdk');
378+
expect(spyFsCopyFileSync).not.toHaveBeenCalled()
379+
});
380+
381+
it('should copy cacerts file', () => {
382+
const mockJavaBase = new EmptyJavaBase({
383+
version: '11',
384+
packageType: 'jdk',
385+
architecture: 'x64',
386+
checkLatest: false,
387+
cacerts: '/etc/ssl/certs/java/cacerts',
388+
});
389+
DummyJavaBase.prototype.initCacerts.call(mockJavaBase, '/tmp/dummy_jdk');
390+
expect(spyFsCopyFileSync).toHaveBeenCalledWith('/etc/ssl/certs/java/cacerts', path.join('/tmp/dummy_jdk', 'lib/security/cacerts'))
391+
});
392+
});

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ inputs:
2424
description: 'Set this option if you want the action to check for the latest available version that satisfies the version spec'
2525
required: false
2626
default: false
27+
cacerts:
28+
description: 'Copy cacerts file from given path into newly downloaded Java installation'
29+
required: false
2730
server-id:
2831
description: 'ID of the distributionManagement repository in the pom.xml
2932
file. Default is `github`'

0 commit comments

Comments
 (0)