mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
refactor(core): Abstract away InstanceSettings and encryptionKey into injectable services (no-changelog) (#7471)
This change ensures that things like `encryptionKey` and `instanceId` are always available directly where they are needed, instead of passing them around throughout the code.
This commit is contained in:
committed by
GitHub
parent
519680c2cf
commit
b6de910cbe
@@ -1,10 +1,8 @@
|
||||
import type { SuperAgentTest } from 'supertest';
|
||||
import { In } from 'typeorm';
|
||||
import { UserSettings } from 'n8n-core';
|
||||
import type { IUser } from 'n8n-workflow';
|
||||
|
||||
import * as Db from '@/Db';
|
||||
import { RESPONSE_ERROR_MESSAGES } from '@/constants';
|
||||
import type { Credentials } from '@/requests';
|
||||
import * as UserManagementHelpers from '@/UserManagement/UserManagementHelper';
|
||||
import type { Role } from '@db/entities/Role';
|
||||
@@ -304,21 +302,6 @@ describe('GET /credentials/:id', () => {
|
||||
expect(response.body.data).toBeUndefined(); // owner's cred not returned
|
||||
});
|
||||
|
||||
test('should fail with missing encryption key', async () => {
|
||||
const savedCredential = await saveCredential(randomCredentialPayload(), { user: owner });
|
||||
|
||||
const mock = jest.spyOn(UserSettings, 'getEncryptionKey');
|
||||
mock.mockRejectedValue(new Error(RESPONSE_ERROR_MESSAGES.NO_ENCRYPTION_KEY));
|
||||
|
||||
const response = await authOwnerAgent
|
||||
.get(`/credentials/${savedCredential.id}`)
|
||||
.query({ includeData: true });
|
||||
|
||||
expect(response.statusCode).toBe(500);
|
||||
|
||||
mock.mockRestore();
|
||||
});
|
||||
|
||||
test('should return 404 if cred not found', async () => {
|
||||
const response = await authOwnerAgent.get('/credentials/789');
|
||||
expect(response.statusCode).toBe(404);
|
||||
|
||||
Reference in New Issue
Block a user