mirror of
https://github.com/andwati/zitadel.git
synced 2026-12-01 00:18:51 +00:00
test(e2e): test authorizations (#4342)
* add specs that cover the b2b demo * update cypress * test handling manager roles * use shared mocha contexts * use beforeEach instead of before * improve readability * improve application test * remove static waits * remove old awaitDesired * test owned project authorizations * simplify ensure.ts * test granted projects authz * disable prevSubject for shouldNotExist * await non-existence, then expect no error * update dependencies * fix tests from scratch * fix settings tests from scratch * Apply suggestions from code review Co-authored-by: Max Peintner <[email protected]> * Implement code review suggestions * use spread operator * settings properties must match * add check settings object * revert spread operator Co-authored-by: Max Peintner <[email protected]>
This commit is contained in:
co-authored by
Max Peintner
parent
6daf44a34a
commit
51febd7e4e
@@ -5,37 +5,43 @@ describe('applications', () => {
|
||||
const testProjectName = 'e2eprojectapplication';
|
||||
const testAppName = 'e2eappundertest';
|
||||
|
||||
beforeEach(`ensure it doesn't exist already`, () => {
|
||||
apiAuth().then((api) => {
|
||||
ensureProjectExists(api, testProjectName).then((projectID) => {
|
||||
ensureProjectResourceDoesntExist(api, projectID, Apps, testAppName).then(() => {
|
||||
cy.visit(`/projects/${projectID}`);
|
||||
});
|
||||
beforeEach(() => {
|
||||
apiAuth()
|
||||
.as('api')
|
||||
.then((api) => {
|
||||
ensureProjectExists(api, testProjectName).as('projectId');
|
||||
});
|
||||
});
|
||||
|
||||
describe('add app', function () {
|
||||
beforeEach(`ensure it doesn't exist already`, function () {
|
||||
ensureProjectResourceDoesntExist(this.api, this.projectId, Apps, testAppName);
|
||||
cy.visit(`/projects/${this.projectId}`);
|
||||
});
|
||||
|
||||
it('add app', () => {
|
||||
cy.get('[data-e2e="app-card-add"]').should('be.visible').click();
|
||||
cy.get('[formcontrolname="name"]').focus().type(testAppName);
|
||||
cy.get('[for="WEB"]').click();
|
||||
cy.get('[data-e2e="continue-button-nameandtype"]').click();
|
||||
cy.get('[for="PKCE"]').should('be.visible').click();
|
||||
cy.get('[data-e2e="continue-button-authmethod"]').click();
|
||||
cy.get('[data-e2e="redirect-uris"] input').focus().type('http://localhost:3000/api/auth/callback/zitadel');
|
||||
cy.get('[data-e2e="postlogout-uris"] input').focus().type('http://localhost:3000');
|
||||
cy.get('[data-e2e="continue-button-redirecturis"]').click();
|
||||
cy.get('[data-e2e="create-button"]').click();
|
||||
cy.get('[id*=overlay]').should('exist');
|
||||
cy.get('.data-e2e-success');
|
||||
const expectClientId = new RegExp(`^.*[0-9]+\\@${testProjectName}.*$`);
|
||||
cy.get('[data-e2e="client-id-copy"]').click();
|
||||
cy.contains('[data-e2e="client-id"]', expectClientId);
|
||||
cy.clipboardMatches(expectClientId);
|
||||
cy.shouldNotExist({ selector: '.data-e2e-failure' });
|
||||
});
|
||||
});
|
||||
|
||||
it('add app', () => {
|
||||
cy.get('[data-e2e="app-card-add"]').should('be.visible').click();
|
||||
// select webapp
|
||||
cy.get('[formcontrolname="name"]').type(testAppName);
|
||||
cy.get('[for="WEB"]').click();
|
||||
cy.get('[data-e2e="continue-button-nameandtype"]').click();
|
||||
//select authentication
|
||||
cy.get('[for="PKCE"]').click();
|
||||
cy.get('[data-e2e="continue-button-authmethod"]').click();
|
||||
//enter URL
|
||||
cy.get('cnsl-redirect-uris').eq(0).type('https://testurl.org');
|
||||
cy.get('cnsl-redirect-uris').eq(1).type('https://testlogouturl.org');
|
||||
cy.get('[data-e2e="continue-button-redirecturis"]').click();
|
||||
cy.get('[data-e2e="create-button"]')
|
||||
.click()
|
||||
.then(() => {
|
||||
cy.get('[id*=overlay]').should('exist');
|
||||
});
|
||||
cy.get('.data-e2e-success');
|
||||
cy.wait(200);
|
||||
cy.get('.data-e2e-failure', { timeout: 0 }).should('not.exist');
|
||||
//TODO: check client ID/Secret
|
||||
describe('edit app', () => {
|
||||
it('should configure an application to enable dev mode');
|
||||
it('should configure an application to put user roles and info inside id token');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -7,19 +7,20 @@ describe('humans', () => {
|
||||
const testHumanUserNameAdd = 'e2ehumanusernameadd';
|
||||
const testHumanUserNameRemove = 'e2ehumanusernameremove';
|
||||
|
||||
beforeEach(() => {
|
||||
apiAuth().as('api');
|
||||
});
|
||||
|
||||
describe('add', () => {
|
||||
before(`ensure it doesn't exist already`, () => {
|
||||
apiAuth().then((apiCallProperties) => {
|
||||
ensureUserDoesntExist(apiCallProperties, testHumanUserNameAdd).then(() => {
|
||||
cy.visit(humansPath);
|
||||
});
|
||||
});
|
||||
beforeEach(`ensure it doesn't exist already`, function () {
|
||||
ensureUserDoesntExist(this.api, loginname(testHumanUserNameAdd, Cypress.env('ORGANIZATION')));
|
||||
cy.visit(humansPath);
|
||||
});
|
||||
|
||||
it('should add a user', () => {
|
||||
cy.get('[data-e2e="create-user-button"]').click();
|
||||
cy.url().should('contain', 'users/create');
|
||||
cy.get('[formcontrolname="email"]').type(loginname('e2ehuman', Cypress.env('ORGANIZATION')));
|
||||
cy.get('[formcontrolname="email"]').type('[email protected]');
|
||||
//force needed due to the prefilled username prefix
|
||||
cy.get('[formcontrolname="userName"]').type(loginname(testHumanUserNameAdd, Cypress.env('ORGANIZATION')));
|
||||
cy.get('[formcontrolname="firstName"]').type('e2ehumanfirstname');
|
||||
@@ -27,33 +28,29 @@ describe('humans', () => {
|
||||
cy.get('[formcontrolname="phone"]').type('+41 123456789');
|
||||
cy.get('[data-e2e="create-button"]').click();
|
||||
cy.get('.data-e2e-success');
|
||||
cy.wait(200);
|
||||
cy.get('.data-e2e-failure', { timeout: 0 }).should('not.exist');
|
||||
const loginName = loginname(testHumanUserNameAdd, Cypress.env('ORGANIZATION'));
|
||||
cy.contains('[data-e2e="copy-loginname"]', loginName).click();
|
||||
cy.clipboardMatches(loginName);
|
||||
cy.shouldNotExist({ selector: '.data-e2e-failure' });
|
||||
});
|
||||
});
|
||||
|
||||
describe('remove', () => {
|
||||
before('ensure it exists', () => {
|
||||
apiAuth().then((api) => {
|
||||
ensureHumanUserExists(api, loginname(testHumanUserNameRemove, Cypress.env('ORGANIZATION'))).then(() => {
|
||||
cy.visit(humansPath);
|
||||
});
|
||||
});
|
||||
beforeEach('ensure it exists', function () {
|
||||
ensureHumanUserExists(this.api, loginname(testHumanUserNameRemove, Cypress.env('ORGANIZATION')));
|
||||
cy.visit(humansPath);
|
||||
});
|
||||
|
||||
it('should delete a human user', () => {
|
||||
cy.contains('tr', testHumanUserNameRemove)
|
||||
// doesn't work, need to force click.
|
||||
// .trigger('mouseover')
|
||||
.find('[data-e2e="enabled-delete-button"]')
|
||||
.click({ force: true });
|
||||
const rowSelector = `tr:contains(${testHumanUserNameRemove})`;
|
||||
cy.get(rowSelector).find('[data-e2e="enabled-delete-button"]').click({ force: true });
|
||||
cy.get('[data-e2e="confirm-dialog-input"]')
|
||||
.focus()
|
||||
.type(loginname(testHumanUserNameRemove, Cypress.env('ORGANIZATION')));
|
||||
cy.get('[data-e2e="confirm-dialog-button"]').click();
|
||||
cy.get('.data-e2e-success');
|
||||
cy.wait(200);
|
||||
cy.get('.data-e2e-failure', { timeout: 0 }).should('not.exist');
|
||||
cy.shouldNotExist({ selector: rowSelector, timeout: 2000 });
|
||||
cy.shouldNotExist({ selector: '.data-e2e-failure' });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,17 +3,18 @@ import { ensureMachineUserExists, ensureUserDoesntExist } from '../../support/ap
|
||||
import { loginname } from '../../support/login/users';
|
||||
|
||||
describe('machines', () => {
|
||||
beforeEach(() => {
|
||||
apiAuth().as('api');
|
||||
});
|
||||
|
||||
const machinesPath = `/users?type=machine`;
|
||||
const testMachineUserNameAdd = 'e2emachineusernameadd';
|
||||
const testMachineUserNameRemove = 'e2emachineusernameremove';
|
||||
|
||||
describe('add', () => {
|
||||
before(`ensure it doesn't exist already`, () => {
|
||||
apiAuth().then((apiCallProperties) => {
|
||||
ensureUserDoesntExist(apiCallProperties, testMachineUserNameAdd).then(() => {
|
||||
cy.visit(machinesPath);
|
||||
});
|
||||
});
|
||||
beforeEach(`ensure it doesn't exist already`, function () {
|
||||
ensureUserDoesntExist(this.api, testMachineUserNameAdd);
|
||||
cy.visit(machinesPath);
|
||||
});
|
||||
|
||||
it('should add a machine', () => {
|
||||
@@ -25,31 +26,28 @@ describe('machines', () => {
|
||||
cy.get('[formcontrolname="description"]').type('e2emachinedescription');
|
||||
cy.get('[data-e2e="create-button"]').click();
|
||||
cy.get('.data-e2e-success');
|
||||
cy.wait(200);
|
||||
cy.get('.data-e2e-failure', { timeout: 0 }).should('not.exist');
|
||||
cy.contains('[data-e2e="copy-loginname"]', testMachineUserNameAdd).click();
|
||||
cy.clipboardMatches(testMachineUserNameAdd);
|
||||
cy.shouldNotExist({ selector: '.data-e2e-failure' });
|
||||
});
|
||||
});
|
||||
|
||||
describe('remove', () => {
|
||||
before('ensure it exists', () => {
|
||||
apiAuth().then((api) => {
|
||||
ensureMachineUserExists(api, testMachineUserNameRemove).then(() => {
|
||||
cy.visit(machinesPath);
|
||||
});
|
||||
});
|
||||
describe('edit', () => {
|
||||
beforeEach('ensure it exists', function () {
|
||||
ensureMachineUserExists(this.api, testMachineUserNameRemove);
|
||||
cy.visit(machinesPath);
|
||||
});
|
||||
|
||||
it('should delete a machine', () => {
|
||||
cy.contains('tr', testMachineUserNameRemove)
|
||||
// doesn't work, need to force click.
|
||||
// .trigger('mouseover')
|
||||
.find('[data-e2e="enabled-delete-button"]')
|
||||
.click({ force: true });
|
||||
const rowSelector = `tr:contains(${testMachineUserNameRemove})`;
|
||||
cy.get(rowSelector).find('[data-e2e="enabled-delete-button"]').click({ force: true });
|
||||
cy.get('[data-e2e="confirm-dialog-input"]').focus().type(testMachineUserNameRemove);
|
||||
cy.get('[data-e2e="confirm-dialog-button"]').click();
|
||||
cy.get('.data-e2e-success');
|
||||
cy.wait(200);
|
||||
cy.get('.data-e2e-failure', { timeout: 0 }).should('not.exist');
|
||||
cy.shouldNotExist({ selector: rowSelector, timeout: 2000 });
|
||||
cy.shouldNotExist({ selector: '.data-e2e-failure' });
|
||||
});
|
||||
|
||||
it('should create a personal access token');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
describe('organizations', () => {
|
||||
it('should add an organization with the personal account as org owner');
|
||||
describe('changing the current organization', () => {
|
||||
it('should update displayed organization details');
|
||||
});
|
||||
});
|
||||
@@ -1,110 +1,249 @@
|
||||
import { ensureProjectGrantExists } from 'support/api/grants';
|
||||
import {
|
||||
ensureHumanIsOrgMember,
|
||||
ensureHumanIsNotOrgMember,
|
||||
ensureHumanIsNotProjectMember,
|
||||
ensureHumanIsProjectMember,
|
||||
} from 'support/api/members';
|
||||
import { ensureOrgExists } from 'support/api/orgs';
|
||||
import { ensureHumanUserExists, ensureUserDoesntExist } from 'support/api/users';
|
||||
import { loginname } from 'support/login/users';
|
||||
import { apiAuth } from '../../support/api/apiauth';
|
||||
import { ensureProjectExists, ensureProjectResourceDoesntExist, Roles } from '../../support/api/projects';
|
||||
|
||||
describe('permissions', () => {
|
||||
const testProjectName = 'e2eprojectpermission';
|
||||
const testAppName = 'e2eapppermission';
|
||||
const testRoleName = 'e2eroleundertestname';
|
||||
const testRoleDisplay = 'e2eroleundertestdisplay';
|
||||
const testRoleGroup = 'e2eroleundertestgroup';
|
||||
const testGrantName = 'e2egrantundertest';
|
||||
|
||||
var projectId: number;
|
||||
|
||||
beforeEach(() => {
|
||||
apiAuth().then((apiCalls) => {
|
||||
ensureProjectExists(apiCalls, testProjectName).then((projId) => {
|
||||
projectId = projId;
|
||||
apiAuth().as('api');
|
||||
});
|
||||
|
||||
describe('management', () => {
|
||||
const testManagerLoginname = loginname('e2ehumanmanager', Cypress.env('ORGANIZATION'));
|
||||
function testAuthorizations(
|
||||
roles: string[],
|
||||
beforeCreate: Mocha.HookFunction,
|
||||
beforeMutate: Mocha.HookFunction,
|
||||
navigate: Mocha.HookFunction,
|
||||
) {
|
||||
beforeEach(function () {
|
||||
ensureUserDoesntExist(this.api, testManagerLoginname);
|
||||
ensureHumanUserExists(this.api, testManagerLoginname);
|
||||
});
|
||||
|
||||
describe('create authorization', () => {
|
||||
beforeEach(beforeCreate);
|
||||
beforeEach(navigate);
|
||||
|
||||
it('should add a manager', () => {
|
||||
cy.get('[data-e2e="add-member-button"]').click();
|
||||
cy.get('[data-e2e="add-member-input"]').type(testManagerLoginname);
|
||||
cy.get('[data-e2e="user-option"]').click();
|
||||
cy.contains('[data-e2e="role-checkbox"]', roles[0]).click();
|
||||
cy.get('[data-e2e="confirm-add-member-button"]').click();
|
||||
cy.get('.data-e2e-success');
|
||||
cy.contains('[data-e2e="member-avatar"]', 'ee');
|
||||
cy.shouldNotExist({ selector: '.data-e2e-failure' });
|
||||
});
|
||||
});
|
||||
|
||||
describe('mutate authorization', () => {
|
||||
const rowSelector = `tr:contains(${testManagerLoginname})`;
|
||||
|
||||
beforeEach(beforeMutate);
|
||||
beforeEach(navigate);
|
||||
|
||||
beforeEach(() => {
|
||||
cy.contains('[data-e2e="member-avatar"]', 'ee').click();
|
||||
cy.get(rowSelector).as('managerRow');
|
||||
});
|
||||
|
||||
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();
|
||||
cy.get('.data-e2e-success');
|
||||
cy.shouldNotExist({ selector: rowSelector, timeout: 2000 });
|
||||
cy.shouldNotExist({ selector: '.data-e2e-failure' });
|
||||
});
|
||||
|
||||
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();
|
||||
cy.get('.data-e2e-success');
|
||||
cy.get('@managerRow')
|
||||
.find('[data-e2e="remove-role-button"]')
|
||||
.should('have.length', roles.length - 1);
|
||||
cy.shouldNotExist({ selector: '.data-e2e-failure' });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
describe('organizations', () => {
|
||||
const roles = [
|
||||
{ internal: 'ORG_OWNER', display: 'Org Owner' },
|
||||
{ internal: 'ORG_OWNER_VIEWER', display: 'Org Owner Viewer' },
|
||||
];
|
||||
|
||||
testAuthorizations(
|
||||
roles.map((role) => role.display),
|
||||
function () {
|
||||
ensureHumanIsNotOrgMember(this.api, testManagerLoginname);
|
||||
},
|
||||
function () {
|
||||
ensureHumanIsNotOrgMember(this.api, testManagerLoginname);
|
||||
ensureHumanIsOrgMember(
|
||||
this.api,
|
||||
testManagerLoginname,
|
||||
roles.map((role) => role.internal),
|
||||
);
|
||||
},
|
||||
() => {
|
||||
cy.visit('/orgs');
|
||||
cy.contains('tr', Cypress.env('ORGANIZATION')).click();
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
describe('projects', () => {
|
||||
describe('owned projects', () => {
|
||||
beforeEach(function () {
|
||||
ensureProjectExists(this.api, 'e2eprojectpermission').as('projectId');
|
||||
});
|
||||
|
||||
const visitOwnedProject: Mocha.HookFunction = function () {
|
||||
cy.visit(`/projects/${this.projectId}`);
|
||||
};
|
||||
|
||||
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),
|
||||
function () {
|
||||
ensureHumanIsNotProjectMember(this.api, this.projectId, testManagerLoginname);
|
||||
},
|
||||
function () {
|
||||
ensureHumanIsNotProjectMember(this.api, this.projectId, testManagerLoginname);
|
||||
ensureHumanIsProjectMember(
|
||||
this.api,
|
||||
this.projectId,
|
||||
testManagerLoginname,
|
||||
roles.map((role) => role.internal),
|
||||
);
|
||||
},
|
||||
visitOwnedProject,
|
||||
);
|
||||
});
|
||||
|
||||
describe('roles', () => {
|
||||
const testRoleName = 'e2eroleundertestname';
|
||||
|
||||
beforeEach(function () {
|
||||
ensureProjectResourceDoesntExist(this.api, this.projectId, Roles, testRoleName);
|
||||
});
|
||||
|
||||
beforeEach(visitOwnedProject);
|
||||
|
||||
it('should add a role', () => {
|
||||
cy.get('[data-e2e="sidenav-element-roles"]').click();
|
||||
cy.get('[data-e2e="add-new-role"]').click();
|
||||
cy.get('[formcontrolname="key"]').type(testRoleName);
|
||||
cy.get('[formcontrolname="displayName"]').type('e2eroleundertestdisplay');
|
||||
cy.get('[formcontrolname="group"]').type('e2eroleundertestgroup');
|
||||
cy.get('[data-e2e="save-button"]').click();
|
||||
cy.get('.data-e2e-success');
|
||||
cy.contains('tr', testRoleName);
|
||||
cy.shouldNotExist({ selector: '.data-e2e-failure' });
|
||||
});
|
||||
it('should remove a role');
|
||||
});
|
||||
});
|
||||
|
||||
describe('granted projects', () => {
|
||||
beforeEach(function () {
|
||||
ensureOrgExists(this.api, 'e2eforeignorg')
|
||||
.as('foreignOrgId')
|
||||
.then((foreignOrgId) => {
|
||||
ensureProjectExists(this.api, 'e2eprojectgrants', foreignOrgId)
|
||||
.as('projectId')
|
||||
.then((projectId) => {
|
||||
ensureProjectGrantExists(this.api, foreignOrgId, projectId).as('grantId');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
const visitGrantedProject: Mocha.HookFunction = function () {
|
||||
cy.visit(`/granted-projects/${this.projectId}/grant/${this.grantId}`);
|
||||
};
|
||||
|
||||
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),
|
||||
function () {
|
||||
ensureHumanIsNotProjectMember(this.api, this.projectId, testManagerLoginname, this.grantId);
|
||||
},
|
||||
function () {
|
||||
ensureHumanIsNotProjectMember(this.api, this.projectId, testManagerLoginname, this.grantId);
|
||||
ensureHumanIsProjectMember(
|
||||
this.api,
|
||||
this.projectId,
|
||||
testManagerLoginname,
|
||||
roles.map((role) => role.internal),
|
||||
this.grantId,
|
||||
);
|
||||
},
|
||||
visitGrantedProject,
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('add role', () => {
|
||||
beforeEach(() => {
|
||||
apiAuth().then((api) => {
|
||||
ensureProjectResourceDoesntExist(api, projectId, Roles, testRoleName);
|
||||
cy.visit(`/projects/${projectId}?id=roles`);
|
||||
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 ...');
|
||||
});
|
||||
});
|
||||
|
||||
it('should add a role', () => {
|
||||
cy.get('[data-e2e="add-new-role"]').click();
|
||||
cy.get('[formcontrolname="key"]').type(testRoleName);
|
||||
cy.get('[formcontrolname="displayName"]').type(testRoleDisplay);
|
||||
cy.get('[formcontrolname="group"]').type(testRoleGroup);
|
||||
cy.get('[data-e2e="save-button"]').click();
|
||||
cy.get('.data-e2e-success');
|
||||
cy.wait(200);
|
||||
cy.get('.data-e2e-failure', { timeout: 0 }).should('not.exist');
|
||||
describe('granted projects', () => {
|
||||
describe('no ownership', () => {
|
||||
it('a user without project grant ownership can ...');
|
||||
it('a user without project grant ownership can not ...');
|
||||
});
|
||||
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 ...');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
/*
|
||||
|
||||
describe('permissions', () => {
|
||||
|
||||
before(()=> {
|
||||
// cy.consolelogin(Cypress.env('username'), Cypress.env('password'), Cypress.config('baseUrl')/ui/console)
|
||||
})
|
||||
|
||||
it('should show projects ', () => {
|
||||
cy.visit(Cypress.config('baseUrl')/ui/console + '/projects')
|
||||
cy.url().should('contain', '/projects')
|
||||
})
|
||||
|
||||
it('should add a role', () => {
|
||||
cy.visit(Cypress.config('baseUrl')/ui/console + '/org').then(() => {
|
||||
cy.url().should('contain', '/org');
|
||||
})
|
||||
cy.visit(Cypress.config('baseUrl')/ui/console + '/projects').then(() => {
|
||||
cy.url().should('contain', '/projects');
|
||||
cy.get('.card').should('contain.text', "newProjectToTest")
|
||||
})
|
||||
cy.get('.card').filter(':contains("newProjectToTest")').click()
|
||||
cy.get('.app-container').filter(':contains("newAppToTest")').should('be.visible').click()
|
||||
let projectID
|
||||
cy.url().then(url => {
|
||||
cy.log(url.split('/')[4])
|
||||
projectID = url.split('/')[4]
|
||||
});
|
||||
|
||||
cy.then(() => cy.visit(Cypress.config('baseUrl')/ui/console + '/projects/' + projectID +'/roles/create'))
|
||||
cy.get('[formcontrolname^=key]').type("newdemorole")
|
||||
cy.get('[formcontrolname^=displayName]').type("newdemodisplayname")
|
||||
cy.get('[formcontrolname^=group]').type("newdemogroupname")
|
||||
cy.get('button').filter(':contains("Save")').should('be.visible').click()
|
||||
//let the Role get processed
|
||||
cy.wait(5000)
|
||||
})
|
||||
|
||||
it('should add a grant', () => {
|
||||
cy.visit(Cypress.config('baseUrl')/ui/console + '/org').then(() => {
|
||||
cy.url().should('contain', '/org');
|
||||
})
|
||||
cy.visit(Cypress.config('baseUrl')/ui/console + '/projects').then(() => {
|
||||
cy.url().should('contain', '/projects');
|
||||
cy.get('.card').should('contain.text', "newProjectToTest")
|
||||
})
|
||||
cy.get('.card').filter(':contains("newProjectToTest")').click()
|
||||
cy.get('.app-container').filter(':contains("newAppToTest")').should('be.visible').click()
|
||||
let projectID
|
||||
cy.url().then(url => {
|
||||
cy.log(url.split('/')[4])
|
||||
projectID = url.split('/')[4]
|
||||
});
|
||||
|
||||
cy.then(() => cy.visit(Cypress.config('baseUrl')/ui/console + '/grant-create/project/' + projectID ))
|
||||
cy.get('input').type("demo")
|
||||
cy.get('[role^=listbox]').filter(`:contains("${Cypress.env("fullUserName")}")`).should('be.visible').click()
|
||||
cy.wait(5000)
|
||||
//cy.get('.button').contains('Continue').click()
|
||||
cy.get('button').filter(':contains("Continue")').click()
|
||||
cy.wait(5000)
|
||||
cy.get('tr').filter(':contains("demo")').find('label').click()
|
||||
cy.get('button').filter(':contains("Save")').should('be.visible').click()
|
||||
//let the grant get processed
|
||||
cy.wait(5000)
|
||||
})
|
||||
})
|
||||
|
||||
*/
|
||||
|
||||
@@ -2,15 +2,16 @@ import { apiAuth } from '../../support/api/apiauth';
|
||||
import { ensureProjectDoesntExist, ensureProjectExists } from '../../support/api/projects';
|
||||
|
||||
describe('projects', () => {
|
||||
beforeEach(() => {
|
||||
apiAuth().as('api');
|
||||
});
|
||||
|
||||
const testProjectNameCreate = 'e2eprojectcreate';
|
||||
const testProjectNameDeleteList = 'e2eprojectdeletelist';
|
||||
const testProjectNameDeleteGrid = 'e2eprojectdeletegrid';
|
||||
const testProjectNameDelete = 'e2eprojectdelete';
|
||||
|
||||
describe('add project', () => {
|
||||
beforeEach(`ensure it doesn't exist already`, () => {
|
||||
apiAuth().then((api) => {
|
||||
ensureProjectDoesntExist(api, testProjectNameCreate);
|
||||
});
|
||||
beforeEach(`ensure it doesn't exist already`, function () {
|
||||
ensureProjectDoesntExist(this.api, testProjectNameCreate);
|
||||
cy.visit(`/projects`);
|
||||
});
|
||||
|
||||
@@ -19,52 +20,43 @@ describe('projects', () => {
|
||||
cy.get('input').type(testProjectNameCreate);
|
||||
cy.get('[data-e2e="continue-button"]').click();
|
||||
cy.get('.data-e2e-success');
|
||||
cy.wait(200);
|
||||
cy.get('.data-e2e-failure', { timeout: 0 }).should('not.exist');
|
||||
cy.shouldNotExist({ selector: '.data-e2e-failure' });
|
||||
});
|
||||
|
||||
it('should configure a project to assert roles on authentication');
|
||||
});
|
||||
|
||||
describe('remove project', () => {
|
||||
describe('list view', () => {
|
||||
beforeEach('ensure it exists', () => {
|
||||
apiAuth().then((api) => {
|
||||
ensureProjectExists(api, testProjectNameDeleteList);
|
||||
});
|
||||
cy.visit(`/projects`);
|
||||
});
|
||||
describe('edit project', () => {
|
||||
beforeEach('ensure it exists', function () {
|
||||
ensureProjectExists(this.api, testProjectNameDelete);
|
||||
cy.visit(`/projects`);
|
||||
});
|
||||
|
||||
it('removes the project', () => {
|
||||
describe('remove project', () => {
|
||||
it('removes the project from list view', () => {
|
||||
const rowSelector = `tr:contains(${testProjectNameDelete})`;
|
||||
cy.get('[data-e2e="toggle-grid"]').click();
|
||||
cy.get('[data-e2e="timestamp"]');
|
||||
cy.contains('tr', testProjectNameDeleteList, { timeout: 1000 })
|
||||
.find('[data-e2e="delete-project-button"]')
|
||||
.click({ force: true });
|
||||
cy.get('[data-e2e="confirm-dialog-input"]').focus().type(testProjectNameDeleteList);
|
||||
cy.get(rowSelector).find('[data-e2e="delete-project-button"]').click({ force: true });
|
||||
cy.get('[data-e2e="confirm-dialog-input"]').focus().type(testProjectNameDelete);
|
||||
cy.get('[data-e2e="confirm-dialog-button"]').click();
|
||||
cy.get('.data-e2e-success');
|
||||
cy.wait(200);
|
||||
cy.get('.data-e2e-failure', { timeout: 0 }).should('not.exist');
|
||||
cy.shouldNotExist({ selector: rowSelector, timeout: 2000 });
|
||||
cy.shouldNotExist({ selector: '.data-e2e-failure' });
|
||||
});
|
||||
|
||||
it('removes the project from grid view', () => {
|
||||
const cardSelector = `[data-e2e="grid-card"]:contains(${testProjectNameDelete})`;
|
||||
cy.get(cardSelector).find('[data-e2e="delete-project-button"]').click({ force: true });
|
||||
cy.get('[data-e2e="confirm-dialog-input"]').focus().type(testProjectNameDelete);
|
||||
cy.get('[data-e2e="confirm-dialog-button"]').click();
|
||||
cy.get('.data-e2e-success');
|
||||
cy.shouldNotExist({ selector: cardSelector, timeout: 2000 });
|
||||
cy.shouldNotExist({ selector: '.data-e2e-failure' });
|
||||
});
|
||||
});
|
||||
|
||||
describe('grid view', () => {
|
||||
beforeEach('ensure it exists', () => {
|
||||
apiAuth().then((api) => {
|
||||
ensureProjectExists(api, testProjectNameDeleteGrid);
|
||||
});
|
||||
cy.visit(`/projects`);
|
||||
});
|
||||
|
||||
it('removes the project', () => {
|
||||
cy.contains('[data-e2e="grid-card"]', testProjectNameDeleteGrid)
|
||||
.find('[data-e2e="delete-project-button"]')
|
||||
.click({ force: true });
|
||||
cy.get('[data-e2e="confirm-dialog-input"]').focus().type(testProjectNameDeleteGrid);
|
||||
cy.get('[data-e2e="confirm-dialog-button"]').click();
|
||||
cy.get('.data-e2e-success');
|
||||
cy.wait(200);
|
||||
cy.get('.data-e2e-failure', { timeout: 0 }).should('not.exist');
|
||||
});
|
||||
});
|
||||
it('should add a project manager');
|
||||
it('should remove a project manager');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -8,7 +8,7 @@ describe('oidc settings', () => {
|
||||
const refreshTokenExpirationPrecondition = 7;
|
||||
const refreshTokenIdleExpirationPrecondition = 2;
|
||||
|
||||
before(`ensure they are set`, () => {
|
||||
beforeEach(`ensure they are set`, () => {
|
||||
apiAuth().then((apiCallProperties) => {
|
||||
ensureOIDCSettingsSet(
|
||||
apiCallProperties,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { apiAuth, apiCallProperties } from '../../support/api/apiauth';
|
||||
import { apiAuth, API } from '../../support/api/apiauth';
|
||||
import { Policy, resetPolicy } from '../../support/api/policies';
|
||||
import { login, User } from '../../support/login/users';
|
||||
|
||||
@@ -7,7 +7,7 @@ describe('private labeling', () => {
|
||||
|
||||
[User.OrgOwner].forEach((user) => {
|
||||
describe(`as user "${user}"`, () => {
|
||||
let api: apiCallProperties;
|
||||
let api: API;
|
||||
|
||||
beforeEach(() => {
|
||||
login(user);
|
||||
|
||||
Reference in New Issue
Block a user