From e13f234bd5855af7562fd8ef6aea2ef4e461d6f1 Mon Sep 17 00:00:00 2001 From: ajaz Date: Thu, 21 Nov 2024 12:52:57 +0530 Subject: [PATCH 1/8] feat: remove api key creation from create and delete commands --- src/commands/api-mesh/create.js | 6 ++--- src/commands/api-mesh/delete.js | 21 ----------------- src/lib/devConsole.js | 41 ++++----------------------------- 3 files changed, 6 insertions(+), 62 deletions(-) diff --git a/src/commands/api-mesh/create.js b/src/commands/api-mesh/create.js index 1a4cbe93..6e9ce528 100644 --- a/src/commands/api-mesh/create.js +++ b/src/commands/api-mesh/create.js @@ -130,7 +130,7 @@ class CreateCommand extends Command { if (shouldContinue) { try { - const { mesh, apiKey, sdkList } = await createMesh( + const { mesh } = await createMesh( imsOrgId, projectId, workspaceId, @@ -160,9 +160,7 @@ class CreateCommand extends Command { // When renaming the return values, make sure to make necessary changes to // template adobe/generator-app-api-mesh since it relies on "mesh" & "apiKey" return { - apiKey, - sdkList, - mesh, + mesh }; } else { this.error(`Unable to create a mesh. Please try again. RequestId: ${global.requestId}`, { diff --git a/src/commands/api-mesh/delete.js b/src/commands/api-mesh/delete.js index d6aab52f..661873ed 100644 --- a/src/commands/api-mesh/delete.js +++ b/src/commands/api-mesh/delete.js @@ -17,8 +17,6 @@ const { ignoreCacheFlag, autoConfirmActionFlag } = require('../../utils'); const { getMeshId, deleteMesh, - getApiKeyCredential, - unsubscribeCredentialFromMeshService, } = require('../../lib/devConsole'); require('dotenv').config(); @@ -69,25 +67,6 @@ class DeleteCommand extends Command { if (deleteMeshResponse) { this.log('Successfully deleted mesh %s', meshId); - const credential = await getApiKeyCredential(imsOrgId, projectId, workspaceId); - - if (credential) { - const newSDKList = await unsubscribeCredentialFromMeshService( - imsOrgId, - projectId, - workspaceId, - credential.id_integration, - ); - - if (newSDKList) { - this.log('Successfully unsubscribed API Key %s', credential.client_id); - } else { - this.log('Unable to unsubscribe API Key %s', credential.client_id); - } - } else { - this.log('No API Key found to unsubscribe'); - } - return deleteMeshResponse; } else { throw new Error('Unable to delete mesh'); diff --git a/src/lib/devConsole.js b/src/lib/devConsole.js index ce3ec50a..fbdb0208 100644 --- a/src/lib/devConsole.js +++ b/src/lib/devConsole.js @@ -94,9 +94,9 @@ const describeMesh = async (organizationId, projectId, workspaceId, workspaceNam const credential = await getApiKeyCredential(organizationId, projectId, workspaceId); if (credential) { - return { meshId, apiKey: credential.client_id }; + return { meshId }; } else { - logger.error('API Key credential not found on workspace'); + logger.error('credential not found on workspace'); return { meshId, apiKey: null }; } @@ -270,42 +270,9 @@ const createMesh = async ( if (response && response.status === 201) { logger.info(`Mesh Config : ${objToString(response, ['data'])}`); - let sdkList = []; - let credential; - let isApiKeyNew = false; - - credential = await getApiKeyCredential(organizationId, projectId, workspaceId); - if (!credential) { - logger.info('API Key credential not found on workspace'); - - // try to create a new API key credential - credential = await createAPIMeshCredentials(organizationId, projectId, workspaceId); - isApiKeyNew = true; - } - // subscribe the credential to API mesh service - sdkList = await subscribeCredentialToMeshService( - organizationId, - projectId, - workspaceId, - isApiKeyNew ? credential.id : credential.id_integration, - ); - const newlyCreatedOrExistingApiKey = isApiKeyNew ? credential.apiKey : credential.client_id; - - if (sdkList) { - logger.info( - 'Successfully subscribed API Key %s to API Mesh service', - isApiKeyNew ? credential.apiKey : credential.client_id, - ); - } else { - logger.error( - 'Unable to subscribe API Key %s to API Mesh service', - newlyCreatedOrExistingApiKey, - ); - } return { - mesh: response.data, - apiKey: newlyCreatedOrExistingApiKey, - sdkList, + mesh: response.data + }; } else { // Non 201 response received From 6c70006e2db841da489a97efec6eff77e61c9f34 Mon Sep 17 00:00:00 2001 From: ajaz Date: Thu, 21 Nov 2024 15:24:44 +0530 Subject: [PATCH 2/8] fix: lint errors --- src/commands/api-mesh/create.js | 4 ++-- src/commands/api-mesh/delete.js | 5 +---- src/lib/devConsole.js | 3 +-- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/commands/api-mesh/create.js b/src/commands/api-mesh/create.js index 6e9ce528..4bb09b77 100644 --- a/src/commands/api-mesh/create.js +++ b/src/commands/api-mesh/create.js @@ -130,7 +130,7 @@ class CreateCommand extends Command { if (shouldContinue) { try { - const { mesh } = await createMesh( + const { mesh } = await createMesh( imsOrgId, projectId, workspaceId, @@ -160,7 +160,7 @@ class CreateCommand extends Command { // When renaming the return values, make sure to make necessary changes to // template adobe/generator-app-api-mesh since it relies on "mesh" & "apiKey" return { - mesh + mesh, }; } else { this.error(`Unable to create a mesh. Please try again. RequestId: ${global.requestId}`, { diff --git a/src/commands/api-mesh/delete.js b/src/commands/api-mesh/delete.js index 661873ed..0636e25d 100644 --- a/src/commands/api-mesh/delete.js +++ b/src/commands/api-mesh/delete.js @@ -14,10 +14,7 @@ const { Command } = require('@oclif/command'); const logger = require('../../classes/logger'); const { initSdk, initRequestId, promptConfirm } = require('../../helpers'); const { ignoreCacheFlag, autoConfirmActionFlag } = require('../../utils'); -const { - getMeshId, - deleteMesh, -} = require('../../lib/devConsole'); +const { getMeshId, deleteMesh } = require('../../lib/devConsole'); require('dotenv').config(); diff --git a/src/lib/devConsole.js b/src/lib/devConsole.js index fbdb0208..734a1cca 100644 --- a/src/lib/devConsole.js +++ b/src/lib/devConsole.js @@ -271,8 +271,7 @@ const createMesh = async ( logger.info(`Mesh Config : ${objToString(response, ['data'])}`); return { - mesh: response.data - + mesh: response.data, }; } else { // Non 201 response received From 154c8f4ca7807bde302fb40304814190e70713cd Mon Sep 17 00:00:00 2001 From: ajaz Date: Thu, 21 Nov 2024 15:48:34 +0530 Subject: [PATCH 3/8] fix : failing tests --- .../api-mesh/__tests__/delete.test.js | 42 ++----------------- src/commands/api-mesh/create.js | 4 +- src/lib/devConsole.js | 6 ++- 3 files changed, 11 insertions(+), 41 deletions(-) diff --git a/src/commands/api-mesh/__tests__/delete.test.js b/src/commands/api-mesh/__tests__/delete.test.js index 00f96cba..c55d160d 100644 --- a/src/commands/api-mesh/__tests__/delete.test.js +++ b/src/commands/api-mesh/__tests__/delete.test.js @@ -169,10 +169,6 @@ describe('delete command tests', () => { "Successfully deleted mesh %s", "mesh_id", ], - [ - "Successfully unsubscribed API Key %s", - "dummy_client_id", - ], ] `); expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`[]`); @@ -204,7 +200,7 @@ describe('delete command tests', () => { `); }); - test('should delete mesh but fail to unsubscribe if unable to get api key', async () => { + test.skip('should delete mesh but fail to unsubscribe if unable to get api key', async () => { getApiKeyCredential.mockRejectedValueOnce(new Error('unable to get api key')); const runResult = DeleteCommand.run(); @@ -234,7 +230,7 @@ describe('delete command tests', () => { `); }); - test('should delete mesh but fail to unsubscribe if unsubscribe api failed', async () => { + test.skip('should delete mesh but fail to unsubscribe if unsubscribe api failed', async () => { unsubscribeCredentialFromMeshService.mockRejectedValueOnce(new Error('unsubscribe api failed')); const runResult = DeleteCommand.run(); @@ -264,7 +260,7 @@ describe('delete command tests', () => { `); }); - test('should delete mesh and unsubscribe if correct args are provided', async () => { + test('should delete mesh if correct args are provided', async () => { const runResult = await DeleteCommand.run(); expect(initRequestId).toHaveBeenCalled(); @@ -283,37 +279,7 @@ describe('delete command tests', () => { ], ] `); - expect(getApiKeyCredential.mock.calls).toMatchInlineSnapshot(` - [ - [ - "1234", - "5678", - "123456789", - ], - ] - `); - expect(unsubscribeCredentialFromMeshService.mock.calls).toMatchInlineSnapshot(` - [ - [ - "1234", - "5678", - "123456789", - "dummy_integration_id", - ], - ] - `); - expect(logSpy.mock.calls).toMatchInlineSnapshot(` - [ - [ - "Successfully deleted mesh %s", - "mesh_id", - ], - [ - "Successfully unsubscribed API Key %s", - "dummy_client_id", - ], - ] - `); + expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`[]`); }); }); diff --git a/src/commands/api-mesh/create.js b/src/commands/api-mesh/create.js index 4bb09b77..ce16f825 100644 --- a/src/commands/api-mesh/create.js +++ b/src/commands/api-mesh/create.js @@ -130,7 +130,7 @@ class CreateCommand extends Command { if (shouldContinue) { try { - const { mesh } = await createMesh( + const { mesh, apiKey, sdkList } = await createMesh( imsOrgId, projectId, workspaceId, @@ -161,6 +161,8 @@ class CreateCommand extends Command { // template adobe/generator-app-api-mesh since it relies on "mesh" & "apiKey" return { mesh, + apiKey, + sdkList, }; } else { this.error(`Unable to create a mesh. Please try again. RequestId: ${global.requestId}`, { diff --git a/src/lib/devConsole.js b/src/lib/devConsole.js index 734a1cca..79c5a4d2 100644 --- a/src/lib/devConsole.js +++ b/src/lib/devConsole.js @@ -94,9 +94,9 @@ const describeMesh = async (organizationId, projectId, workspaceId, workspaceNam const credential = await getApiKeyCredential(organizationId, projectId, workspaceId); if (credential) { - return { meshId }; + return { meshId, apiKey: null }; } else { - logger.error('credential not found on workspace'); + logger.error('credentials not found on workspace'); return { meshId, apiKey: null }; } @@ -272,6 +272,8 @@ const createMesh = async ( return { mesh: response.data, + apiKey: null, + sdkList: null, }; } else { // Non 201 response received From 1cc47e6c64f872a8b1a0f68d409bc2f344e519b6 Mon Sep 17 00:00:00 2001 From: ajaz Date: Thu, 21 Nov 2024 15:52:32 +0530 Subject: [PATCH 4/8] fix: delete command unit test --- src/commands/api-mesh/__tests__/delete.test.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/commands/api-mesh/__tests__/delete.test.js b/src/commands/api-mesh/__tests__/delete.test.js index c55d160d..8f5168bf 100644 --- a/src/commands/api-mesh/__tests__/delete.test.js +++ b/src/commands/api-mesh/__tests__/delete.test.js @@ -280,6 +280,14 @@ describe('delete command tests', () => { ] `); + expect(logSpy.mock.calls).toMatchInlineSnapshot(` + [ + [ + "Successfully deleted mesh %s", + "mesh_id", + ], + ] + `); expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`[]`); }); }); From 483731ed96d41828baec42836824d201d24e7147 Mon Sep 17 00:00:00 2001 From: ajaz Date: Thu, 21 Nov 2024 15:53:45 +0530 Subject: [PATCH 5/8] fix: lint --- src/commands/api-mesh/__tests__/delete.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/api-mesh/__tests__/delete.test.js b/src/commands/api-mesh/__tests__/delete.test.js index 8f5168bf..789ef308 100644 --- a/src/commands/api-mesh/__tests__/delete.test.js +++ b/src/commands/api-mesh/__tests__/delete.test.js @@ -280,7 +280,7 @@ describe('delete command tests', () => { ] `); - expect(logSpy.mock.calls).toMatchInlineSnapshot(` + expect(logSpy.mock.calls).toMatchInlineSnapshot(` [ [ "Successfully deleted mesh %s", From 59e37088876a9d5853b56e213a079bf98dc0df60 Mon Sep 17 00:00:00 2001 From: ajaz Date: Fri, 22 Nov 2024 18:17:04 +0530 Subject: [PATCH 6/8] fix: address review comments --- src/commands/api-mesh/__tests__/delete.test.js | 2 +- src/lib/devConsole.js | 16 +--------------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/src/commands/api-mesh/__tests__/delete.test.js b/src/commands/api-mesh/__tests__/delete.test.js index 789ef308..57f7fe4a 100644 --- a/src/commands/api-mesh/__tests__/delete.test.js +++ b/src/commands/api-mesh/__tests__/delete.test.js @@ -260,7 +260,7 @@ describe('delete command tests', () => { `); }); - test('should delete mesh if correct args are provided', async () => { + test('should delete mesh if correct args are provided', async () => { const runResult = await DeleteCommand.run(); expect(initRequestId).toHaveBeenCalled(); diff --git a/src/lib/devConsole.js b/src/lib/devConsole.js index 79c5a4d2..93f9b32d 100644 --- a/src/lib/devConsole.js +++ b/src/lib/devConsole.js @@ -90,21 +90,7 @@ const describeMesh = async (organizationId, projectId, workspaceId, workspaceNam logger.info('Response from getMeshId %s', meshId); - if (meshId) { - const credential = await getApiKeyCredential(organizationId, projectId, workspaceId); - - if (credential) { - return { meshId, apiKey: null }; - } else { - logger.error('credentials not found on workspace'); - - return { meshId, apiKey: null }; - } - } else { - logger.error(`Unable to retrieve meshId.`); - - throw new Error(`Unable to retrieve meshId.`); - } + return { meshId, apiKey: null }; } catch (error) { logger.error(error); From 0cdf38947a29cca5105e04d5f37acc3a99979d05 Mon Sep 17 00:00:00 2001 From: Andrew Molina Date: Mon, 25 Nov 2024 12:48:02 -0600 Subject: [PATCH 7/8] refactor(legacy): CEXT-3841 remove apiKey from command output --- src/commands/api-mesh/create.js | 10 +++------- src/lib/devConsole.js | 4 +--- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/commands/api-mesh/create.js b/src/commands/api-mesh/create.js index ce16f825..87a1791d 100644 --- a/src/commands/api-mesh/create.js +++ b/src/commands/api-mesh/create.js @@ -130,7 +130,7 @@ class CreateCommand extends Command { if (shouldContinue) { try { - const { mesh, apiKey, sdkList } = await createMesh( + const { mesh } = await createMesh( imsOrgId, projectId, workspaceId, @@ -158,12 +158,8 @@ class CreateCommand extends Command { this.log('Mesh Endpoint: %s', meshUrl); // When renaming the return values, make sure to make necessary changes to - // template adobe/generator-app-api-mesh since it relies on "mesh" & "apiKey" - return { - mesh, - apiKey, - sdkList, - }; + // template adobe/generator-app-api-mesh since it relies on "mesh" + return { mesh }; } else { this.error(`Unable to create a mesh. Please try again. RequestId: ${global.requestId}`, { exit: false, diff --git a/src/lib/devConsole.js b/src/lib/devConsole.js index 93f9b32d..37eb33be 100644 --- a/src/lib/devConsole.js +++ b/src/lib/devConsole.js @@ -90,7 +90,7 @@ const describeMesh = async (organizationId, projectId, workspaceId, workspaceNam logger.info('Response from getMeshId %s', meshId); - return { meshId, apiKey: null }; + return { meshId }; } catch (error) { logger.error(error); @@ -258,8 +258,6 @@ const createMesh = async ( return { mesh: response.data, - apiKey: null, - sdkList: null, }; } else { // Non 201 response received From 75d9b45203e12042bce93fff76d9ca94b338f50e Mon Sep 17 00:00:00 2001 From: Andrew Molina Date: Mon, 25 Nov 2024 14:45:08 -0600 Subject: [PATCH 8/8] refactor(legacy): CEXT-3841 remove apiKey references from tests --- .../api-mesh/__tests__/create.test.js | 165 ------------------ .../api-mesh/__tests__/delete.test.js | 60 ------- 2 files changed, 225 deletions(-) diff --git a/src/commands/api-mesh/__tests__/create.test.js b/src/commands/api-mesh/__tests__/create.test.js index 56cec173..0eb94842 100644 --- a/src/commands/api-mesh/__tests__/create.test.js +++ b/src/commands/api-mesh/__tests__/create.test.js @@ -42,8 +42,6 @@ const { const { getMesh, createMesh, - createAPIMeshCredentials, - subscribeCredentialToMeshService, getTenantFeatures, getPublicEncryptionKey, } = require('../../../lib/devConsole'); @@ -122,17 +120,8 @@ describe('create command tests', () => { meshId: 'dummy_mesh_id', meshConfig: sampleCreateMeshConfig.meshConfig, }, - apiKey: 'dummy_api_key', - sdkList: ['dummy_service'], }); - createAPIMeshCredentials.mockResolvedValue({ - apiKey: 'dummy_api_key', - id: 'dummy_id', - }); - - subscribeCredentialToMeshService.mockResolvedValue(['dummy_service']); - getMesh.mockResolvedValue({ meshId: 'dummy_id', meshURL: '', @@ -171,11 +160,7 @@ describe('create command tests', () => { }); const output = await CreateCommand.run(); expect(output).toHaveProperty('mesh'); - expect(output).toHaveProperty('apiKey'); - expect(output).toHaveProperty('sdkList'); expect(output.mesh).toEqual(expect.objectContaining({ meshId: 'dummy_mesh_id' })); - expect(output.apiKey).toEqual('dummy_api_key'); - expect(output.sdkList).toEqual(['dummy_service']); }); test('snapshot create command description', () => { @@ -244,8 +229,6 @@ describe('create command tests', () => { meshId: 'dummy_mesh_id', meshConfig: meshConfigWithComposerFiles.meshConfig, }, - apiKey: 'dummy_api_key', - sdkList: ['dummy_service'], }); parseSpy.mockResolvedValueOnce({ @@ -259,7 +242,6 @@ describe('create command tests', () => { expect(output).toMatchInlineSnapshot(` { - "apiKey": "dummy_api_key", "mesh": { "meshConfig": { "files": [ @@ -303,9 +285,6 @@ describe('create command tests', () => { }, "meshId": "dummy_mesh_id", }, - "sdkList": [ - "dummy_service", - ], } `); }); @@ -365,7 +344,6 @@ describe('create command tests', () => { `); expect(runResult).toMatchInlineSnapshot(` { - "apiKey": "dummy_api_key", "mesh": { "meshConfig": { "sources": [ @@ -381,9 +359,6 @@ describe('create command tests', () => { }, "meshId": "dummy_mesh_id", }, - "sdkList": [ - "dummy_service", - ], } `); expect(logSpy.mock.calls).toMatchInlineSnapshot(` @@ -449,7 +424,6 @@ describe('create command tests', () => { expect(runResult).toMatchInlineSnapshot(` { - "apiKey": "dummy_api_key", "mesh": { "meshConfig": { "sources": [ @@ -465,9 +439,6 @@ describe('create command tests', () => { }, "meshId": "dummy_mesh_id", }, - "sdkList": [ - "dummy_service", - ], } `); expect(logSpy.mock.calls).toMatchInlineSnapshot(` @@ -546,92 +517,6 @@ describe('create command tests', () => { `); }); - test.skip('should fail if create api credential api has failed', async () => { - createAPIMeshCredentials.mockRejectedValue(new Error('create api credential api failed')); - - const runResult = CreateCommand.run(); - - await expect(runResult).rejects.toEqual( - new Error( - 'Unable to create a mesh. Please check the mesh configuration file and try again. If the error persists please contact support. RequestId: dummy_request_id', - ), - ); - expect(logSpy.mock.calls).toMatchInlineSnapshot(` - [ - [ - "******************************************************************************************************", - ], - [ - "Your mesh is being provisioned. Wait a few minutes before checking the status of your mesh %s", - "dummy_mesh_id", - ], - [ - "To check the status of your mesh, run:", - ], - [ - "aio api-mesh:status", - ], - [ - "******************************************************************************************************", - ], - [ - "create api credential api failed", - ], - ] - `); - expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(` - [ - [ - "Unable to create a mesh. Please check the mesh configuration file and try again. If the error persists please contact support. RequestId: dummy_request_id", - ], - ] - `); - }); - - test.skip('should fail if subscribe credential to mesh service api has failed', async () => { - subscribeCredentialToMeshService.mockRejectedValueOnce( - new Error('subscribe credential to mesh service api failed'), - ); - - const runResult = CreateCommand.run(); - - await expect(runResult).rejects.toEqual( - new Error( - 'Unable to create a mesh. Please check the mesh configuration file and try again. If the error persists please contact support. RequestId: dummy_request_id', - ), - ); - expect(logSpy.mock.calls).toMatchInlineSnapshot(` - [ - [ - "******************************************************************************************************", - ], - [ - "Your mesh is being provisioned. Wait a few minutes before checking the status of your mesh %s", - "dummy_mesh_id", - ], - [ - "To check the status of your mesh, run:", - ], - [ - "aio api-mesh:status", - ], - [ - "******************************************************************************************************", - ], - [ - "subscribe credential to mesh service api failed", - ], - ] - `); - expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(` - [ - [ - "Unable to create a mesh. Please check the mesh configuration file and try again. If the error persists please contact support. RequestId: dummy_request_id", - ], - ] - `); - }); - test('should not ask for confirmation if autoConfirmAction is provided', async () => { parseSpy.mockResolvedValueOnce({ args: { file: 'src/commands/__fixtures__/sample_mesh.json' }, @@ -704,11 +589,7 @@ describe('create command tests', () => { }); const output = await CreateCommand.run(); expect(output).toHaveProperty('mesh'); - expect(output).toHaveProperty('apiKey'); - expect(output).toHaveProperty('sdkList'); expect(output.mesh).toEqual(expect.objectContaining({ meshId: 'dummy_mesh_id' })); - expect(output.apiKey).toEqual('dummy_api_key'); - expect(output.sdkList).toEqual(['dummy_service']); }); test('should return error if the mesh has placeholders and env file provided using --env flag is not found', async () => { @@ -876,7 +757,6 @@ describe('create command tests', () => { expect(promptConfirm).toHaveBeenCalledWith('Are you sure you want to create a mesh?'); expect(runResult).toMatchInlineSnapshot(` { - "apiKey": "dummy_api_key", "mesh": { "meshConfig": { "sources": [ @@ -892,9 +772,6 @@ describe('create command tests', () => { }, "meshId": "dummy_mesh_id", }, - "sdkList": [ - "dummy_service", - ], } `); }); @@ -956,8 +833,6 @@ describe('create command tests', () => { meshId: 'dummy_mesh_id', meshConfig: meshConfig, }, - apiKey: 'dummy_api_key', - sdkList: ['dummy_service'], }); parseSpy.mockResolvedValueOnce({ @@ -1016,7 +891,6 @@ describe('create command tests', () => { expect(output).toMatchInlineSnapshot(` { - "apiKey": "dummy_api_key", "mesh": { "meshConfig": { "files": [ @@ -1047,9 +921,6 @@ describe('create command tests', () => { }, "meshId": "dummy_mesh_id", }, - "sdkList": [ - "dummy_service", - ], } `); }); @@ -1225,8 +1096,6 @@ describe('create command tests', () => { meshId: 'dummy_mesh_id', meshConfig: meshConfig, }, - apiKey: 'dummy_api_key', - sdkList: ['dummy_service'], }); parseSpy.mockResolvedValueOnce({ @@ -1278,7 +1147,6 @@ describe('create command tests', () => { `); expect(output).toMatchInlineSnapshot(` { - "apiKey": "dummy_api_key", "mesh": { "meshConfig": { "files": [ @@ -1309,9 +1177,6 @@ describe('create command tests', () => { }, "meshId": "dummy_mesh_id", }, - "sdkList": [ - "dummy_service", - ], } `); }); @@ -1364,8 +1229,6 @@ describe('create command tests', () => { meshId: 'dummy_mesh_id', meshConfig: meshConfig, }, - apiKey: 'dummy_api_key', - sdkList: ['dummy_service'], }); const output = await CreateCommand.run(); @@ -1413,7 +1276,6 @@ describe('create command tests', () => { expect(output).toMatchInlineSnapshot(` { - "apiKey": "dummy_api_key", "mesh": { "meshConfig": { "files": [ @@ -1444,9 +1306,6 @@ describe('create command tests', () => { }, "meshId": "dummy_mesh_id", }, - "sdkList": [ - "dummy_service", - ], } `); }); @@ -1498,8 +1357,6 @@ describe('create command tests', () => { meshId: 'dummy_mesh_id', meshConfig: meshConfig, }, - apiKey: 'dummy_api_key', - sdkList: ['dummy_service'], }); const output = await CreateCommand.run(); @@ -1546,7 +1403,6 @@ describe('create command tests', () => { `); expect(output).toMatchInlineSnapshot(` { - "apiKey": "dummy_api_key", "mesh": { "meshConfig": { "files": [ @@ -1577,9 +1433,6 @@ describe('create command tests', () => { }, "meshId": "dummy_mesh_id", }, - "sdkList": [ - "dummy_service", - ], } `); }); @@ -1618,8 +1471,6 @@ describe('create command tests', () => { meshId: 'dummy_mesh_id', meshConfig: meshConfig, }, - apiKey: 'dummy_api_key', - sdkList: ['dummy_service'], }); parseSpy.mockResolvedValueOnce({ @@ -1677,7 +1528,6 @@ describe('create command tests', () => { `); expect(output).toMatchInlineSnapshot(` { - "apiKey": "dummy_api_key", "mesh": { "meshConfig": { "files": [ @@ -1708,9 +1558,6 @@ describe('create command tests', () => { }, "meshId": "dummy_mesh_id", }, - "sdkList": [ - "dummy_service", - ], } `); }); @@ -1921,7 +1768,6 @@ describe('create command tests', () => { const runResult = await CreateCommand.run(); expect(runResult).toMatchInlineSnapshot(` { - "apiKey": "dummy_api_key", "mesh": { "meshConfig": { "sources": [ @@ -1937,9 +1783,6 @@ describe('create command tests', () => { }, "meshId": "dummy_mesh_id", }, - "sdkList": [ - "dummy_service", - ], } `); }); @@ -1995,7 +1838,6 @@ describe('create command tests', () => { const runResult = await CreateCommand.run(); expect(runResult).toMatchInlineSnapshot(` { - "apiKey": "dummy_api_key", "mesh": { "meshConfig": { "sources": [ @@ -2011,9 +1853,6 @@ describe('create command tests', () => { }, "meshId": "dummy_mesh_id", }, - "sdkList": [ - "dummy_service", - ], } `); }); @@ -2036,7 +1875,6 @@ describe('create command tests', () => { const runResult = await CreateCommand.run(); expect(runResult).toMatchInlineSnapshot(` { - "apiKey": "dummy_api_key", "mesh": { "meshConfig": { "sources": [ @@ -2052,9 +1890,6 @@ describe('create command tests', () => { }, "meshId": "dummy_mesh_id", }, - "sdkList": [ - "dummy_service", - ], } `); }); diff --git a/src/commands/api-mesh/__tests__/delete.test.js b/src/commands/api-mesh/__tests__/delete.test.js index 57f7fe4a..ae6c3d0d 100644 --- a/src/commands/api-mesh/__tests__/delete.test.js +++ b/src/commands/api-mesh/__tests__/delete.test.js @@ -200,66 +200,6 @@ describe('delete command tests', () => { `); }); - test.skip('should delete mesh but fail to unsubscribe if unable to get api key', async () => { - getApiKeyCredential.mockRejectedValueOnce(new Error('unable to get api key')); - - const runResult = DeleteCommand.run(); - - await expect(runResult).rejects.toEqual( - new Error( - 'Unable to delete mesh. Please check the details and try again. If the error persists please contact support. RequestId: dummy_request_id', - ), - ); - expect(logSpy.mock.calls).toMatchInlineSnapshot(` - [ - [ - "Successfully deleted mesh %s", - "mesh_id", - ], - [ - "unable to get api key", - ], - ] - `); - expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(` - [ - [ - "Unable to delete mesh. Please check the details and try again. If the error persists please contact support. RequestId: dummy_request_id", - ], - ] - `); - }); - - test.skip('should delete mesh but fail to unsubscribe if unsubscribe api failed', async () => { - unsubscribeCredentialFromMeshService.mockRejectedValueOnce(new Error('unsubscribe api failed')); - - const runResult = DeleteCommand.run(); - - await expect(runResult).rejects.toEqual( - new Error( - 'Unable to delete mesh. Please check the details and try again. If the error persists please contact support. RequestId: dummy_request_id', - ), - ); - expect(logSpy.mock.calls).toMatchInlineSnapshot(` - [ - [ - "Successfully deleted mesh %s", - "mesh_id", - ], - [ - "unsubscribe api failed", - ], - ] - `); - expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(` - [ - [ - "Unable to delete mesh. Please check the details and try again. If the error persists please contact support. RequestId: dummy_request_id", - ], - ] - `); - }); - test('should delete mesh if correct args are provided', async () => { const runResult = await DeleteCommand.run();