diff --git a/packages/backend/src/controllers/api/v1/app-auth-clients/get-app-auth-client.js b/packages/backend/src/controllers/api/v1/apps/get-auth-client.ee.js similarity index 84% rename from packages/backend/src/controllers/api/v1/app-auth-clients/get-app-auth-client.js rename to packages/backend/src/controllers/api/v1/apps/get-auth-client.ee.js index ae5e335f..5aceb529 100644 --- a/packages/backend/src/controllers/api/v1/app-auth-clients/get-app-auth-client.js +++ b/packages/backend/src/controllers/api/v1/apps/get-auth-client.ee.js @@ -4,7 +4,7 @@ import AppAuthClient from '../../../../models/app-auth-client.js'; export default async (request, response) => { const appAuthClient = await AppAuthClient.query() .findById(request.params.appAuthClientId) - .where({ active: true }) + .where({ app_key: request.params.appKey, active: true }) .throwIfNotFound(); renderObject(response, appAuthClient); diff --git a/packages/backend/src/controllers/api/v1/app-auth-clients/get-app-auth-client.test.js b/packages/backend/src/controllers/api/v1/apps/get-auth-client.ee.test.js similarity index 74% rename from packages/backend/src/controllers/api/v1/app-auth-clients/get-app-auth-client.test.js rename to packages/backend/src/controllers/api/v1/apps/get-auth-client.ee.test.js index 6eef721f..7b60f397 100644 --- a/packages/backend/src/controllers/api/v1/app-auth-clients/get-app-auth-client.test.js +++ b/packages/backend/src/controllers/api/v1/apps/get-auth-client.ee.test.js @@ -4,25 +4,27 @@ import Crypto from 'crypto'; import app from '../../../../app.js'; import createAuthTokenByUserId from '../../../../helpers/create-auth-token-by-user-id.js'; import { createUser } from '../../../../../test/factories/user.js'; -import getAppAuthClientMock from '../../../../../test/mocks/rest/api/v1/app-auth-clients/get-app-auth-client.js'; +import getAppAuthClientMock from '../../../../../test/mocks/rest/api/v1/apps/get-auth-client.js'; import { createAppAuthClient } from '../../../../../test/factories/app-auth-client.js'; import * as license from '../../../../helpers/license.ee.js'; -describe('GET /api/v1/app-auth-clients/:id', () => { +describe('GET /api/v1/apps/:appKey/auth-clients/:appAuthClientId', () => { let currentUser, currentAppAuthClient, token; beforeEach(async () => { vi.spyOn(license, 'hasValidLicense').mockResolvedValue(true); currentUser = await createUser(); - currentAppAuthClient = await createAppAuthClient(); + currentAppAuthClient = await createAppAuthClient({ + appKey: 'deepl', + }); token = createAuthTokenByUserId(currentUser.id); }); - it('should return specified app auth client info', async () => { + it('should return specified app auth client', async () => { const response = await request(app) - .get(`/api/v1/app-auth-clients/${currentAppAuthClient.id}`) + .get(`/api/v1/apps/deepl/auth-clients/${currentAppAuthClient.id}`) .set('Authorization', token) .expect(200); @@ -34,14 +36,14 @@ describe('GET /api/v1/app-auth-clients/:id', () => { const notExistingAppAuthClientUUID = Crypto.randomUUID(); await request(app) - .get(`/api/v1/app-auth-clients/${notExistingAppAuthClientUUID}`) + .get(`/api/v1/apps/deepl/auth-clients/${notExistingAppAuthClientUUID}`) .set('Authorization', token) .expect(404); }); it('should return bad request response for invalid UUID', async () => { await request(app) - .get('/api/v1/app-auth-clients/invalidAppAuthClientUUID') + .get('/api/v1/apps/deepl/auth-clients/invalidAppAuthClientUUID') .set('Authorization', token) .expect(400); }); diff --git a/packages/backend/src/routes/api/v1/app-auth-clients.js b/packages/backend/src/routes/api/v1/app-auth-clients.js deleted file mode 100644 index 6a15826f..00000000 --- a/packages/backend/src/routes/api/v1/app-auth-clients.js +++ /dev/null @@ -1,16 +0,0 @@ -import { Router } from 'express'; -import asyncHandler from 'express-async-handler'; -import { authenticateUser } from '../../../helpers/authentication.js'; -import { checkIsEnterprise } from '../../../helpers/check-is-enterprise.js'; -import getAppAuthClientAction from '../../../controllers/api/v1/app-auth-clients/get-app-auth-client.js'; - -const router = Router(); - -router.get( - '/:appAuthClientId', - authenticateUser, - checkIsEnterprise, - asyncHandler(getAppAuthClientAction) -); - -export default router; diff --git a/packages/backend/src/routes/api/v1/apps.js b/packages/backend/src/routes/api/v1/apps.js index 9bbc1e4f..ac524cbd 100644 --- a/packages/backend/src/routes/api/v1/apps.js +++ b/packages/backend/src/routes/api/v1/apps.js @@ -8,6 +8,7 @@ import getAppsAction from '../../../controllers/api/v1/apps/get-apps.js'; import getAuthAction from '../../../controllers/api/v1/apps/get-auth.js'; import getConfigAction from '../../../controllers/api/v1/apps/get-config.ee.js'; import getAuthClientsAction from '../../../controllers/api/v1/apps/get-auth-clients.ee.js'; +import getAuthClientAction from '../../../controllers/api/v1/apps/get-auth-client.ee.js'; import getTriggersAction from '../../../controllers/api/v1/apps/get-triggers.js'; import getTriggerSubstepsAction from '../../../controllers/api/v1/apps/get-trigger-substeps.js'; import getActionsAction from '../../../controllers/api/v1/apps/get-actions.js'; @@ -34,6 +35,13 @@ router.get( asyncHandler(getAuthClientsAction) ); +router.get( + '/:appKey/auth-clients/:appAuthClientId', + authenticateUser, + checkIsEnterprise, + asyncHandler(getAuthClientAction) +); + router.get( '/:appKey/triggers', authenticateUser, diff --git a/packages/backend/src/routes/index.js b/packages/backend/src/routes/index.js index cb141691..f582352e 100644 --- a/packages/backend/src/routes/index.js +++ b/packages/backend/src/routes/index.js @@ -7,7 +7,6 @@ import automatischRouter from './api/v1/automatisch.js'; import accessTokensRouter from './api/v1/access-tokens.js'; import usersRouter from './api/v1/users.js'; import paymentRouter from './api/v1/payment.ee.js'; -import appAuthClientsRouter from './api/v1/app-auth-clients.js'; import flowsRouter from './api/v1/flows.js'; import stepsRouter from './api/v1/steps.js'; import appsRouter from './api/v1/apps.js'; @@ -30,11 +29,10 @@ router.use('/api/v1/automatisch', automatischRouter); router.use('/api/v1/access-tokens', accessTokensRouter); router.use('/api/v1/users', usersRouter); router.use('/api/v1/payment', paymentRouter); -router.use('/api/v1/app-auth-clients', appAuthClientsRouter); -router.use('/api/v1/flows', flowsRouter); -router.use('/api/v1/steps', stepsRouter); router.use('/api/v1/apps', appsRouter); router.use('/api/v1/connections', connectionsRouter); +router.use('/api/v1/flows', flowsRouter); +router.use('/api/v1/steps', stepsRouter); router.use('/api/v1/executions', executionsRouter); router.use('/api/v1/saml-auth-providers', samlAuthProvidersRouter); router.use('/api/v1/admin/saml-auth-providers', adminSamlAuthProvidersRouter); diff --git a/packages/backend/test/mocks/rest/api/v1/app-auth-clients/get-app-auth-client.js b/packages/backend/test/mocks/rest/api/v1/apps/get-auth-client.js similarity index 100% rename from packages/backend/test/mocks/rest/api/v1/app-auth-clients/get-app-auth-client.js rename to packages/backend/test/mocks/rest/api/v1/apps/get-auth-client.js