|
| 1 | +import faker from 'faker'; |
| 2 | +import nock from 'nock'; |
| 3 | +import { JfrogClient } from '../../../src'; |
| 4 | +import { TestUtils } from '../../TestUtils'; |
| 5 | + |
| 6 | +describe('Xray jas config tests', () => { |
| 7 | + test('Get jas config', async () => { |
| 8 | + const PLATFORM_URL: string = faker.internet.url(); |
| 9 | + const uri: string = `/xray/api/v1/configuration/jas`; |
| 10 | + const expectedResource: string = '{"enable_token_validation_scanning": true}'; |
| 11 | + nock(PLATFORM_URL).get(uri).reply(200, expectedResource); |
| 12 | + const client: JfrogClient = new JfrogClient({ platformUrl: PLATFORM_URL, logger: TestUtils.createTestLogger() }); |
| 13 | + const res: any = await client.xray().jasconfig().getJasConfig(); |
| 14 | + expect(res).toHaveProperty("enable_token_validation_scanning") |
| 15 | + expect(res.enable_token_validation_scanning).toEqual(true) |
| 16 | + }); |
| 17 | +}); |
| 18 | + |
| 19 | +describe('Xray jas config tests', () => { |
| 20 | + test('Fail get jas config', async () => { |
| 21 | + const PLATFORM_URL: string = faker.internet.url(); |
| 22 | + const uri: string = `/xray/api/v1/configuration/jas`; |
| 23 | + nock(PLATFORM_URL).get(uri).reply(402, { message: 'error' }).persist(); |
| 24 | + const client: JfrogClient = new JfrogClient({ platformUrl: PLATFORM_URL, logger: TestUtils.createTestLogger() }) |
| 25 | + await expect(async () => { |
| 26 | + await client |
| 27 | + .xray() |
| 28 | + .jasconfig() |
| 29 | + .getJasConfig(); |
| 30 | + }).rejects.toThrow(`Request failed with status code 402`); |
| 31 | + }); |
| 32 | +}); |
0 commit comments