github: translate access controls permissions

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2023-02-03 04:09:04 +01:00
parent ad59af8cf2
commit 3e2548a8ed
No known key found for this signature in database
GPG key ID: 3248E46B6BB8C7F7
3 changed files with 40 additions and 20 deletions

View file

@ -107,12 +107,12 @@ describe('actionsRuntimeToken', () => {
it('fixture', async () => {
process.env.ACTIONS_RUNTIME_TOKEN = fs.readFileSync(path.join(__dirname, 'fixtures', 'runtimeToken.txt')).toString().trim();
const runtimeToken = GitHub.actionsRuntimeToken;
expect(runtimeToken.ac).toEqual('[{"Scope":"refs/heads/master","Permission":3}]');
expect(runtimeToken.iss).toEqual('vstoken.actions.githubusercontent.com');
expect(runtimeToken?.ac).toEqual('[{"Scope":"refs/heads/master","Permission":3}]');
expect(runtimeToken?.iss).toEqual('vstoken.actions.githubusercontent.com');
});
});
describe('printActionsRuntimeToken', () => {
describe('printActionsRuntimeTokenACs', () => {
const originalEnv = process.env;
beforeEach(() => {
jest.resetModules();
@ -126,18 +126,13 @@ describe('printActionsRuntimeToken', () => {
it('empty', async () => {
const execSpy = jest.spyOn(core, 'info');
process.env.ACTIONS_RUNTIME_TOKEN = '';
GitHub.printActionsRuntimeToken();
await GitHub.printActionsRuntimeTokenACs();
expect(execSpy).toHaveBeenCalledWith(`ACTIONS_RUNTIME_TOKEN not set`);
});
it('prints ac', () => {
it('refs/heads/master', async () => {
const execSpy = jest.spyOn(core, 'info');
process.env.ACTIONS_RUNTIME_TOKEN = fs.readFileSync(path.join(__dirname, 'fixtures', 'runtimeToken.txt')).toString().trim();
GitHub.printActionsRuntimeToken();
expect(execSpy).toHaveBeenCalledWith(`[
{
"Scope": "refs/heads/master",
"Permission": 3
}
]`);
await GitHub.printActionsRuntimeTokenACs();
expect(execSpy).toHaveBeenCalledWith(`refs/heads/master: read/write`);
});
});