From 1ecbe18c8bc93d2b5fc06361f9130fdd0b7e3f9d Mon Sep 17 00:00:00 2001 From: Jared Petersen Date: Sun, 10 May 2020 22:46:48 -0700 Subject: [PATCH] use runner temp for private key directory --- __tests__/auth.test.ts | 17 +++++++++-------- dist/index.js | Bin 170076 -> 169915 bytes src/auth.ts | 20 ++++++++------------ 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/__tests__/auth.test.ts b/__tests__/auth.test.ts index 1e62aa9f..e7b4c032 100644 --- a/__tests__/auth.test.ts +++ b/__tests__/auth.test.ts @@ -19,11 +19,12 @@ jest.mock('@actions/exec', () => { import * as auth from '../src/auth'; -const env = process.env; const m2Dir = path.join(__dirname, auth.M2_DIR); const settingsFile = path.join(m2Dir, auth.SETTINGS_FILE); -const privateKeyDir = path.join(__dirname, auth.PRIVATE_KEY_DIR); -const privateKeyFile = auth.PRIVATE_KEY_FILE; +const tempDir = path.join(__dirname, 'runner', 'temp'); +const privateKeyFile = path.join(tempDir, auth.PRIVATE_KEY_FILE); + +process.env['RUNNER_TEMP'] = tempDir; describe('auth tests', () => { beforeEach(async () => { @@ -33,7 +34,7 @@ describe('auth tests', () => { afterAll(async () => { try { await io.rmRF(m2Dir); - await io.rmRF(privateKeyDir); + await io.rmRF(tempDir); } catch { console.log('Failed to remove test directories'); } @@ -176,11 +177,11 @@ describe('auth tests', () => { expect(exec.exec).toHaveBeenCalledWith( 'gpg', - ['--import', '--batch', privateKeyFile], - {cwd: privateKeyDir} + expect.anything(), + expect.anything() ); - expect(fs.existsSync(privateKeyDir)).toBe(false); + expect(fs.existsSync(privateKeyFile)).toBe(false); }, 100000); it('does not import gpg private key when private key is not set', async () => { @@ -196,6 +197,6 @@ describe('auth tests', () => { expect.anything() ); - expect(fs.existsSync(privateKeyDir)).toBe(false); + expect(fs.existsSync(privateKeyFile)).toBe(false); }, 100000); }); diff --git a/dist/index.js b/dist/index.js index 4ec5c6b4766b4d829eceacc3ff416f42e3353ff9..b708bbe3a55098c38df1efe8375163484bcba23b 100644 GIT binary patch delta 228 zcmcb!fou1Au7)j)>Cqe^uD${BE}lWt-%e$enBJ4b#5+Acn$c$azGy}l*69H?Ol;Hj zlNi~V1Kc&H^CmG$Ouo%8x_w6yqad3AP$<11J)kJFEU_fjJGF9hql}MOc~NFbszz!> zL4Hw5u^!y?kBN*Xtd*ImIVsb%G8wg|e@Cw~YL^GQ3xOfIB*ea;&Wv5maZ{Hcs7|l9eAe@OsuSB7sD6=fF zB-J~$(j~JfHMu0es1m5MAh9GvFDpMYPb0rrFC#xUH6^o1Lv#AZ3`Q|#pjp!wR5OWA zKO4`;C5A=6rZv~}^>Y{{rvHy;6cNRupf&+wz`k@wHeoFCAbX^yze@)atE-u~6f$!Q z@{3B`3(|qE)WD%$diug@CK1V^)ZF~CR4j_N8zeFsv57*=0Qv^vRUL)2%$(H8jWTZ2 pW#2NgPv^^E)RY7X#p)