Skip to content

Commit

Permalink
Merge pull request #1582 from NationalSecurityAgency/t#1551/ui_max_pr…
Browse files Browse the repository at this point in the history
…oj_for_root_user

#1551: allow root user to create unlimited number of projects
  • Loading branch information
dwalizer authored Aug 19, 2022
2 parents 8ed66d4 + f93cf82 commit fca9e42
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 20 deletions.
2 changes: 1 addition & 1 deletion dashboard/src/components/projects/MyProjects.vue
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ limitations under the License.
},
computed: {
addProjectDisabled() {
return this.projects && this.$store.getters.config && this.projects.length >= this.$store.getters.config.maxProjectsPerAdmin;
return this.projects && this.$store.getters.config && this.projects.length >= this.$store.getters.config.maxProjectsPerAdmin && !this.$store.getters['access/isRoot'];
},
addProjectsDisabledMsg() {
if (this.$store.getters.config) {
Expand Down
17 changes: 0 additions & 17 deletions e2e-tests/cypress/e2e/copy_project_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,21 +224,4 @@ describe('Copy Project Tests', () => {
.should('have.focus');
});

it('projects table validation: user cannot create more than configured max projects', () => {
for (let i = 2; i <= 25; i += 1) {
cy.createProject(i);
}
cy.visit('/administrator/');
cy.get('[data-cy="addProjectDisabled"]')
.contains('Cannot create or copy projects - The maximum number of Projects allowed is 25');
cy.get('[data-cy="newProjectButton"]')
.should('be.disabled');
cy.get('[data-cy="copyProjectIdproj25"]')
.should('be.disabled');
cy.get('[data-cy="copyProjectIdproj24"]')
.should('be.disabled');
cy.get('[data-cy="copyProjectIdproj23"]')
.should('be.disabled');
});

});
61 changes: 59 additions & 2 deletions e2e-tests/cypress/e2e/projects_table_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ dayjs.extend(utcPlugin);

describe('Projects Table Tests', () => {
const tableSelector = '[data-cy=projectsTable]';

const numProjCreated = 10;
beforeEach(() => {
cy.intercept('GET', '/app/projects')
.as('getProjects');
Expand All @@ -31,7 +31,7 @@ describe('Projects Table Tests', () => {
cy.intercept('/admin/projects/proj1/users/[email protected]/roles')
.as('getRolesForRoot');

for (let i = 1; i <= 10; i += 1) {
for (let i = 1; i <= numProjCreated; i += 1) {
cy.createProject(i);
}
});
Expand Down Expand Up @@ -591,5 +591,62 @@ describe('Projects Table Tests', () => {
.should('have.focus');
});

const maxNumProjects = 25;
it('projects table validation: user cannot create more than configured max projects', () => {
for (let i = numProjCreated + 1; i <= maxNumProjects; i += 1) {
cy.createProject(i);
}
cy.visit('/administrator/');
cy.get('[data-cy="addProjectDisabled"]')
.contains('Cannot create or copy projects - The maximum number of Projects allowed is 25');
cy.get('[data-cy="newProjectButton"]')
.should('be.disabled');
cy.get('[data-cy="copyProjectIdproj25"]')
.should('be.disabled');
cy.get('[data-cy="copyProjectIdproj24"]')
.should('be.disabled');
cy.get('[data-cy="copyProjectIdproj23"]')
.should('be.disabled');
});

it('root user can create unlimited number of projects', () => {
cy.logout();
cy.fixture('vars.json')
.then((vars) => {
cy.login(vars.rootUser, vars.defaultPass);
});
for (let i = numProjCreated + 1; i <= maxNumProjects; i += 1) {
cy.createProject(i);
}
for (let i = 1; i <= maxNumProjects; i += 1) {
cy.request('POST', `/root/pin/proj${i}`, {});
}
cy.visit('/administrator/');
cy.get('[data-cy="copyProjectIdproj25"]')
cy.get('[data-cy="addProjectDisabled"]').should('not.exist')
cy.get('[data-cy="newProjectButton"]').should('be.enabled');
cy.get('[data-cy="copyProjectIdproj25"]')
.should('be.enabled');
cy.get('[data-cy="copyProjectIdproj24"]')
.should('be.enabled');
cy.get('[data-cy="copyProjectIdproj23"]')
.should('be.enabled');

// save new project as root
cy.get('[data-cy="newProjectButton"]').click()
cy.get('[data-cy="projectName"]')
.type('NewProj');
cy.get('[data-cy="saveProjectButton"]').click();
cy.get('[data-cy="manageProjLink_NewProj"]')

// copy project as root
cy.get('[data-cy="copyProjectIdproj25"]').click();
cy.get('[data-cy="projectName"]')
.type('Copy Proj');
cy.get('[data-cy="saveProjectButton"]').click();
cy.get('[data-cy="allDoneBtn"]').click();
cy.get('[data-cy="manageProjLink_CopyProj"]')
});

});

0 comments on commit fca9e42

Please sign in to comment.