Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

55 changes: 0 additions & 55 deletions .eslintrc.json

This file was deleted.

79 changes: 78 additions & 1 deletion __tests__/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import * as security from '../src/security'
import * as core from '@actions/core'
import * as exec from '@actions/exec'
import * as security from '../src/security.js'

test('imports p12 file', async () => {
const keychain: string = 'signing_temp'
Expand All @@ -15,4 +17,79 @@ test('imports p12 file', async () => {
)

await security.deleteKeychain(keychain)

expect(exec.exec).toHaveBeenNthCalledWith(
1,
'security',
['create-keychain', '-p', keychainPassword, 'signing_temp.keychain'],
expect.any(Object)
)
expect(exec.exec).toHaveBeenNthCalledWith(
2,
'security',
['set-keychain-settings', '-lut', '21600', 'signing_temp.keychain'],
expect.any(Object)
)
expect(exec.exec).toHaveBeenNthCalledWith(
3,
'security',
['unlock-keychain', '-p', keychainPassword, 'signing_temp.keychain'],
expect.any(Object)
)
expect(exec.exec).toHaveBeenNthCalledWith(
4,
'security',
[
'import',
p12FilePath,
'-k',
'signing_temp.keychain',
'-f',
'pkcs12',
'-A',
'-T',
'/usr/bin/codesign',
'-T',
'/usr/bin/security',
'-P',
p12Password
],
expect.any(Object)
)
expect(exec.exec).toHaveBeenNthCalledWith(
5,
'security',
[
'set-key-partition-list',
'-S',
'apple-tool:,apple:',
'-k',
keychainPassword,
'signing_temp.keychain'
],
undefined
)
expect(exec.exec).toHaveBeenNthCalledWith(
6,
'security',
[
'list-keychains',
'-d',
'user',
'-s',
'signing_temp.keychain',
'login.keychain'
],
expect.any(Object)
)
expect(exec.exec).toHaveBeenNthCalledWith(
7,
'security',
['delete-keychain', 'signing_temp.keychain'],
undefined
)
expect(core.setOutput).toHaveBeenCalledWith(
'security-response',
expect.stringContaining('security')
)
})
5 changes: 5 additions & 0 deletions __tests__/mocks/actions-core.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { jest } from '@jest/globals';
export const getInput = jest.fn(() => '');
export const setFailed = jest.fn();
export const setOutput = jest.fn();
export const setSecret = jest.fn();
6 changes: 6 additions & 0 deletions __tests__/mocks/actions-core.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import {jest} from '@jest/globals'

export const getInput = jest.fn(() => '')
export const setFailed = jest.fn()
export const setOutput = jest.fn()
export const setSecret = jest.fn()
6 changes: 6 additions & 0 deletions __tests__/mocks/actions-exec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { jest } from '@jest/globals';
export const exec = jest.fn(async (commandLine, args, options) => {
const renderedArgs = args?.join(' ') ?? '';
options?.listeners?.stdout?.(Buffer.from(`${commandLine} ${renderedArgs}\n`));
return 0;
});
17 changes: 17 additions & 0 deletions __tests__/mocks/actions-exec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {jest} from '@jest/globals'

export const exec = jest.fn(
async (
commandLine: string,
args?: string[],
options?: {
listeners?: {
stdout?: (data: Buffer) => void
}
}
) => {
const renderedArgs = args?.join(' ') ?? ''
options?.listeners?.stdout?.(Buffer.from(`${commandLine} ${renderedArgs}\n`))
return 0
}
)
Loading