refactor: Rename AppAuthClient model as OAuthClient
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { faker } from '@faker-js/faker';
|
||||
import AppAuthClient from '../../src/models/app-auth-client';
|
||||
import OAuthClient from '../../src/models/oauth-client';
|
||||
|
||||
const formattedAuthDefaults = {
|
||||
oAuthRedirectUrl: faker.internet.url(),
|
||||
@@ -8,14 +8,14 @@ const formattedAuthDefaults = {
|
||||
clientSecret: faker.string.uuid(),
|
||||
};
|
||||
|
||||
export const createAppAuthClient = async (params = {}) => {
|
||||
export const createOAuthClient = async (params = {}) => {
|
||||
params.name = params?.name || faker.person.fullName();
|
||||
params.appKey = params?.appKey || 'deepl';
|
||||
params.active = params?.active ?? true;
|
||||
params.formattedAuthDefaults =
|
||||
params?.formattedAuthDefaults || formattedAuthDefaults;
|
||||
|
||||
const appAuthClient = await AppAuthClient.query().insertAndFetch(params);
|
||||
const oauthClient = await OAuthClient.query().insertAndFetch(params);
|
||||
|
||||
return appAuthClient;
|
||||
return oauthClient;
|
||||
};
|
||||
@@ -1,17 +0,0 @@
|
||||
const createAppAuthClientMock = (appAuthClient) => {
|
||||
return {
|
||||
data: {
|
||||
name: appAuthClient.name,
|
||||
active: appAuthClient.active,
|
||||
},
|
||||
meta: {
|
||||
count: 1,
|
||||
currentPage: null,
|
||||
isArray: false,
|
||||
totalPages: null,
|
||||
type: 'AppAuthClient',
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default createAppAuthClientMock;
|
||||
@@ -0,0 +1,17 @@
|
||||
const createOAuthClientMock = (oauthClient) => {
|
||||
return {
|
||||
data: {
|
||||
name: oauthClient.name,
|
||||
active: oauthClient.active,
|
||||
},
|
||||
meta: {
|
||||
count: 1,
|
||||
currentPage: null,
|
||||
isArray: false,
|
||||
totalPages: null,
|
||||
type: 'OAuthClient',
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default createOAuthClientMock;
|
||||
@@ -1,18 +0,0 @@
|
||||
const getAppAuthClientMock = (appAuthClient) => {
|
||||
return {
|
||||
data: {
|
||||
name: appAuthClient.name,
|
||||
id: appAuthClient.id,
|
||||
active: appAuthClient.active,
|
||||
},
|
||||
meta: {
|
||||
count: 1,
|
||||
currentPage: null,
|
||||
isArray: false,
|
||||
totalPages: null,
|
||||
type: 'AppAuthClient',
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default getAppAuthClientMock;
|
||||
@@ -1,18 +0,0 @@
|
||||
const getAdminAppAuthClientsMock = (appAuthClients) => {
|
||||
return {
|
||||
data: appAuthClients.map((appAuthClient) => ({
|
||||
name: appAuthClient.name,
|
||||
id: appAuthClient.id,
|
||||
active: appAuthClient.active,
|
||||
})),
|
||||
meta: {
|
||||
count: appAuthClients.length,
|
||||
currentPage: null,
|
||||
isArray: true,
|
||||
totalPages: null,
|
||||
type: 'AppAuthClient',
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default getAdminAppAuthClientsMock;
|
||||
@@ -0,0 +1,18 @@
|
||||
const getOAuthClientMock = (oauthClient) => {
|
||||
return {
|
||||
data: {
|
||||
name: oauthClient.name,
|
||||
id: oauthClient.id,
|
||||
active: oauthClient.active,
|
||||
},
|
||||
meta: {
|
||||
count: 1,
|
||||
currentPage: null,
|
||||
isArray: false,
|
||||
totalPages: null,
|
||||
type: 'OAuthClient',
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default getOAuthClientMock;
|
||||
@@ -0,0 +1,18 @@
|
||||
const getAdminOAuthClientsMock = (oauthClients) => {
|
||||
return {
|
||||
data: oauthClients.map((oauthClient) => ({
|
||||
name: oauthClient.name,
|
||||
id: oauthClient.id,
|
||||
active: oauthClient.active,
|
||||
})),
|
||||
meta: {
|
||||
count: oauthClients.length,
|
||||
currentPage: null,
|
||||
isArray: true,
|
||||
totalPages: null,
|
||||
type: 'OAuthClient',
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default getAdminOAuthClientsMock;
|
||||
@@ -1,18 +0,0 @@
|
||||
const updateAppAuthClientMock = (appAuthClient) => {
|
||||
return {
|
||||
data: {
|
||||
id: appAuthClient.id,
|
||||
name: appAuthClient.name,
|
||||
active: appAuthClient.active,
|
||||
},
|
||||
meta: {
|
||||
count: 1,
|
||||
currentPage: null,
|
||||
isArray: false,
|
||||
totalPages: null,
|
||||
type: 'AppAuthClient',
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default updateAppAuthClientMock;
|
||||
@@ -0,0 +1,18 @@
|
||||
const updateOAuthClientMock = (oauthClient) => {
|
||||
return {
|
||||
data: {
|
||||
id: oauthClient.id,
|
||||
name: oauthClient.name,
|
||||
active: oauthClient.active,
|
||||
},
|
||||
meta: {
|
||||
count: 1,
|
||||
currentPage: null,
|
||||
isArray: false,
|
||||
totalPages: null,
|
||||
type: 'OAuthClient',
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default updateOAuthClientMock;
|
||||
@@ -2,7 +2,7 @@ const createConnection = (connection) => {
|
||||
const connectionData = {
|
||||
id: connection.id,
|
||||
key: connection.key,
|
||||
appAuthClientId: connection.appAuthClientId,
|
||||
oauthClientId: connection.oauthClientId,
|
||||
formattedData: connection.formattedData,
|
||||
verified: connection.verified || false,
|
||||
createdAt: connection.createdAt.getTime(),
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
const getAppAuthClientMock = (appAuthClient) => {
|
||||
return {
|
||||
data: {
|
||||
name: appAuthClient.name,
|
||||
id: appAuthClient.id,
|
||||
active: appAuthClient.active,
|
||||
},
|
||||
meta: {
|
||||
count: 1,
|
||||
currentPage: null,
|
||||
isArray: false,
|
||||
totalPages: null,
|
||||
type: 'AppAuthClient',
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default getAppAuthClientMock;
|
||||
@@ -1,18 +0,0 @@
|
||||
const getAppAuthClientsMock = (appAuthClients) => {
|
||||
return {
|
||||
data: appAuthClients.map((appAuthClient) => ({
|
||||
name: appAuthClient.name,
|
||||
id: appAuthClient.id,
|
||||
active: appAuthClient.active,
|
||||
})),
|
||||
meta: {
|
||||
count: appAuthClients.length,
|
||||
currentPage: null,
|
||||
isArray: true,
|
||||
totalPages: null,
|
||||
type: 'AppAuthClient',
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default getAppAuthClientsMock;
|
||||
@@ -4,7 +4,7 @@ const getConnectionsMock = (connections) => {
|
||||
id: connection.id,
|
||||
key: connection.key,
|
||||
verified: connection.verified,
|
||||
appAuthClientId: connection.appAuthClientId,
|
||||
oauthClientId: connection.oauthClientId,
|
||||
formattedData: {
|
||||
screenName: connection.formattedData.screenName,
|
||||
},
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
const getOAuthClientMock = (oauthClient) => {
|
||||
return {
|
||||
data: {
|
||||
name: oauthClient.name,
|
||||
id: oauthClient.id,
|
||||
active: oauthClient.active,
|
||||
},
|
||||
meta: {
|
||||
count: 1,
|
||||
currentPage: null,
|
||||
isArray: false,
|
||||
totalPages: null,
|
||||
type: 'OAuthClient',
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default getOAuthClientMock;
|
||||
@@ -0,0 +1,18 @@
|
||||
const getOAuthClientsMock = (oauthClients) => {
|
||||
return {
|
||||
data: oauthClients.map((oauthClient) => ({
|
||||
name: oauthClient.name,
|
||||
id: oauthClient.id,
|
||||
active: oauthClient.active,
|
||||
})),
|
||||
meta: {
|
||||
count: oauthClients.length,
|
||||
currentPage: null,
|
||||
isArray: true,
|
||||
totalPages: null,
|
||||
type: 'OAuthClient',
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default getOAuthClientsMock;
|
||||
@@ -3,7 +3,7 @@ const resetConnectionMock = (connection) => {
|
||||
id: connection.id,
|
||||
key: connection.key,
|
||||
verified: connection.verified,
|
||||
appAuthClientId: connection.appAuthClientId,
|
||||
oauthClientId: connection.oauthClientId,
|
||||
formattedData: {
|
||||
screenName: connection.formattedData.screenName,
|
||||
},
|
||||
|
||||
@@ -3,7 +3,7 @@ const updateConnectionMock = (connection) => {
|
||||
id: connection.id,
|
||||
key: connection.key,
|
||||
verified: connection.verified,
|
||||
appAuthClientId: connection.appAuthClientId,
|
||||
oauthClientId: connection.oauthClientId,
|
||||
formattedData: {
|
||||
screenName: connection.formattedData.screenName,
|
||||
},
|
||||
|
||||
@@ -3,7 +3,7 @@ const getConnectionMock = async (connection) => {
|
||||
id: connection.id,
|
||||
key: connection.key,
|
||||
verified: connection.verified,
|
||||
appAuthClientId: connection.appAuthClientId,
|
||||
oauthClientId: connection.oauthClientId,
|
||||
formattedData: {
|
||||
screenName: connection.formattedData.screenName,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user