Support loading GPG private key from file path.

This commit is contained in:
Warren Seine 2020-08-05 23:02:41 +02:00
parent 3019d15cad
commit b9a18e1677
8 changed files with 86 additions and 35 deletions

View file

@ -1,4 +1,5 @@
import path = require('path');
import fs = require('fs');
import io = require('@actions/io');
import exec = require('@actions/exec');
@ -41,6 +42,23 @@ describe('gpg tests', () => {
});
});
describe('importKeyFromPath', () => {
it('attempts to import private key from path and returns null key id on failure', async () => {
const privateKey = 'KEY CONTENTS';
const privateKeyPath = path.join(tempDir, 'test.asc');
fs.writeFileSync(privateKeyPath, privateKey);
const keyId = await gpg.importKeyFromPath(privateKeyPath);
expect(keyId).toBeNull();
expect(exec.exec).toHaveBeenCalledWith(
'gpg',
expect.anything(),
expect.anything()
);
});
});
describe('deleteKey', () => {
it('deletes private key', async () => {
const keyId = 'asdfhjkl';