feat: Implement new get app auth clients API endpoint
This commit is contained in:
@@ -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);
|
@@ -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);
|
||||
});
|
@@ -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;
|
@@ -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,
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user