Skip to content

Commit

Permalink
test: add closed box test
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterSchafer committed May 17, 2024
1 parent 1e1bf1f commit 0bb78ad
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions test/jest/acceptance/auth.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ describe('Auth', () => {

beforeEach(async () => {
initialConfig = await getCliConfig();
// delete config
await runSnykCLI(`config clear`, {
env,
});
});

afterEach(async () => {
Expand All @@ -51,11 +55,6 @@ describe('Auth', () => {
},
);
expect(code).toEqual(0);

// delete test token
await runSnykCLI(`config unset INTERNAL_OAUTH_TOKEN_STORAGE`, {
env,
});
});

it('fails to us oauth client credentials grant to authenticate', async () => {
Expand Down Expand Up @@ -90,4 +89,18 @@ describe('Auth', () => {
expect(resultConfigGet.code).toEqual(0);
expect(resultConfigGet.stdout).toContain(serverToken);
});

it('fall back to API token based authentication for IDEs per default', async () => {
const { code } = await runSnykCLI(`auth`, {
env: { ...env, SNYK_INTEGRATION_NAME: 'VS_CODE' },
});

const resultConfigGet = await runSnykCLI('config get api', {
env,
});

expect(code).toEqual(0);
expect(resultConfigGet.code).toEqual(0);
expect(resultConfigGet.stdout).toContain(serverToken);
});
});

0 comments on commit 0bb78ad

Please sign in to comment.