mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 09:36:44 +00:00
fix(core): Credential export for personal projects (#19720)
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { Container } from '@n8n/di';
|
||||
import { In } from '@n8n/typeorm';
|
||||
|
||||
import { SharedCredentials } from '../../entities';
|
||||
import { mockEntityManager } from '../../utils/test-utils/mock-entity-manager';
|
||||
import { SharedCredentialsRepository } from '../shared-credentials.repository';
|
||||
|
||||
describe('SharedCredentialsRepository', () => {
|
||||
const entityManager = mockEntityManager(SharedCredentials);
|
||||
const sharedCredentialsRepository = Container.get(SharedCredentialsRepository);
|
||||
|
||||
beforeEach(() => {
|
||||
jest.resetAllMocks();
|
||||
});
|
||||
|
||||
describe('findByCredentialIds', () => {
|
||||
it('should return shared credentials with project relations including role', async () => {
|
||||
const credentialIds = ['cred1', 'cred2'];
|
||||
const role = 'credential:owner';
|
||||
|
||||
entityManager.find.mockResolvedValueOnce([]);
|
||||
|
||||
await sharedCredentialsRepository.findByCredentialIds(credentialIds, role);
|
||||
|
||||
expect(entityManager.find).toHaveBeenCalledWith(SharedCredentials, {
|
||||
relations: { credentials: true, project: { projectRelations: { user: true, role: true } } },
|
||||
where: {
|
||||
credentialsId: In(credentialIds),
|
||||
role,
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -14,7 +14,7 @@ export class SharedCredentialsRepository extends Repository<SharedCredentials> {
|
||||
|
||||
async findByCredentialIds(credentialIds: string[], role: CredentialSharingRole) {
|
||||
return await this.find({
|
||||
relations: { credentials: true, project: { projectRelations: { user: true } } },
|
||||
relations: { credentials: true, project: { projectRelations: { user: true, role: true } } },
|
||||
where: {
|
||||
credentialsId: In(credentialIds),
|
||||
role,
|
||||
|
||||
Reference in New Issue
Block a user