mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
refactor(core): Move license endpoints to a decorated controller class (no-changelog) (#8074)
This commit is contained in:
committed by
GitHub
parent
63a6e7e034
commit
a63d94f28c
@@ -60,7 +60,7 @@ describe('POST /license/activate', () => {
|
||||
await authMemberAgent
|
||||
.post('/license/activate')
|
||||
.send({ activationKey: 'abcde' })
|
||||
.expect(403, { code: 403, message: NON_OWNER_ACTIVATE_RENEW_MESSAGE });
|
||||
.expect(403, UNAUTHORIZED_RESPONSE);
|
||||
});
|
||||
|
||||
test('errors out properly', async () => {
|
||||
@@ -82,19 +82,17 @@ describe('POST /license/renew', () => {
|
||||
});
|
||||
|
||||
test('does not work for regular users', async () => {
|
||||
await authMemberAgent
|
||||
.post('/license/renew')
|
||||
.expect(403, { code: 403, message: NON_OWNER_ACTIVATE_RENEW_MESSAGE });
|
||||
await authMemberAgent.post('/license/renew').expect(403, UNAUTHORIZED_RESPONSE);
|
||||
});
|
||||
|
||||
test('errors out properly', async () => {
|
||||
License.prototype.renew = jest.fn().mockImplementation(() => {
|
||||
throw new Error(RENEW_ERROR_MESSAGE);
|
||||
throw new Error(GENERIC_ERROR_MESSAGE);
|
||||
});
|
||||
|
||||
await authOwnerAgent
|
||||
.post('/license/renew')
|
||||
.expect(400, { code: 400, message: RENEW_ERROR_MESSAGE });
|
||||
.expect(400, { code: 400, message: `Failed to renew license: ${GENERIC_ERROR_MESSAGE}` });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -131,6 +129,6 @@ const DEFAULT_POST_RESPONSE: { data: ILicensePostResponse } = {
|
||||
},
|
||||
};
|
||||
|
||||
const NON_OWNER_ACTIVATE_RENEW_MESSAGE = 'Only an instance owner may activate or renew a license';
|
||||
const UNAUTHORIZED_RESPONSE = { status: 'error', message: 'Unauthorized' };
|
||||
const ACTIVATION_FAILED_MESSAGE = 'Failed to activate license';
|
||||
const RENEW_ERROR_MESSAGE = 'Something went wrong when trying to renew license';
|
||||
const GENERIC_ERROR_MESSAGE = 'Something went wrong';
|
||||
|
||||
Reference in New Issue
Block a user