mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
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:
@@ -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);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user