refactor(app-config): rename allow_custom_connection as custom_connection_allowed
This commit is contained in:
@@ -3,10 +3,6 @@
|
||||
exports[`AppConfig model > jsonSchema should have correct validations 1`] = `
|
||||
{
|
||||
"properties": {
|
||||
"allowCustomConnection": {
|
||||
"default": false,
|
||||
"type": "boolean",
|
||||
},
|
||||
"connectionAllowed": {
|
||||
"default": false,
|
||||
"type": "boolean",
|
||||
@@ -14,6 +10,10 @@ exports[`AppConfig model > jsonSchema should have correct validations 1`] = `
|
||||
"createdAt": {
|
||||
"type": "string",
|
||||
},
|
||||
"customConnectionAllowed": {
|
||||
"default": false,
|
||||
"type": "boolean",
|
||||
},
|
||||
"disabled": {
|
||||
"default": false,
|
||||
"type": "boolean",
|
||||
@@ -39,3 +39,5 @@ exports[`AppConfig model > jsonSchema should have correct validations 1`] = `
|
||||
"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' },
|
||||
key: { type: 'string' },
|
||||
connectionAllowed: { type: 'boolean', default: false },
|
||||
allowCustomConnection: { type: 'boolean', default: false },
|
||||
customConnectionAllowed: { type: 'boolean', default: false },
|
||||
shared: { type: 'boolean', default: false },
|
||||
disabled: { type: 'boolean', default: false },
|
||||
createdAt: { type: 'string' },
|
||||
|
@@ -36,35 +36,6 @@ describe('AppConfig model', () => {
|
||||
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', () => {
|
||||
it('should return true when app is enabled, shared and allows custom connection with an active app auth client at least', async () => {
|
||||
await createAppAuthClient({
|
||||
@@ -79,7 +50,7 @@ describe('AppConfig model', () => {
|
||||
|
||||
const appConfig = await createAppConfig({
|
||||
disabled: false,
|
||||
allowCustomConnection: true,
|
||||
customConnectionAllowed: true,
|
||||
shared: true,
|
||||
key: 'deepl',
|
||||
});
|
||||
@@ -95,7 +66,7 @@ describe('AppConfig model', () => {
|
||||
|
||||
const appConfig = await createAppConfig({
|
||||
disabled: false,
|
||||
allowCustomConnection: true,
|
||||
customConnectionAllowed: true,
|
||||
shared: true,
|
||||
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 () => {
|
||||
const appConfig = await createAppConfig({
|
||||
disabled: false,
|
||||
allowCustomConnection: true,
|
||||
customConnectionAllowed: true,
|
||||
shared: true,
|
||||
key: 'deepl',
|
||||
});
|
||||
@@ -117,7 +88,7 @@ describe('AppConfig model', () => {
|
||||
it('should return false when app is disabled', async () => {
|
||||
const appConfig = await createAppConfig({
|
||||
disabled: true,
|
||||
allowCustomConnection: true,
|
||||
customConnectionAllowed: true,
|
||||
});
|
||||
|
||||
expect(appConfig.connectionAllowed).toBe(false);
|
||||
@@ -126,7 +97,7 @@ describe('AppConfig model', () => {
|
||||
it(`should return false when app doesn't allow custom connection`, async () => {
|
||||
const appConfig = await createAppConfig({
|
||||
disabled: false,
|
||||
allowCustomConnection: false,
|
||||
customConnectionAllowed: false,
|
||||
});
|
||||
|
||||
expect(appConfig.connectionAllowed).toBe(false);
|
||||
|
@@ -89,7 +89,7 @@ class Connection extends Base {
|
||||
}
|
||||
|
||||
if (this.appConfig) {
|
||||
return !this.appConfig.disabled && this.appConfig.allowCustomConnection;
|
||||
return !this.appConfig.disabled && this.appConfig.customConnectionAllowed;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -144,7 +144,7 @@ class Connection extends Base {
|
||||
);
|
||||
}
|
||||
|
||||
if (!appConfig.allowCustomConnection && this.formattedData) {
|
||||
if (!appConfig.customConnectionAllowed && this.formattedData) {
|
||||
throw new NotAuthorizedError(
|
||||
`New custom connections have been disabled for ${app.name}!`
|
||||
);
|
||||
|
Reference in New Issue
Block a user