-
Notifications
You must be signed in to change notification settings - Fork 757
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #63 from jaredpetersen/master
Added support for GPG signing
- Loading branch information
Showing
17 changed files
with
37,572 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import path = require('path'); | ||
import io = require('@actions/io'); | ||
import exec = require('@actions/exec'); | ||
|
||
jest.mock('@actions/exec', () => { | ||
return { | ||
exec: jest.fn() | ||
}; | ||
}); | ||
|
||
const tempDir = path.join(__dirname, 'runner', 'temp'); | ||
process.env['RUNNER_TEMP'] = tempDir; | ||
|
||
import gpg = require('../src/gpg'); | ||
|
||
describe('gpg tests', () => { | ||
beforeEach(async () => { | ||
await io.mkdirP(tempDir); | ||
}); | ||
|
||
afterAll(async () => { | ||
try { | ||
await io.rmRF(tempDir); | ||
} catch { | ||
console.log('Failed to remove test directories'); | ||
} | ||
}); | ||
|
||
describe('importKey', () => { | ||
it('attempts to import private key and returns null key id on failure', async () => { | ||
const privateKey = 'KEY CONTENTS'; | ||
const keyId = await gpg.importKey(privateKey); | ||
|
||
expect(keyId).toBeNull(); | ||
|
||
expect(exec.exec).toHaveBeenCalledWith( | ||
'gpg', | ||
expect.anything(), | ||
expect.anything() | ||
); | ||
}); | ||
}); | ||
|
||
describe('deleteKey', () => { | ||
it('deletes private key', async () => { | ||
const keyId = 'asdfhjkl'; | ||
await gpg.deleteKey(keyId); | ||
|
||
expect(exec.exec).toHaveBeenCalledWith( | ||
'gpg', | ||
expect.anything(), | ||
expect.anything() | ||
); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import path = require('path'); | ||
|
||
const env = process.env; | ||
|
||
describe('util tests', () => { | ||
beforeEach(() => { | ||
const tempEnv = Object.assign({}, env); | ||
delete tempEnv.RUNNER_TEMP; | ||
delete tempEnv.USERPROFILE; | ||
process.env = tempEnv; | ||
Object.defineProperty(process, 'platform', {value: 'linux'}); | ||
}); | ||
|
||
describe('getTempDir', () => { | ||
it('gets temp dir using env', () => { | ||
process.env['RUNNER_TEMP'] = 'defaulttmp'; | ||
const util = require('../src/util'); | ||
|
||
const tempDir = util.getTempDir(); | ||
|
||
expect(tempDir).toEqual(process.env['RUNNER_TEMP']); | ||
}); | ||
|
||
it('gets temp dir for windows using userprofile', () => { | ||
Object.defineProperty(process, 'platform', {value: 'win32'}); | ||
process.env['USERPROFILE'] = 'winusertmp'; | ||
const util = require('../src/util'); | ||
|
||
const tempDir = util.getTempDir(); | ||
|
||
expect(tempDir).toEqual( | ||
path.join(process.env['USERPROFILE'], 'actions', 'temp') | ||
); | ||
}); | ||
|
||
it('gets temp dir for windows using c drive', () => { | ||
Object.defineProperty(process, 'platform', {value: 'win32'}); | ||
const util = require('../src/util'); | ||
|
||
const tempDir = util.getTempDir(); | ||
|
||
expect(tempDir).toEqual(path.join('C:\\', 'actions', 'temp')); | ||
}); | ||
|
||
it('gets temp dir for mac', () => { | ||
Object.defineProperty(process, 'platform', {value: 'darwin'}); | ||
const util = require('../src/util'); | ||
|
||
const tempDir = util.getTempDir(); | ||
|
||
expect(tempDir).toEqual(path.join('/Users', 'actions', 'temp')); | ||
}); | ||
|
||
it('gets temp dir for linux', () => { | ||
const util = require('../src/util'); | ||
const tempDir = util.getTempDir(); | ||
|
||
expect(tempDir).toEqual(path.join('/home', 'actions', 'temp')); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.