Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions lib/src/wso2/wso2-api/handler/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,25 @@ describe('wso2 custom resource lambda', () => {
expect(eres.Status).toBe('SUCCESS');
});

it('should return success when api does not exists on DELETE operation', async () => {
nockBasicWso2SDK();

// api update mock
nock(baseWso2Url)
.delete(/.*\/publisher\/v1\/apis\/.*$/)
.reply(404);

const eres = await handler(
testCFNEventDelete(
{
...testEvent,
},
'123-456',
),
);
expect(eres.Status).toBe('SUCCESS');
});

const toResultList = (apiDefs: PublisherPortalAPIv1): { list: ApiFromListV1[] } => {
return {
list: [
Expand Down
7 changes: 6 additions & 1 deletion lib/src/wso2/wso2-api/handler/wso2-v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,12 @@ export const removeApiInWso2 = async (args: {
if (!args.wso2ApiId) {
throw new Error('wso2ApiId is required for deleting API');
}
await args.wso2Axios.delete(`/api/am/publisher/v1/apis/${args.wso2ApiId}`);
await args.wso2Axios.delete(`/api/am/publisher/v1/apis/${args.wso2ApiId}`, {
validateStatus(status) {
// If it returns 404, the api is already deleted
return status === 200 || status === 404;
},
});
};

/**
Expand Down