From 44d8956644782ee5a6c2e20f3716fd868b5f0df7 Mon Sep 17 00:00:00 2001 From: kushalshit27 <43465488+kushalshit27@users.noreply.github.com> Date: Tue, 3 Mar 2026 15:18:12 +0530 Subject: [PATCH 1/3] feat(src/tools/auth0/handlers/connections.ts): refactor getConnectionEnabledClients to use pagination - Simplified fetching of enabled clients by using pagination method - Removed manual handling of pagination and array population --- src/tools/auth0/handlers/connections.ts | 26 +++++-------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/src/tools/auth0/handlers/connections.ts b/src/tools/auth0/handlers/connections.ts index 760007d2a..a01dd9926 100644 --- a/src/tools/auth0/handlers/connections.ts +++ b/src/tools/auth0/handlers/connections.ts @@ -161,28 +161,12 @@ export const getConnectionEnabledClients = async ( if (!connectionId) return null; try { - const enabledClientsFormatted: string[] = []; - - let enabledClients = await auth0Client.connections.clients.get(connectionId); - - // Process first page - enabledClients.data?.forEach((client) => { - if (client?.client_id) { - enabledClientsFormatted.push(client.client_id); - } - }); - - // Fetch remaining pages - while (enabledClients.hasNextPage()) { - enabledClients = await enabledClients.getNextPage(); - enabledClients.data?.forEach((client) => { - if (client?.client_id) { - enabledClientsFormatted.push(client.client_id); - } - }); - } + const enabledClients = await paginate( + (params) => auth0Client.connections.clients.get(connectionId, params), + { checkpoint: true, take: 100 } + ); - return enabledClientsFormatted; + return enabledClients.filter((client) => !!client?.client_id).map((client) => client.client_id); } catch (error) { return null; } From 93fa3a31c75971da6da70952e4296070f61fdcf3 Mon Sep 17 00:00:00 2001 From: kushalshit27 <43465488+kushalshit27@users.noreply.github.com> Date: Wed, 4 Mar 2026 14:08:47 +0530 Subject: [PATCH 2/3] feat(test/tools/auth0/handlers/connections.tests.js): simplify mock responses for getConnectionEnabledClients feat(test/tools/auth0/handlers/databases.tests.js): simplify mock responses for clients in database handler --- .../tools/auth0/handlers/connections.tests.js | 68 +++++++------------ test/tools/auth0/handlers/databases.tests.js | 8 +-- 2 files changed, 29 insertions(+), 47 deletions(-) diff --git a/test/tools/auth0/handlers/connections.tests.js b/test/tools/auth0/handlers/connections.tests.js index 5c88b8a85..c4e75b064 100644 --- a/test/tools/auth0/handlers/connections.tests.js +++ b/test/tools/auth0/handlers/connections.tests.js @@ -926,29 +926,24 @@ describe('#connections enabled clients functionality', () => { describe('#getConnectionEnabledClients', () => { it('should return array of client IDs with single page', async () => { const connectionId = 'con_123'; - const mockResponse = { - data: [{ client_id: 'client_1' }, { client_id: 'client_2' }, { client_id: 'client_3' }], - hasNextPage: () => false, - getNextPage: async () => ({ data: [], hasNextPage: () => false }), - }; - - mockAuth0Client.connections.clients.get.resolves(mockResponse); + mockAuth0Client.connections.clients.get.resolves([ + { client_id: 'client_1' }, + { client_id: 'client_2' }, + { client_id: 'client_3' }, + ]); const result = await getConnectionEnabledClients(mockAuth0Client, connectionId); expect(result).to.deep.equal(['client_1', 'client_2', 'client_3']); - sinon.assert.calledOnceWithExactly(mockAuth0Client.connections.clients.get, connectionId); + sinon.assert.calledOnceWithExactly(mockAuth0Client.connections.clients.get, connectionId, { + checkpoint: true, + take: 100, + }); }); it('should return empty array when no enabled clients', async () => { const connectionId = 'con_123'; - const mockResponse = { - data: [], - hasNextPage: () => false, - getNextPage: async () => ({ data: [], hasNextPage: () => false }), - }; - - mockAuth0Client.connections.clients.get.resolves(mockResponse); + mockAuth0Client.connections.clients.get.resolves([]); const result = await getConnectionEnabledClients(mockAuth0Client, connectionId); @@ -958,26 +953,17 @@ describe('#connections enabled clients functionality', () => { it('should handle multi-page pagination correctly', async () => { const connectionId = 'con_123'; - // Simulate 3 pages of results - const page3 = { - data: [{ client_id: 'client_7' }, { client_id: 'client_8' }], - hasNextPage: () => false, - getNextPage: async () => ({ data: [], hasNextPage: () => false }), - }; - - const page2 = { - data: [{ client_id: 'client_4' }, { client_id: 'client_5' }, { client_id: 'client_6' }], - hasNextPage: () => true, - getNextPage: async () => page3, - }; - - const page1 = { - data: [{ client_id: 'client_1' }, { client_id: 'client_2' }, { client_id: 'client_3' }], - hasNextPage: () => true, - getNextPage: async () => page2, - }; - - mockAuth0Client.connections.clients.get.resolves(page1); + // Pagination is handled by the paginate helper; mock returns all clients as a flat array + mockAuth0Client.connections.clients.get.resolves([ + { client_id: 'client_1' }, + { client_id: 'client_2' }, + { client_id: 'client_3' }, + { client_id: 'client_4' }, + { client_id: 'client_5' }, + { client_id: 'client_6' }, + { client_id: 'client_7' }, + { client_id: 'client_8' }, + ]); const result = await getConnectionEnabledClients(mockAuth0Client, connectionId); @@ -985,12 +971,12 @@ describe('#connections enabled clients functionality', () => { expect(result).to.deep.equal([ 'client_1', 'client_2', - 'client_3', // Page 1 + 'client_3', 'client_4', 'client_5', - 'client_6', // Page 2 + 'client_6', 'client_7', - 'client_8', // Page 3 + 'client_8', ]); }); }); @@ -1407,11 +1393,9 @@ describe('#connections enabled clients functionality', () => { // Mock enabled clients responses getEnabledClientsStub .withArgs('con_1') - .resolves( - mockPagedData({}, 'clients', [{ client_id: 'client_1' }, { client_id: 'client_2' }]) - ) + .resolves([{ client_id: 'client_1' }, { client_id: 'client_2' }]) .withArgs('con_2') - .resolves(mockPagedData({}, 'clients', [{ client_id: 'client_3' }])); + .resolves([{ client_id: 'client_3' }]); const handler = new connections.default({ client: pageClient(auth0), config }); handler.scimHandler = scimHandlerMock; diff --git a/test/tools/auth0/handlers/databases.tests.js b/test/tools/auth0/handlers/databases.tests.js index 9070f4d30..fa375508f 100644 --- a/test/tools/auth0/handlers/databases.tests.js +++ b/test/tools/auth0/handlers/databases.tests.js @@ -556,7 +556,7 @@ describe('#databases handler', () => { }, clients: { get: () => { - return Promise.resolve(mockPagedData({}, 'clients', [{ client_id: clientId }])); + return Promise.resolve([{ client_id: clientId }]); }, }, }, @@ -2242,11 +2242,9 @@ describe('#databases handler with enabled clients integration', () => { // Mock enabled clients responses getEnabledClientsStub .withArgs('con_1') - .resolves( - mockPagedData({}, 'clients', [{ client_id: 'client_1' }, { client_id: 'client_2' }]) - ) + .resolves([{ client_id: 'client_1' }, { client_id: 'client_2' }]) .withArgs('con_2') - .resolves(mockPagedData({}, 'clients', [{ client_id: 'client_3' }])); + .resolves([{ client_id: 'client_3' }]); const handler = new databases.default({ client: pageClient(auth0), config }); From 527459a6d3bc3a500fb707519c264a906bf0351b Mon Sep 17 00:00:00 2001 From: kushalshit27 <43465488+kushalshit27@users.noreply.github.com> Date: Fri, 6 Mar 2026 15:57:35 +0530 Subject: [PATCH 3/3] feat(package.json): update dependencies and devDependencies - package.json: bump auth0 to ^5.4.0 - package.json: update @types/lodash to ^4.17.24 - package.json: upgrade @typescript-eslint/eslint-plugin and parser to ^8.56.1 - package.json: change typescript version to ~5.9.3 --- package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 3efca6c21..3395ceb6f 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "homepage": "https://github.com/auth0/auth0-deploy-cli#readme", "dependencies": { "ajv": "^6.12.6", - "auth0": "^5.3.1", + "auth0": "^5.4.0", "dot-prop": "^5.3.0", "fs-extra": "^10.1.0", "js-yaml": "^4.1.1", @@ -49,11 +49,11 @@ "devDependencies": { "@eslint/js": "^9.39.2", "@types/fs-extra": "^9.0.13", - "@types/lodash": "^4.17.23", + "@types/lodash": "^4.17.24", "@types/mocha": "^10.0.10", "@types/nconf": "^0.10.7", - "@typescript-eslint/eslint-plugin": "^8.55.0", - "@typescript-eslint/parser": "^8.55.0", + "@typescript-eslint/eslint-plugin": "^8.56.1", + "@typescript-eslint/parser": "^8.56.1", "chai": "^4.5.0", "chai-as-promised": "^7.1.2", "eslint": "^9.39.2", @@ -73,7 +73,7 @@ "sinon": "^13.0.2", "sinon-chai": "^3.7.0", "ts-mocha": "^11.1.0", - "typescript": "^5.9.3" + "typescript": "~5.9.3" }, "engines": { "node": ">=20.19.0"