refactor(app-config): rename allow_custom_connection as custom_connection_allowed
This commit is contained in:
@@ -10,11 +10,11 @@ export default async (request, response) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const appConfigParams = (request) => {
|
const appConfigParams = (request) => {
|
||||||
const { allowCustomConnection, shared, disabled } = request.body;
|
const { customConnectionAllowed, shared, disabled } = request.body;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
key: request.params.appKey,
|
key: request.params.appKey,
|
||||||
allowCustomConnection,
|
customConnectionAllowed,
|
||||||
shared,
|
shared,
|
||||||
disabled,
|
disabled,
|
||||||
};
|
};
|
||||||
|
@@ -23,7 +23,7 @@ describe('POST /api/v1/admin/apps/:appKey/config', () => {
|
|||||||
|
|
||||||
it('should return created app config', async () => {
|
it('should return created app config', async () => {
|
||||||
const appConfig = {
|
const appConfig = {
|
||||||
allowCustomConnection: true,
|
customConnectionAllowed: true,
|
||||||
shared: true,
|
shared: true,
|
||||||
disabled: false,
|
disabled: false,
|
||||||
};
|
};
|
||||||
@@ -44,7 +44,7 @@ describe('POST /api/v1/admin/apps/:appKey/config', () => {
|
|||||||
it('should return HTTP 422 for already existing app config', async () => {
|
it('should return HTTP 422 for already existing app config', async () => {
|
||||||
const appConfig = {
|
const appConfig = {
|
||||||
key: 'gitlab',
|
key: 'gitlab',
|
||||||
allowCustomConnection: true,
|
customConnectionAllowed: true,
|
||||||
shared: true,
|
shared: true,
|
||||||
disabled: false,
|
disabled: false,
|
||||||
};
|
};
|
||||||
|
@@ -14,10 +14,10 @@ export default async (request, response) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const appConfigParams = (request) => {
|
const appConfigParams = (request) => {
|
||||||
const { allowCustomConnection, shared, disabled } = request.body;
|
const { customConnectionAllowed, shared, disabled } = request.body;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
allowCustomConnection,
|
customConnectionAllowed,
|
||||||
shared,
|
shared,
|
||||||
disabled,
|
disabled,
|
||||||
};
|
};
|
||||||
|
@@ -24,7 +24,7 @@ describe('PATCH /api/v1/admin/apps/:appKey/config', () => {
|
|||||||
it('should return updated app config', async () => {
|
it('should return updated app config', async () => {
|
||||||
const appConfig = {
|
const appConfig = {
|
||||||
key: 'gitlab',
|
key: 'gitlab',
|
||||||
allowCustomConnection: true,
|
customConnectionAllowed: true,
|
||||||
shared: true,
|
shared: true,
|
||||||
disabled: false,
|
disabled: false,
|
||||||
};
|
};
|
||||||
@@ -34,7 +34,7 @@ describe('PATCH /api/v1/admin/apps/:appKey/config', () => {
|
|||||||
const newAppConfigValues = {
|
const newAppConfigValues = {
|
||||||
shared: false,
|
shared: false,
|
||||||
disabled: true,
|
disabled: true,
|
||||||
allowCustomConnection: false,
|
customConnectionAllowed: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
const response = await request(app)
|
const response = await request(app)
|
||||||
@@ -55,7 +55,7 @@ describe('PATCH /api/v1/admin/apps/:appKey/config', () => {
|
|||||||
const appConfig = {
|
const appConfig = {
|
||||||
shared: false,
|
shared: false,
|
||||||
disabled: true,
|
disabled: true,
|
||||||
allowCustomConnection: false,
|
customConnectionAllowed: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
await request(app)
|
await request(app)
|
||||||
@@ -68,7 +68,7 @@ describe('PATCH /api/v1/admin/apps/:appKey/config', () => {
|
|||||||
it('should return HTTP 422 for invalid app config data', async () => {
|
it('should return HTTP 422 for invalid app config data', async () => {
|
||||||
const appConfig = {
|
const appConfig = {
|
||||||
key: 'gitlab',
|
key: 'gitlab',
|
||||||
allowCustomConnection: true,
|
customConnectionAllowed: true,
|
||||||
shared: true,
|
shared: true,
|
||||||
disabled: false,
|
disabled: false,
|
||||||
};
|
};
|
||||||
|
@@ -155,7 +155,7 @@ describe('POST /api/v1/apps/:appKey/connections', () => {
|
|||||||
await createAppConfig({
|
await createAppConfig({
|
||||||
key: 'gitlab',
|
key: 'gitlab',
|
||||||
disabled: false,
|
disabled: false,
|
||||||
allowCustomConnection: true,
|
customConnectionAllowed: true,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -218,7 +218,7 @@ describe('POST /api/v1/apps/:appKey/connections', () => {
|
|||||||
await createAppConfig({
|
await createAppConfig({
|
||||||
key: 'gitlab',
|
key: 'gitlab',
|
||||||
disabled: false,
|
disabled: false,
|
||||||
allowCustomConnection: false,
|
customConnectionAllowed: false,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -17,7 +17,7 @@ describe('GET /api/v1/apps/:appKey/config', () => {
|
|||||||
|
|
||||||
appConfig = await createAppConfig({
|
appConfig = await createAppConfig({
|
||||||
key: 'deepl',
|
key: 'deepl',
|
||||||
allowCustomConnection: true,
|
customConnectionAllowed: true,
|
||||||
shared: true,
|
shared: true,
|
||||||
disabled: false,
|
disabled: false,
|
||||||
});
|
});
|
||||||
|
@@ -0,0 +1,11 @@
|
|||||||
|
export async function up(knex) {
|
||||||
|
return knex.schema.alterTable('app_configs', (table) => {
|
||||||
|
table.renameColumn('allow_custom_connection', 'custom_connection_allowed');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function down(knex) {
|
||||||
|
return knex.schema.alterTable('app_configs', (table) => {
|
||||||
|
table.renameColumn('custom_connection_allowed', 'allow_custom_connection');
|
||||||
|
});
|
||||||
|
}
|
@@ -3,10 +3,6 @@
|
|||||||
exports[`AppConfig model > jsonSchema should have correct validations 1`] = `
|
exports[`AppConfig model > jsonSchema should have correct validations 1`] = `
|
||||||
{
|
{
|
||||||
"properties": {
|
"properties": {
|
||||||
"allowCustomConnection": {
|
|
||||||
"default": false,
|
|
||||||
"type": "boolean",
|
|
||||||
},
|
|
||||||
"connectionAllowed": {
|
"connectionAllowed": {
|
||||||
"default": false,
|
"default": false,
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
@@ -14,6 +10,10 @@ exports[`AppConfig model > jsonSchema should have correct validations 1`] = `
|
|||||||
"createdAt": {
|
"createdAt": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
},
|
},
|
||||||
|
"customConnectionAllowed": {
|
||||||
|
"default": false,
|
||||||
|
"type": "boolean",
|
||||||
|
},
|
||||||
"disabled": {
|
"disabled": {
|
||||||
"default": false,
|
"default": false,
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
@@ -39,3 +39,5 @@ exports[`AppConfig model > jsonSchema should have correct validations 1`] = `
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`AppConfig model > virtualAttributes should return correct properties 1`] = `null`;
|
||||||
|
@@ -13,7 +13,7 @@ class AppConfig extends Base {
|
|||||||
id: { type: 'string', format: 'uuid' },
|
id: { type: 'string', format: 'uuid' },
|
||||||
key: { type: 'string' },
|
key: { type: 'string' },
|
||||||
connectionAllowed: { type: 'boolean', default: false },
|
connectionAllowed: { type: 'boolean', default: false },
|
||||||
allowCustomConnection: { type: 'boolean', default: false },
|
customConnectionAllowed: { type: 'boolean', default: false },
|
||||||
shared: { type: 'boolean', default: false },
|
shared: { type: 'boolean', default: false },
|
||||||
disabled: { type: 'boolean', default: false },
|
disabled: { type: 'boolean', default: false },
|
||||||
createdAt: { type: 'string' },
|
createdAt: { type: 'string' },
|
||||||
|
@@ -36,35 +36,6 @@ describe('AppConfig model', () => {
|
|||||||
expect(AppConfig.virtualAttributes).toMatchSnapshot();
|
expect(AppConfig.virtualAttributes).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('allowCustomConnection', () => {
|
|
||||||
it('should return true when app is enabled and allows custom connection', async () => {
|
|
||||||
const appConfig = await createAppConfig({
|
|
||||||
disabled: false,
|
|
||||||
allowCustomConnection: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(appConfig.allowCustomConnection).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return false when app is disabled', async () => {
|
|
||||||
const appConfig = await createAppConfig({
|
|
||||||
disabled: true,
|
|
||||||
allowCustomConnection: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(appConfig.allowCustomConnection).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it(`should return false when app doesn't allow custom connection`, async () => {
|
|
||||||
const appConfig = await createAppConfig({
|
|
||||||
disabled: false,
|
|
||||||
allowCustomConnection: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(appConfig.allowCustomConnection).toBe(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('connectionAllowed', () => {
|
describe('connectionAllowed', () => {
|
||||||
it('should return true when app is enabled, shared and allows custom connection with an active app auth client at least', async () => {
|
it('should return true when app is enabled, shared and allows custom connection with an active app auth client at least', async () => {
|
||||||
await createAppAuthClient({
|
await createAppAuthClient({
|
||||||
@@ -79,7 +50,7 @@ describe('AppConfig model', () => {
|
|||||||
|
|
||||||
const appConfig = await createAppConfig({
|
const appConfig = await createAppConfig({
|
||||||
disabled: false,
|
disabled: false,
|
||||||
allowCustomConnection: true,
|
customConnectionAllowed: true,
|
||||||
shared: true,
|
shared: true,
|
||||||
key: 'deepl',
|
key: 'deepl',
|
||||||
});
|
});
|
||||||
@@ -95,7 +66,7 @@ describe('AppConfig model', () => {
|
|||||||
|
|
||||||
const appConfig = await createAppConfig({
|
const appConfig = await createAppConfig({
|
||||||
disabled: false,
|
disabled: false,
|
||||||
allowCustomConnection: true,
|
customConnectionAllowed: true,
|
||||||
shared: true,
|
shared: true,
|
||||||
key: 'deepl',
|
key: 'deepl',
|
||||||
});
|
});
|
||||||
@@ -106,7 +77,7 @@ describe('AppConfig model', () => {
|
|||||||
it('should return false when app is enabled, shared and allows custom connection without any app auth clients', async () => {
|
it('should return false when app is enabled, shared and allows custom connection without any app auth clients', async () => {
|
||||||
const appConfig = await createAppConfig({
|
const appConfig = await createAppConfig({
|
||||||
disabled: false,
|
disabled: false,
|
||||||
allowCustomConnection: true,
|
customConnectionAllowed: true,
|
||||||
shared: true,
|
shared: true,
|
||||||
key: 'deepl',
|
key: 'deepl',
|
||||||
});
|
});
|
||||||
@@ -117,7 +88,7 @@ describe('AppConfig model', () => {
|
|||||||
it('should return false when app is disabled', async () => {
|
it('should return false when app is disabled', async () => {
|
||||||
const appConfig = await createAppConfig({
|
const appConfig = await createAppConfig({
|
||||||
disabled: true,
|
disabled: true,
|
||||||
allowCustomConnection: true,
|
customConnectionAllowed: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(appConfig.connectionAllowed).toBe(false);
|
expect(appConfig.connectionAllowed).toBe(false);
|
||||||
@@ -126,7 +97,7 @@ describe('AppConfig model', () => {
|
|||||||
it(`should return false when app doesn't allow custom connection`, async () => {
|
it(`should return false when app doesn't allow custom connection`, async () => {
|
||||||
const appConfig = await createAppConfig({
|
const appConfig = await createAppConfig({
|
||||||
disabled: false,
|
disabled: false,
|
||||||
allowCustomConnection: false,
|
customConnectionAllowed: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(appConfig.connectionAllowed).toBe(false);
|
expect(appConfig.connectionAllowed).toBe(false);
|
||||||
|
@@ -89,7 +89,7 @@ class Connection extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.appConfig) {
|
if (this.appConfig) {
|
||||||
return !this.appConfig.disabled && this.appConfig.allowCustomConnection;
|
return !this.appConfig.disabled && this.appConfig.customConnectionAllowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -144,7 +144,7 @@ class Connection extends Base {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!appConfig.allowCustomConnection && this.formattedData) {
|
if (!appConfig.customConnectionAllowed && this.formattedData) {
|
||||||
throw new NotAuthorizedError(
|
throw new NotAuthorizedError(
|
||||||
`New custom connections have been disabled for ${app.name}!`
|
`New custom connections have been disabled for ${app.name}!`
|
||||||
);
|
);
|
||||||
|
@@ -2,7 +2,7 @@ const appConfigSerializer = (appConfig) => {
|
|||||||
return {
|
return {
|
||||||
id: appConfig.id,
|
id: appConfig.id,
|
||||||
key: appConfig.key,
|
key: appConfig.key,
|
||||||
allowCustomConnection: appConfig.allowCustomConnection,
|
customConnectionAllowed: appConfig.customConnectionAllowed,
|
||||||
shared: appConfig.shared,
|
shared: appConfig.shared,
|
||||||
disabled: appConfig.disabled,
|
disabled: appConfig.disabled,
|
||||||
connectionAllowed: appConfig.connectionAllowed,
|
connectionAllowed: appConfig.connectionAllowed,
|
||||||
|
@@ -13,7 +13,7 @@ describe('appConfig serializer', () => {
|
|||||||
const expectedPayload = {
|
const expectedPayload = {
|
||||||
id: appConfig.id,
|
id: appConfig.id,
|
||||||
key: appConfig.key,
|
key: appConfig.key,
|
||||||
allowCustomConnection: appConfig.allowCustomConnection,
|
customConnectionAllowed: appConfig.customConnectionAllowed,
|
||||||
shared: appConfig.shared,
|
shared: appConfig.shared,
|
||||||
disabled: appConfig.disabled,
|
disabled: appConfig.disabled,
|
||||||
connectionAllowed: appConfig.connectionAllowed,
|
connectionAllowed: appConfig.connectionAllowed,
|
||||||
|
@@ -2,7 +2,7 @@ const createAppConfigMock = (appConfig) => {
|
|||||||
return {
|
return {
|
||||||
data: {
|
data: {
|
||||||
key: appConfig.key,
|
key: appConfig.key,
|
||||||
allowCustomConnection: appConfig.allowCustomConnection,
|
customConnectionAllowed: appConfig.customConnectionAllowed,
|
||||||
shared: appConfig.shared,
|
shared: appConfig.shared,
|
||||||
disabled: appConfig.disabled,
|
disabled: appConfig.disabled,
|
||||||
},
|
},
|
||||||
|
@@ -3,7 +3,7 @@ const getAppConfigMock = (appConfig) => {
|
|||||||
data: {
|
data: {
|
||||||
id: appConfig.id,
|
id: appConfig.id,
|
||||||
key: appConfig.key,
|
key: appConfig.key,
|
||||||
allowCustomConnection: appConfig.allowCustomConnection,
|
customConnectionAllowed: appConfig.customConnectionAllowed,
|
||||||
shared: appConfig.shared,
|
shared: appConfig.shared,
|
||||||
disabled: appConfig.disabled,
|
disabled: appConfig.disabled,
|
||||||
connectionAllowed: appConfig.connectionAllowed,
|
connectionAllowed: appConfig.connectionAllowed,
|
||||||
|
Reference in New Issue
Block a user