feat: implement app-auth-client endpoint
This commit is contained in:
25
packages/backend/test/factories/app-auth-client.js
Normal file
25
packages/backend/test/factories/app-auth-client.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import { faker } from '@faker-js/faker';
|
||||
import { createAppConfig } from './app-config.js';
|
||||
import AppAuthClient from '../../src/models/app-auth-client';
|
||||
|
||||
const formattedAuthDefaults = {
|
||||
oAuthRedirectUrl: faker.internet.url(),
|
||||
instanceUrl: faker.internet.url(),
|
||||
clientId: faker.string.uuid(),
|
||||
clientSecret: faker.string.uuid(),
|
||||
};
|
||||
|
||||
export const createAppAuthClient = async (params = {}) => {
|
||||
params.name = params?.name || faker.person.fullName();
|
||||
params.id = params?.id || faker.string.uuid();
|
||||
params.appConfigId = params?.appConfigId || (await createAppConfig()).id;
|
||||
params.active = params?.active ?? true;
|
||||
params.formattedAuthDefaults =
|
||||
params?.formattedAuthDefaults || formattedAuthDefaults;
|
||||
|
||||
const appAuthClient = await AppAuthClient.query()
|
||||
.insert(params)
|
||||
.returning('*');
|
||||
|
||||
return appAuthClient;
|
||||
};
|
13
packages/backend/test/factories/app-config.js
Normal file
13
packages/backend/test/factories/app-config.js
Normal file
@@ -0,0 +1,13 @@
|
||||
import AppConfig from '../../src/models/app-config.js';
|
||||
|
||||
export const createAppConfig = async (params = {}) => {
|
||||
const appConfigData = {
|
||||
key: params?.key || 'gitlab',
|
||||
};
|
||||
|
||||
const appConfig = await AppConfig.query()
|
||||
.insert(appConfigData)
|
||||
.returning('*');
|
||||
|
||||
return appConfig;
|
||||
};
|
@@ -0,0 +1,19 @@
|
||||
const getAdminAppAuthClientMock = (appAuthClient) => {
|
||||
return {
|
||||
data: {
|
||||
appConfigId: appAuthClient.appConfigId,
|
||||
name: appAuthClient.name,
|
||||
id: appAuthClient.id,
|
||||
active: appAuthClient.active,
|
||||
},
|
||||
meta: {
|
||||
count: 1,
|
||||
currentPage: null,
|
||||
isArray: false,
|
||||
totalPages: null,
|
||||
type: 'AppAuthClient',
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default getAdminAppAuthClientMock;
|
@@ -0,0 +1,19 @@
|
||||
const getAppAuthClientMock = (appAuthClient) => {
|
||||
return {
|
||||
data: {
|
||||
name: appAuthClient.name,
|
||||
id: appAuthClient.id,
|
||||
appConfigId: appAuthClient.appConfigId,
|
||||
active: appAuthClient.active,
|
||||
},
|
||||
meta: {
|
||||
count: 1,
|
||||
currentPage: null,
|
||||
isArray: false,
|
||||
totalPages: null,
|
||||
type: 'AppAuthClient',
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default getAppAuthClientMock;
|
Reference in New Issue
Block a user