feat: Improve error msg when attempting to redeem the same activation code multiple times (no-changelog) (#7355)

This commit is contained in:
Cornelius Suermann
2023-10-05 17:08:30 +02:00
committed by GitHub
parent cd12a5990a
commit f4d8c9eed5
2 changed files with 6 additions and 2 deletions

View File

@@ -90,7 +90,11 @@ licenseController.post(
case 'RESERVATION_CONFLICT': case 'RESERVATION_CONFLICT':
message = 'Activation key not found'; message = 'Activation key not found';
break; break;
case 'RESERVATION_DUPLICATE':
message = 'Activation key has already been used on this instance';
break;
default: default:
message += `: ${error.message}`;
getLogger().error(message, { stack: error.stack ?? 'n/a' }); getLogger().error(message, { stack: error.stack ?? 'n/a' });
} }

View File

@@ -63,13 +63,13 @@ describe('POST /license/activate', () => {
test('errors out properly', async () => { test('errors out properly', async () => {
License.prototype.activate = jest.fn().mockImplementation(() => { License.prototype.activate = jest.fn().mockImplementation(() => {
throw new Error(ACTIVATION_FAILED_MESSAGE); throw new Error('some fake error');
}); });
await authOwnerAgent await authOwnerAgent
.post('/license/activate') .post('/license/activate')
.send({ activationKey: 'abcde' }) .send({ activationKey: 'abcde' })
.expect(400, { code: 400, message: ACTIVATION_FAILED_MESSAGE }); .expect(400, { code: 400, message: `${ACTIVATION_FAILED_MESSAGE}: some fake error` });
}); });
}); });