feat(AppConfig): iterate how apps are managed

- auth clients are always shared, cannot be disabled
- custom connections are enabled by default, can be disabled
- any existing connections can be reconnected regardless of its AppConfig or AppAuthClient states
This commit is contained in:
Ali BARIN
2024-12-09 17:46:51 +00:00
parent 00e80f1fba
commit a57134a89c
48 changed files with 192 additions and 563 deletions

View File

@@ -10,12 +10,11 @@ export default async (request, response) => {
};
const appConfigParams = (request) => {
const { customConnectionAllowed, shared, disabled } = request.body;
const { useOnlyPredefinedAuthClients, disabled } = request.body;
return {
key: request.params.appKey,
customConnectionAllowed,
shared,
useOnlyPredefinedAuthClients,
disabled,
};
};

View File

@@ -23,8 +23,7 @@ describe('POST /api/v1/admin/apps/:appKey/config', () => {
it('should return created app config', async () => {
const appConfig = {
customConnectionAllowed: true,
shared: true,
useOnlyPredefinedAuthClients: false,
disabled: false,
};
@@ -38,14 +37,14 @@ describe('POST /api/v1/admin/apps/:appKey/config', () => {
...appConfig,
key: 'gitlab',
});
expect(response.body).toMatchObject(expectedPayload);
});
it('should return HTTP 422 for already existing app config', async () => {
const appConfig = {
key: 'gitlab',
customConnectionAllowed: true,
shared: true,
useOnlyPredefinedAuthClients: false,
disabled: false,
};

View File

@@ -17,11 +17,10 @@ export default async (request, response) => {
};
const appConfigParams = (request) => {
const { customConnectionAllowed, shared, disabled } = request.body;
const { useOnlyPredefinedAuthClients, disabled } = request.body;
return {
customConnectionAllowed,
shared,
useOnlyPredefinedAuthClients,
disabled,
};
};

View File

@@ -24,17 +24,15 @@ describe('PATCH /api/v1/admin/apps/:appKey/config', () => {
it('should return updated app config', async () => {
const appConfig = {
key: 'gitlab',
customConnectionAllowed: true,
shared: true,
useOnlyPredefinedAuthClients: true,
disabled: false,
};
await createAppConfig(appConfig);
const newAppConfigValues = {
shared: false,
disabled: true,
customConnectionAllowed: false,
useOnlyPredefinedAuthClients: false,
};
const response = await request(app)
@@ -53,9 +51,8 @@ describe('PATCH /api/v1/admin/apps/:appKey/config', () => {
it('should return not found response for unexisting app config', async () => {
const appConfig = {
shared: false,
disabled: true,
customConnectionAllowed: false,
useOnlyPredefinedAuthClients: false,
};
await request(app)
@@ -68,8 +65,7 @@ describe('PATCH /api/v1/admin/apps/:appKey/config', () => {
it('should return HTTP 422 for invalid app config data', async () => {
const appConfig = {
key: 'gitlab',
customConnectionAllowed: true,
shared: true,
useOnlyPredefinedAuthClients: true,
disabled: false,
};