feat(core): Only show credentials shared with you in the overview section (no-changelog) (#14855)

Co-authored-by: Danny Martini <danny@n8n.io>
This commit is contained in:
Ricardo Espinoza
2025-04-30 09:44:58 -04:00
committed by GitHub
parent 833d8e3c18
commit b86fabf047
3 changed files with 74 additions and 19 deletions

View File

@@ -618,28 +618,54 @@ describe('GET /credentials', () => {
expect(response.body.data).toHaveLength(0);
});
test('should return only owned and explicitly shared credentials when filtering by any personal project id', async () => {
test('should return only owned credentials when filtering by owner personal project id', async () => {
// Create credential owned by `owner` and share it to `member`
const ownerCredential = await saveCredential(payload(), {
user: owner,
role: 'credential:owner',
});
await shareCredentialWithUsers(ownerCredential, [member]);
// Create credential owned by `member`
const memberCredential = await saveCredential(payload(), {
user: member,
role: 'credential:owner',
});
await shareCredentialWithUsers(memberCredential, [owner]);
// Simulate editing a workflow owned by `owner` so request credentials to their personal project
const response: GetAllResponse = await testServer
.authAgentFor(member)
.authAgentFor(owner)
.get('/credentials')
.query(`filter={ "projectId": "${ownerPersonalProject.id}" }`)
.expect(200);
expect(response.body.data).toHaveLength(2);
expect(response.body.data).toHaveLength(1);
expect(response.body.data.map((credential) => credential.id)).toContain(ownerCredential.id);
});
test('should return only owned credentials when filtering by member personal project id', async () => {
// Create credential owned by `member`
const memberCredential = await saveCredential(payload(), {
user: member,
role: 'credential:owner',
});
// Create credential owned by `owner` and share it to `member`
const ownerCredential = await saveCredential(payload(), {
user: owner,
role: 'credential:owner',
});
await shareCredentialWithUsers(ownerCredential, [member]);
// Simulate editing a workflow owned by `owner` so request credentials to their personal project
const response: GetAllResponse = await testServer
.authAgentFor(owner)
.get('/credentials')
.query(`filter={ "projectId": "${memberPersonalProject.id}" }`)
.expect(200);
expect(response.body.data).toHaveLength(1);
expect(response.body.data.map((credential) => credential.id)).toContain(memberCredential.id);
});