2022-10-11 15:29:23 +02:00
|
|
|
import { ensureProjectGrantExists } from 'support/api/grants';
|
|
|
|
import {
|
|
|
|
ensureHumanIsOrgMember,
|
|
|
|
ensureHumanIsNotOrgMember,
|
|
|
|
ensureHumanIsNotProjectMember,
|
|
|
|
ensureHumanIsProjectMember,
|
|
|
|
} from 'support/api/members';
|
|
|
|
import { ensureOrgExists } from 'support/api/orgs';
|
2023-02-15 02:52:11 +01:00
|
|
|
import { ensureDomainPolicy } from 'support/api/policies';
|
2022-10-11 15:29:23 +02:00
|
|
|
import { ensureHumanUserExists, ensureUserDoesntExist } from 'support/api/users';
|
2023-02-15 02:52:11 +01:00
|
|
|
import { Context } from 'support/commands';
|
2022-09-19 19:49:46 +02:00
|
|
|
import { ensureProjectExists, ensureProjectResourceDoesntExist, Roles } from '../../support/api/projects';
|
2022-04-28 12:35:02 +02:00
|
|
|
|
2022-09-02 15:43:44 +02:00
|
|
|
describe('permissions', () => {
|
2022-10-11 15:29:23 +02:00
|
|
|
beforeEach(() => {
|
2023-02-15 02:52:11 +01:00
|
|
|
cy.context()
|
|
|
|
.as('ctx')
|
|
|
|
.then((ctx) => {
|
|
|
|
ensureDomainPolicy(ctx.api, false, true, false);
|
|
|
|
});
|
2022-10-11 15:29:23 +02:00
|
|
|
});
|
2022-04-28 12:35:02 +02:00
|
|
|
|
2022-10-11 15:29:23 +02:00
|
|
|
describe('management', () => {
|
2023-02-15 02:52:11 +01:00
|
|
|
const testManagerUsername = 'e2ehumanmanager';
|
2022-10-11 15:29:23 +02:00
|
|
|
function testAuthorizations(
|
|
|
|
roles: string[],
|
2023-02-15 02:52:11 +01:00
|
|
|
beforeCreate: (ctx: Context) => void,
|
|
|
|
beforeMutate: (ctx: Context) => void,
|
|
|
|
navigate: () => void,
|
2022-10-11 15:29:23 +02:00
|
|
|
) {
|
2023-02-15 02:52:11 +01:00
|
|
|
beforeEach(() => {
|
|
|
|
cy.get<Context>('@ctx').then((ctx) => {
|
|
|
|
ensureUserDoesntExist(ctx.api, testManagerUsername);
|
|
|
|
ensureHumanUserExists(ctx.api, testManagerUsername);
|
|
|
|
});
|
2022-10-11 15:29:23 +02:00
|
|
|
});
|
2022-04-28 12:35:02 +02:00
|
|
|
|
2022-10-11 15:29:23 +02:00
|
|
|
describe('create authorization', () => {
|
2023-02-15 02:52:11 +01:00
|
|
|
beforeEach(() => {
|
|
|
|
cy.get<Context>('@ctx').then((ctx) => {
|
|
|
|
beforeCreate(ctx);
|
|
|
|
navigate();
|
|
|
|
});
|
|
|
|
});
|
2022-10-11 15:29:23 +02:00
|
|
|
|
|
|
|
it('should add a manager', () => {
|
|
|
|
cy.get('[data-e2e="add-member-button"]').click();
|
2024-08-22 09:48:36 +02:00
|
|
|
cy.get('[data-e2e="add-member-input"]').should('be.enabled').type(testManagerUsername);
|
2023-02-02 10:29:36 +01:00
|
|
|
cy.get('[data-e2e="user-option"]').first().click();
|
2022-10-11 15:29:23 +02:00
|
|
|
cy.contains('[data-e2e="role-checkbox"]', roles[0]).click();
|
|
|
|
cy.get('[data-e2e="confirm-add-member-button"]').click();
|
2023-01-04 14:38:27 +01:00
|
|
|
cy.shouldConfirmSuccess();
|
2022-10-11 15:29:23 +02:00
|
|
|
cy.contains('[data-e2e="member-avatar"]', 'ee');
|
|
|
|
});
|
2022-09-19 19:49:46 +02:00
|
|
|
});
|
2022-04-28 12:35:02 +02:00
|
|
|
|
2022-10-11 15:29:23 +02:00
|
|
|
describe('mutate authorization', () => {
|
2023-02-15 02:52:11 +01:00
|
|
|
const rowSelector = `tr:contains(${testManagerUsername})`;
|
2022-10-11 15:29:23 +02:00
|
|
|
|
|
|
|
beforeEach(() => {
|
2023-02-15 02:52:11 +01:00
|
|
|
cy.get<Context>('@ctx').then((ctx) => {
|
|
|
|
beforeMutate(ctx);
|
|
|
|
navigate();
|
|
|
|
cy.contains('[data-e2e="member-avatar"]', 'ee').click();
|
|
|
|
cy.get(rowSelector).as('managerRow');
|
|
|
|
});
|
2022-10-11 15:29:23 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should remove a manager', () => {
|
|
|
|
cy.get('@managerRow').find('[data-e2e="remove-member-button"]').click({ force: true });
|
|
|
|
cy.get('[data-e2e="confirm-dialog-button"]').click();
|
2023-01-04 14:38:27 +01:00
|
|
|
cy.shouldConfirmSuccess();
|
|
|
|
cy.shouldNotExist({
|
|
|
|
selector: rowSelector,
|
|
|
|
timeout: { ms: 2000, errMessage: 'timed out before manager disappeared from the table' },
|
|
|
|
});
|
2022-10-11 15:29:23 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should remove a managers authorization', () => {
|
|
|
|
cy.get('@managerRow').find('[data-e2e="role"]').should('have.length', roles.length);
|
|
|
|
cy.get('@managerRow')
|
|
|
|
.contains('[data-e2e="role"]', roles[0])
|
|
|
|
.find('[data-e2e="remove-role-button"]')
|
|
|
|
.click({ force: true }); // TODO: Is this a bug?
|
|
|
|
cy.get('[data-e2e="confirm-dialog-button"]').click();
|
2023-01-04 14:38:27 +01:00
|
|
|
cy.shouldConfirmSuccess();
|
2022-10-11 15:29:23 +02:00
|
|
|
cy.get('@managerRow')
|
|
|
|
.find('[data-e2e="remove-role-button"]')
|
|
|
|
.should('have.length', roles.length - 1);
|
|
|
|
});
|
2022-09-19 19:49:46 +02:00
|
|
|
});
|
2022-10-11 15:29:23 +02:00
|
|
|
}
|
2022-08-05 20:00:46 +02:00
|
|
|
|
2022-10-11 15:29:23 +02:00
|
|
|
describe('organizations', () => {
|
|
|
|
const roles = [
|
|
|
|
{ internal: 'ORG_OWNER', display: 'Org Owner' },
|
|
|
|
{ internal: 'ORG_OWNER_VIEWER', display: 'Org Owner Viewer' },
|
|
|
|
];
|
|
|
|
|
|
|
|
testAuthorizations(
|
|
|
|
roles.map((role) => role.display),
|
2023-02-15 02:52:11 +01:00
|
|
|
function (ctx: Context) {
|
|
|
|
ensureHumanIsNotOrgMember(ctx.api, testManagerUsername);
|
2022-10-11 15:29:23 +02:00
|
|
|
},
|
2023-02-15 02:52:11 +01:00
|
|
|
function (ctx: Context) {
|
|
|
|
ensureHumanIsNotOrgMember(ctx.api, testManagerUsername);
|
2022-10-11 15:29:23 +02:00
|
|
|
ensureHumanIsOrgMember(
|
2023-02-15 02:52:11 +01:00
|
|
|
ctx.api,
|
|
|
|
testManagerUsername,
|
2022-10-11 15:29:23 +02:00
|
|
|
roles.map((role) => role.internal),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
() => {
|
|
|
|
cy.visit('/orgs');
|
|
|
|
cy.contains('tr', Cypress.env('ORGANIZATION')).click();
|
|
|
|
},
|
|
|
|
);
|
2022-09-19 19:49:46 +02:00
|
|
|
});
|
2022-04-28 12:35:02 +02:00
|
|
|
|
2022-10-11 15:29:23 +02:00
|
|
|
describe('projects', () => {
|
|
|
|
describe('owned projects', () => {
|
2023-02-15 02:52:11 +01:00
|
|
|
beforeEach(() => {
|
|
|
|
cy.get<Context>('@ctx').then((ctx) => {
|
|
|
|
ensureProjectExists(ctx.api, 'e2eprojectpermission').as('projectId');
|
|
|
|
});
|
2022-10-11 15:29:23 +02:00
|
|
|
});
|
|
|
|
|
2023-02-15 02:52:11 +01:00
|
|
|
const visitOwnedProject = () => {
|
|
|
|
cy.get<number>('@projectId').then((projectId) => {
|
|
|
|
cy.visit(`/projects/${projectId}`);
|
|
|
|
});
|
2022-10-11 15:29:23 +02:00
|
|
|
};
|
2022-04-28 12:35:02 +02:00
|
|
|
|
2022-10-11 15:29:23 +02:00
|
|
|
describe('authorizations', () => {
|
|
|
|
const roles = [
|
|
|
|
{ internal: 'PROJECT_OWNER_GLOBAL', display: 'Project Owner Global' },
|
|
|
|
{ internal: 'PROJECT_OWNER_VIEWER_GLOBAL', display: 'Project Owner Viewer Global' },
|
|
|
|
];
|
|
|
|
|
|
|
|
testAuthorizations(
|
|
|
|
roles.map((role) => role.display),
|
2023-02-15 02:52:11 +01:00
|
|
|
function (ctx) {
|
|
|
|
cy.get<string>('@projectId').then((projectId) => {
|
|
|
|
ensureHumanIsNotProjectMember(ctx.api, projectId, testManagerUsername);
|
|
|
|
});
|
2022-10-11 15:29:23 +02:00
|
|
|
},
|
2023-02-15 02:52:11 +01:00
|
|
|
function (ctx) {
|
|
|
|
cy.get<string>('@projectId').then((projectId) => {
|
|
|
|
ensureHumanIsNotProjectMember(ctx.api, projectId, testManagerUsername);
|
|
|
|
ensureHumanIsProjectMember(
|
|
|
|
ctx.api,
|
|
|
|
projectId,
|
|
|
|
testManagerUsername,
|
|
|
|
roles.map((role) => role.internal),
|
|
|
|
);
|
|
|
|
});
|
2022-10-11 15:29:23 +02:00
|
|
|
},
|
|
|
|
visitOwnedProject,
|
|
|
|
);
|
2022-04-28 12:35:02 +02:00
|
|
|
});
|
2022-08-05 20:00:46 +02:00
|
|
|
|
2022-10-11 15:29:23 +02:00
|
|
|
describe('roles', () => {
|
|
|
|
const testRoleName = 'e2eroleundertestname';
|
|
|
|
|
2023-02-15 02:52:11 +01:00
|
|
|
beforeEach(() => {
|
|
|
|
cy.get<Context>('@ctx').then((ctx) => {
|
|
|
|
cy.get<string>('@projectId').then((projectId) => {
|
|
|
|
ensureProjectResourceDoesntExist(ctx.api, projectId, Roles, testRoleName);
|
|
|
|
visitOwnedProject();
|
|
|
|
});
|
|
|
|
});
|
2022-10-11 15:29:23 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should add a role', () => {
|
|
|
|
cy.get('[data-e2e="sidenav-element-roles"]').click();
|
|
|
|
cy.get('[data-e2e="add-new-role"]').click();
|
2024-08-22 09:48:36 +02:00
|
|
|
cy.get('[formcontrolname="key"]').should('be.enabled').type(testRoleName);
|
|
|
|
cy.get('[formcontrolname="displayName"]').should('be.enabled').type('e2eroleundertestdisplay');
|
|
|
|
cy.get('[formcontrolname="group"]').should('be.enabled').type('e2eroleundertestgroup');
|
2022-10-11 15:29:23 +02:00
|
|
|
cy.get('[data-e2e="save-button"]').click();
|
2023-01-04 14:38:27 +01:00
|
|
|
cy.shouldConfirmSuccess();
|
2022-10-11 15:29:23 +02:00
|
|
|
cy.contains('tr', testRoleName);
|
|
|
|
});
|
|
|
|
it('should remove a role');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('granted projects', () => {
|
2023-02-15 02:52:11 +01:00
|
|
|
beforeEach(() => {
|
|
|
|
cy.get<Context>('@ctx').then((ctx) => {
|
|
|
|
ensureOrgExists(ctx, 'e2eforeignorg').then((foreignOrgId) => {
|
|
|
|
ensureProjectExists(ctx.api, 'e2eprojectgrants', foreignOrgId)
|
|
|
|
.as('foreignProjectId')
|
|
|
|
.then((foreignProjectId) => {
|
|
|
|
ensureProjectGrantExists(ctx, foreignOrgId, foreignProjectId).as('grantId');
|
2022-10-11 15:29:23 +02:00
|
|
|
});
|
|
|
|
});
|
2023-02-15 02:52:11 +01:00
|
|
|
});
|
2022-10-11 15:29:23 +02:00
|
|
|
});
|
|
|
|
|
2023-02-15 02:52:11 +01:00
|
|
|
function visitGrantedProject() {
|
|
|
|
cy.get<string>('@foreignProjectId').then((foreignProjectId) => {
|
|
|
|
cy.get<string>('@grantId').then((grantId) => {
|
|
|
|
cy.visit(`/granted-projects/${foreignProjectId}/grant/${grantId}`);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2022-10-11 15:29:23 +02:00
|
|
|
|
|
|
|
describe('authorizations', () => {
|
|
|
|
const roles = [
|
|
|
|
{ internal: 'PROJECT_GRANT_OWNER', display: 'Project Grant Owner' },
|
|
|
|
{ internal: 'PROJECT_GRANT_OWNER_VIEWER', display: 'Project Grant Owner Viewer' },
|
|
|
|
];
|
|
|
|
|
|
|
|
testAuthorizations(
|
|
|
|
roles.map((role) => role.display),
|
2023-02-15 02:52:11 +01:00
|
|
|
function (ctx: Context) {
|
|
|
|
cy.get<string>('@foreignProjectId').then((foreignProjectId) => {
|
|
|
|
cy.get<string>('@grantId').then((grantId) => {
|
|
|
|
ensureHumanIsNotProjectMember(ctx.api, foreignProjectId, testManagerUsername, grantId);
|
|
|
|
});
|
|
|
|
});
|
2022-10-11 15:29:23 +02:00
|
|
|
},
|
2023-02-15 02:52:11 +01:00
|
|
|
function (ctx: Context) {
|
|
|
|
cy.get<string>('@foreignProjectId').then((foreignProjectId) => {
|
|
|
|
cy.get<string>('@grantId').then((grantId) => {
|
|
|
|
ensureHumanIsNotProjectMember(ctx.api, foreignProjectId, testManagerUsername, grantId);
|
|
|
|
ensureHumanIsProjectMember(
|
|
|
|
ctx.api,
|
|
|
|
foreignProjectId,
|
|
|
|
testManagerUsername,
|
|
|
|
roles.map((role) => role.internal),
|
|
|
|
grantId,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2022-10-11 15:29:23 +02:00
|
|
|
},
|
|
|
|
visitGrantedProject,
|
|
|
|
);
|
2022-04-28 12:35:02 +02:00
|
|
|
});
|
2022-10-11 15:29:23 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2023-02-15 02:52:11 +01:00
|
|
|
});
|
2022-10-11 15:29:23 +02:00
|
|
|
|
2023-02-15 02:52:11 +01:00
|
|
|
describe('validations', () => {
|
|
|
|
describe('owned projects', () => {
|
|
|
|
describe('no ownership', () => {
|
|
|
|
it('a user without project global ownership can ...');
|
|
|
|
it('a user without project global ownership can not ...');
|
|
|
|
});
|
|
|
|
describe('project owner viewer global', () => {
|
|
|
|
it('a project owner viewer global additionally can ...');
|
|
|
|
it('a project owner viewer global still can not ...');
|
|
|
|
});
|
|
|
|
describe('project owner global', () => {
|
|
|
|
it('a project owner global additionally can ...');
|
|
|
|
it('a project owner global still can not ...');
|
2022-10-11 15:29:23 +02:00
|
|
|
});
|
2023-02-15 02:52:11 +01:00
|
|
|
});
|
2022-08-05 20:00:46 +02:00
|
|
|
|
2023-02-15 02:52:11 +01:00
|
|
|
describe('granted projects', () => {
|
|
|
|
describe('no ownership', () => {
|
|
|
|
it('a user without project grant ownership can ...');
|
|
|
|
it('a user without project grant ownership can not ...');
|
2022-10-11 15:29:23 +02:00
|
|
|
});
|
2023-02-15 02:52:11 +01:00
|
|
|
describe('project grant owner viewer', () => {
|
|
|
|
it('a project grant owner viewer additionally can ...');
|
|
|
|
it('a project grant owner viewer still can not ...');
|
|
|
|
});
|
|
|
|
describe('project grant owner', () => {
|
|
|
|
it('a project grant owner additionally can ...');
|
|
|
|
it('a project grant owner still can not ...');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
describe('organization', () => {
|
|
|
|
describe('org owner', () => {
|
|
|
|
it('a project owner global can ...');
|
|
|
|
it('a project owner global can not ...');
|
2022-10-11 15:29:23 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|