Skip to content

Commit

Permalink
review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
valya committed Jul 23, 2024
1 parent 6b7928d commit ed81de5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions packages/cli/src/credentials/credentials.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,15 +308,15 @@ export class CredentialsController {
let newShareeIds: string[] = [];

await Db.transaction(async (trx) => {
const currentProjectIDs = credential.shared
const currentProjectIds = credential.shared
.filter((sc) => sc.role === 'credential:user')
.map((sc) => sc.projectId);
const newProjectIds = shareWithIds;

const toShare = utils.rightDiff([currentProjectIDs, (id) => id], [newProjectIds, (id) => id]);
const toShare = utils.rightDiff([currentProjectIds, (id) => id], [newProjectIds, (id) => id]);
const toUnshare = utils.rightDiff(
[newProjectIds, (id) => id],
[currentProjectIDs, (id) => id],
[currentProjectIds, (id) => id],
);

const deleteResult = await trx.delete(SharedCredentials, {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/credentials/credentials.service.ee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class EnterpriseCredentialsService {
id: In(shareWithIds),
type: 'team',
// if user can see all projects, don't check project access
// if they don't, find projects they can list
// if they can't, find projects they can list
...(user.hasGlobalScope('project:list')
? {}
: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ describe('PUT /credentials/:id/share', () => {
config.set('userManagement.emails.mode', 'smtp');
});

test('should be able to share from personal project to team project that member has access to', async () => {
test('member should be able to share from personal project to team project that member has access to', async () => {
const savedCredential = await saveCredential(randomCredentialPayload(), { user: member });

const testProject = await createTeamProject();
Expand All @@ -1000,7 +1000,7 @@ describe('PUT /credentials/:id/share', () => {
expect(testShare?.role).toBe('credential:user');
});

test('should be able to share from team project to personal project', async () => {
test('member should be able to share from team project to personal project', async () => {
const testProject = await createTeamProject(undefined, member);

const savedCredential = await saveCredential(randomCredentialPayload(), {
Expand All @@ -1020,7 +1020,7 @@ describe('PUT /credentials/:id/share', () => {
expect(testShare?.role).toBe('credential:user');
});

test('should be able to share from team project to team project that member has access to', async () => {
test('member should be able to share from team project to team project that member has access to', async () => {
const testProject = await createTeamProject(undefined, member);
const testProject2 = await createTeamProject();
await linkUserToProject(member, testProject2, 'project:editor');
Expand All @@ -1042,7 +1042,7 @@ describe('PUT /credentials/:id/share', () => {
expect(testShare?.role).toBe('credential:user');
});

test('admins should be able to share from any team project to team project ', async () => {
test('admins should be able to share from any team project to any team project ', async () => {
const testProject = await createTeamProject();
const testProject2 = await createTeamProject();

Expand All @@ -1063,7 +1063,7 @@ describe('PUT /credentials/:id/share', () => {
expect(testShare?.role).toBe('credential:user');
});

test('admins should be able to share from any team project to personal project ', async () => {
test("admins should be able to share from any team project to any user's personal project ", async () => {
const testProject = await createTeamProject();

const savedCredential = await saveCredential(randomCredentialPayload(), {
Expand All @@ -1083,7 +1083,7 @@ describe('PUT /credentials/:id/share', () => {
expect(testShare?.role).toBe('credential:user');
});

test('admins should be able to share from any personal project to team project ', async () => {
test('admins should be able to share from any personal project to any team project ', async () => {
const testProject = await createTeamProject();

const savedCredential = await saveCredential(randomCredentialPayload(), {
Expand Down

0 comments on commit ed81de5

Please sign in to comment.