chore: Remove old admin app auth clients API endpoint
This commit is contained in:
@@ -1,11 +0,0 @@
|
||||
import { renderObject } from '../../../../../helpers/renderer.js';
|
||||
import AppAuthClient from '../../../../../models/app-auth-client.js';
|
||||
|
||||
export default async (request, response) => {
|
||||
const appAuthClients = await AppAuthClient.query().orderBy(
|
||||
'created_at',
|
||||
'desc'
|
||||
);
|
||||
|
||||
renderObject(response, appAuthClients);
|
||||
};
|
@@ -1,41 +0,0 @@
|
||||
import { vi, describe, it, expect, beforeEach } from 'vitest';
|
||||
import request from 'supertest';
|
||||
import app from '../../../../../app.js';
|
||||
import createAuthTokenByUserId from '../../../../../helpers/create-auth-token-by-user-id.js';
|
||||
import { createUser } from '../../../../../../test/factories/user.js';
|
||||
import getAdminAppAuthClientsMock from '../../../../../../test/mocks/rest/api/v1/admin/app-auth-clients/get-app-auth-clients.js';
|
||||
import { createAppAuthClient } from '../../../../../../test/factories/app-auth-client.js';
|
||||
import { createRole } from '../../../../../../test/factories/role.js';
|
||||
import * as license from '../../../../../helpers/license.ee.js';
|
||||
|
||||
describe('GET /api/v1/admin/app-auth-clients', () => {
|
||||
let currentUser, currentUserRole, token;
|
||||
|
||||
describe('with valid license key', () => {
|
||||
beforeEach(async () => {
|
||||
vi.spyOn(license, 'hasValidLicense').mockResolvedValue(true);
|
||||
|
||||
currentUserRole = await createRole({ key: 'admin' });
|
||||
currentUser = await createUser({ roleId: currentUserRole.id });
|
||||
|
||||
token = createAuthTokenByUserId(currentUser.id);
|
||||
});
|
||||
|
||||
it('should return app auth clients', async () => {
|
||||
const appAuthClientOne = await createAppAuthClient();
|
||||
const appAuthClientTwo = await createAppAuthClient();
|
||||
|
||||
const response = await request(app)
|
||||
.get('/api/v1/admin/app-auth-clients')
|
||||
.set('Authorization', token)
|
||||
.expect(200);
|
||||
|
||||
const expectedPayload = getAdminAppAuthClientsMock([
|
||||
appAuthClientTwo,
|
||||
appAuthClientOne,
|
||||
]);
|
||||
|
||||
expect(response.body).toEqual(expectedPayload);
|
||||
});
|
||||
});
|
||||
});
|
@@ -3,19 +3,10 @@ import asyncHandler from 'express-async-handler';
|
||||
import { authenticateUser } from '../../../../helpers/authentication.js';
|
||||
import { authorizeAdmin } from '../../../../helpers/authorization.js';
|
||||
import { checkIsEnterprise } from '../../../../helpers/check-is-enterprise.js';
|
||||
import getAdminAppAuthClientsAction from '../../../../controllers/api/v1/admin/app-auth-clients/get-app-auth-clients.ee.js';
|
||||
import getAdminAppAuthClientAction from '../../../../controllers/api/v1/admin/app-auth-clients/get-app-auth-client.ee.js';
|
||||
|
||||
const router = Router();
|
||||
|
||||
router.get(
|
||||
'/',
|
||||
authenticateUser,
|
||||
authorizeAdmin,
|
||||
checkIsEnterprise,
|
||||
asyncHandler(getAdminAppAuthClientsAction)
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/:appAuthClientId',
|
||||
authenticateUser,
|
||||
|
@@ -1,19 +0,0 @@
|
||||
const getAdminAppAuthClientsMock = (appAuthClients) => {
|
||||
return {
|
||||
data: appAuthClients.map((appAuthClient) => ({
|
||||
appConfigId: appAuthClient.appConfigId,
|
||||
name: appAuthClient.name,
|
||||
id: appAuthClient.id,
|
||||
active: appAuthClient.active,
|
||||
})),
|
||||
meta: {
|
||||
count: appAuthClients.length,
|
||||
currentPage: null,
|
||||
isArray: true,
|
||||
totalPages: null,
|
||||
type: 'AppAuthClient',
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default getAdminAppAuthClientsMock;
|
Reference in New Issue
Block a user