diff --git a/integrationTests/basic/jwt_auth.test.js b/integrationTests/basic/jwt_auth.test.js index c761bd4..423758d 100644 --- a/integrationTests/basic/jwt_auth.test.js +++ b/integrationTests/basic/jwt_auth.test.js @@ -233,6 +233,15 @@ describe('jwt auth', () => { expect(core.exportVariable).toBeCalledWith('SECRET', 'SUPERSECRET'); }) + it('successfully authenticates as default role without specifying it', async () => { + when(core.getInput) + .calledWith('role') + .mockReturnValueOnce(null); + + await exportSecrets(); + expect(core.exportVariable).toBeCalledWith('SECRET', 'SUPERSECRET'); + }) + }); }); diff --git a/src/auth.js b/src/auth.js index ba89eeb..5e9cb20 100644 --- a/src/auth.js +++ b/src/auth.js @@ -25,7 +25,7 @@ async function retrieveToken(method, client) { case 'jwt': { /** @type {string} */ let jwt; - const role = core.getInput('role', { required: true }); + const role = core.getInput('role', { required: false }); const privateKeyRaw = core.getInput('jwtPrivateKey', { required: false }); const privateKey = Buffer.from(privateKeyRaw, 'base64').toString(); const keyPassword = core.getInput('jwtKeyPassword', { required: false });