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

Commit 7e21708

Browse files
Catch ASG error
1 parent 49db0cb commit 7e21708

2 files changed

Lines changed: 28 additions & 3 deletions

File tree

app/waf/src/controllers/wafpolicy.controller.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,7 @@ export class WafpolicyController extends BaseController {
227227
wafpolicy.id,
228228
);
229229
} catch (error) {
230-
throw new HttpErrors.unprocessableEntity(
231-
'check wafpolicy from asg service failed',
232-
);
230+
throw new HttpErrors.UnprocessableEntity(`ASG error: ${error.message}`);
233231
}
234232

235233
if (!resp || !resp[0]) {

app/waf/test/acceptance/wafpolicy.controller.acceptance.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,33 @@ describe('WafpolicyController', () => {
236236
},
237237
);
238238

239+
it(
240+
'get ' +
241+
prefix +
242+
'/wafpolicies/${id}/adcs/${adcId}: ASG fails when check wafpolicy',
243+
async () => {
244+
const wafpolicy = await givenWafpolicyData(wafapp, {
245+
tenantId: 'a random id',
246+
public: true,
247+
});
248+
249+
const adc = await givenAdcData(wafapp, {
250+
management: {
251+
trustedDeviceId: uuid(),
252+
},
253+
});
254+
255+
checkWafpolicyStub.throws(new Error('OMG'));
256+
257+
const resp = await client
258+
.get(prefix + `/wafpolicies/${wafpolicy.id}/adcs/${adc.id}`)
259+
.set('X-Auth-Token', ExpectedData.userToken)
260+
.set('tenant-id', ExpectedData.tenantId)
261+
.expect(422);
262+
263+
expect(resp.body.error.message).equal('ASG error: OMG');
264+
},
265+
);
239266
it('get ' + prefix + '/wafpolicies: of all', async () => {
240267
const wafpolicy = await givenWafpolicyData(wafapp);
241268

0 commit comments

Comments
 (0)