mirror of
https://github.com/actions/setup-java.git
synced 2025-04-21 10:26:46 +00:00
Add cacerts parameter, which can copy existing cacerts into JDK
This commit is contained in:
parent
d53b046579
commit
0d42bcacb6
11 changed files with 2167 additions and 2075 deletions
|
@ -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'))
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue