Skip to content

Commit 6c9d4f2

Browse files
authored
fix(ipallowlists): exception on getBindingDetails fixes #707
* Update get-binding-details.js * Update tests for get-binding-details.test.js * Update get-binding-details.test.js
1 parent 7c1a13e commit 6c9d4f2

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/commands/cloudmanager/ip-allowlist/get-binding-details.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class ListIPAllowlistBindingDetails extends BaseCommand {
2626

2727
const result = await this.listIpAllowlists(programId, flags.imsContextName)
2828

29-
const allowList = result.find(allowList => allowList.id === args.ipAllowlistId)
29+
const allowList = result.find(allowList => allowList.id === Number(args.ipAllowlistId))
3030

3131
if (!allowList) {
3232
throw new validationCodes.IP_ALLOWLIST_NOT_FOUND({ messageValues: [args.ipAllowlistId, programId] })

test/commands/ip-allowlist/get-binding-details.test.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ test('get-binding-details - not found', async () => {
3737

3838
mockSdk.listIpAllowlists = jest.fn(() => Promise.resolve([
3939
{
40-
id: '1',
40+
id: 1,
4141
name: 'test1',
4242
ipCidrSet: ['1.1.1.1/5', '2.2.2.2/5'],
4343
programId: '4',
@@ -55,7 +55,7 @@ test('get-binding-details - no bindings', async () => {
5555

5656
mockSdk.listIpAllowlists = jest.fn(() => Promise.resolve([
5757
{
58-
id: '1',
58+
id: 1,
5959
name: 'test1',
6060
ipCidrSet: ['1.1.1.1/5', '2.2.2.2/5'],
6161
programId: '4',
@@ -66,7 +66,7 @@ test('get-binding-details - no bindings', async () => {
6666
const runResult = ListIPAllowlistBindingDetails.run(['--programId', '4', '1'])
6767
await expect(runResult instanceof Promise).toBeTruthy()
6868
await expect(runResult).resolves.toMatchObject({
69-
id: '1',
69+
id: 1,
7070
bindings: [],
7171
})
7272
await expect(mockSdk.listIpAllowlists.mock.calls.length).toEqual(1)
@@ -84,7 +84,7 @@ test('get-binding-details - normal with bindings', async () => {
8484

8585
mockSdk.listIpAllowlists = jest.fn(() => Promise.resolve([
8686
{
87-
id: '1',
87+
id: 1,
8888
name: 'test1',
8989
ipCidrSet: ['1.1.1.1/5', '2.2.2.2/5'],
9090
programId: '4',
@@ -98,7 +98,7 @@ test('get-binding-details - normal with bindings', async () => {
9898
const runResult = ListIPAllowlistBindingDetails.run(['--programId', '4', '1'])
9999
await expect(runResult instanceof Promise).toBeTruthy()
100100
await expect(runResult).resolves.toMatchObject({
101-
id: '1',
101+
id: 1,
102102
bindings: [{
103103
environmentId: '3',
104104
environmentName: 'TestProgram_dev',
@@ -114,7 +114,7 @@ test('get-binding-details - binding to unknown environment (should not ever happ
114114

115115
mockSdk.listIpAllowlists = jest.fn(() => Promise.resolve([
116116
{
117-
id: '1',
117+
id: 1,
118118
name: 'test1',
119119
ipCidrSet: ['1.1.1.1/5', '2.2.2.2/5'],
120120
programId: '4',
@@ -128,7 +128,7 @@ test('get-binding-details - binding to unknown environment (should not ever happ
128128
const runResult = ListIPAllowlistBindingDetails.run(['--programId', '4', '1'])
129129
await expect(runResult instanceof Promise).toBeTruthy()
130130
await expect(runResult).resolves.toMatchObject({
131-
id: '1',
131+
id: 1,
132132
bindings: [{
133133
environmentId: 'X',
134134
environmentName: 'Environment X',
@@ -144,7 +144,7 @@ test('get-binding-details - bindings when environment load fails', async () => {
144144

145145
mockSdk.listIpAllowlists = jest.fn(() => Promise.resolve([
146146
{
147-
id: '1',
147+
id: 1,
148148
name: 'test1',
149149
ipCidrSet: ['1.1.1.1/5', '2.2.2.2/5'],
150150
programId: '4',
@@ -159,7 +159,7 @@ test('get-binding-details - bindings when environment load fails', async () => {
159159
const runResult = ListIPAllowlistBindingDetails.run(['--programId', '4', '1'])
160160
await expect(runResult instanceof Promise).toBeTruthy()
161161
await expect(runResult).resolves.toMatchObject({
162-
id: '1',
162+
id: 1,
163163
bindings: [{
164164
environmentId: 'X',
165165
environmentName: 'Environment X',

0 commit comments

Comments
 (0)