Skip to content
This repository has been archived by the owner on Aug 12, 2022. It is now read-only.

Commit

Permalink
Catch ASG error
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoqin-github committed Sep 27, 2019
1 parent 49db0cb commit 7e21708
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
4 changes: 1 addition & 3 deletions app/waf/src/controllers/wafpolicy.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,7 @@ export class WafpolicyController extends BaseController {
wafpolicy.id,
);
} catch (error) {
throw new HttpErrors.unprocessableEntity(
'check wafpolicy from asg service failed',
);
throw new HttpErrors.UnprocessableEntity(`ASG error: ${error.message}`);
}

if (!resp || !resp[0]) {
Expand Down
27 changes: 27 additions & 0 deletions app/waf/test/acceptance/wafpolicy.controller.acceptance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,33 @@ describe('WafpolicyController', () => {
},
);

it(
'get ' +
prefix +
'/wafpolicies/${id}/adcs/${adcId}: ASG fails when check wafpolicy',
async () => {
const wafpolicy = await givenWafpolicyData(wafapp, {
tenantId: 'a random id',
public: true,
});

const adc = await givenAdcData(wafapp, {
management: {
trustedDeviceId: uuid(),
},
});

checkWafpolicyStub.throws(new Error('OMG'));

const resp = await client
.get(prefix + `/wafpolicies/${wafpolicy.id}/adcs/${adc.id}`)
.set('X-Auth-Token', ExpectedData.userToken)
.set('tenant-id', ExpectedData.tenantId)
.expect(422);

expect(resp.body.error.message).equal('ASG error: OMG');
},
);
it('get ' + prefix + '/wafpolicies: of all', async () => {
const wafpolicy = await givenWafpolicyData(wafapp);

Expand Down

0 comments on commit 7e21708

Please sign in to comment.