Skip to content

Commit

Permalink
Merge branch 'main' into ssh-keys
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveDarsa committed Jul 4, 2024
2 parents f8627e1 + 1531166 commit 479c42a
Show file tree
Hide file tree
Showing 45 changed files with 1,207 additions and 682 deletions.
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Node builder image
FROM uselagoon/node-20-builder:latest as builder
FROM uselagoon/node-20-builder:latest AS builder

COPY . /app/

RUN yarn install
RUN yarn install --network-timeout 300000


# Node service image
Expand All @@ -28,4 +28,4 @@ ENV GRAPHQL_API=$GRAPHQL_API
RUN yarn run build

EXPOSE 3000
CMD ["yarn", "start"]
CMD ["yarn", "start"]
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ A couple of environment variables are required:
- user_owner - user with owner role
- user_orguser - Organization user
- user_orgviewer - Organization viewer
- user_orgadmin - Organization admin
- user_orgowner - Organization owner
- user_platformowner - Platform owner

Expand Down
2 changes: 2 additions & 0 deletions cypress/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { defineConfig } from 'cypress';

export default defineConfig({
requestTimeout: 15000,
defaultCommandTimeout: 8000,
e2e: {
env: {
api: 'http://0.0.0.0:33000/graphql',
Expand All @@ -15,6 +16,7 @@ export default defineConfig({
// orgs
user_orguser: 'orguser@example.com',
user_orgviewer: 'orgviewer@example.com',
user_orgadmin: 'orgadmin@example.com',
user_orgowner: 'orgowner@example.com',
// top level user for all default tests
user_platformowner: 'platformowner@example.com',
Expand Down
9 changes: 7 additions & 2 deletions cypress/e2e/organizations/manage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@ describe('Org Manage page', () => {
it('Adds a org viewer', () => {
manage.doAddOrgViewer(testData.organizations.manage.user);
});
it('Should upgrade org viewer to owner', () => {
manage.doEditOrgViewer(testData.organizations.manage.user);
it('Should upgrade org viewer to admin', () => {
manage.doEditOrgViewerToAdmin(testData.organizations.manage.user);
});

it('Should upgrade org admin to owner', () => {
manage.doEditOrgViewerToOwner(testData.organizations.manage.user);
});

it('Deletes user', () => {
manage.doDeleteUser(testData.organizations.manage.user);
});
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/organizations/overview.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('Organization overview page', () => {
overview.doQuotaFieldCheck();
});

it.only('Changes org friendly name/description', () => {
it('Changes org friendly name/description', () => {
registerIdleHandler('idle');

overview.changeOrgFriendlyname(testData.organizations.overview.friendlyName);
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/rbac/developer.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ describe('DEVELOPER permission test suites', () => {
environmentOverview.doDeleteEnvironmentError('main');
});

it('Deletes stating environment', () => {
it('Deletes staging environment', () => {
cy.visit(`${Cypress.env('url')}/projects/lagoon-demo/lagoon-demo-staging`);

cy.intercept('POST', Cypress.env('api'), req => {
Expand Down Expand Up @@ -147,7 +147,7 @@ describe('DEVELOPER permission test suites', () => {
});

it('Fails to cancel any deployment - no permission to CANCEL for DEVELOPER', () => {
cy.visit(`${Cypress.env('url')}/projects/lagoon-demo/lagoon-demo-staging/deployments`);
cy.visit(`${Cypress.env('url')}/projects/lagoon-demo/lagoon-demo-main/deployments`);

registerIdleHandler('idle');

Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/rbac/guest.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ describe('GUEST permission test suites', () => {
});

it('Fails to do cancel a deployment - no permission for GUEST', () => {
cy.visit(`${Cypress.env('url')}/projects/lagoon-demo/lagoon-demo-staging/deployments`);
cy.visit(`${Cypress.env('url')}/projects/lagoon-demo/lagoon-demo-main/deployments`);
registerIdleHandler('idle');

cy.intercept('POST', Cypress.env('api'), req => {
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/rbac/maintainer.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ describe('MAINTAINER permission test suites', () => {
environmentOverview.doDeleteEnvironmentError('main');
});

it('Deletes stating environment', () => {
it('Deletes staging environment', () => {
cy.visit(`${Cypress.env('url')}/projects/lagoon-demo/lagoon-demo-staging`);

cy.intercept('POST', Cypress.env('api'), req => {
Expand Down Expand Up @@ -169,7 +169,7 @@ describe('MAINTAINER permission test suites', () => {
});

it('Cancels a staging deployment', () => {
cy.visit(`${Cypress.env('url')}/projects/lagoon-demo/lagoon-demo-staging/deployments`);
cy.visit(`${Cypress.env('url')}/projects/lagoon-demo/lagoon-demo-main/deployments`);

registerIdleHandler('idle');

Expand Down
170 changes: 170 additions & 0 deletions cypress/e2e/rbac/organizations/orgAdmin.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
import { testData } from 'cypress/fixtures/variables';
import GroupAction from 'cypress/support/actions/organizations/GroupsAction';
import NotificationsAction from 'cypress/support/actions/organizations/NotificationsAction';
import OverviewAction from 'cypress/support/actions/organizations/OverviewAction';
import ProjectsActions from 'cypress/support/actions/organizations/ProjectsActions';
import { aliasMutation, aliasQuery, registerIdleHandler } from 'cypress/utils/aliasQuery';

const overview = new OverviewAction();
const group = new GroupAction();
const project = new ProjectsActions();
const notifications = new NotificationsAction();

const orgAdmin = [Cypress.env('user_orgadmin')];

orgAdmin.forEach(admin => {
const desc = {
[Cypress.env('user_orgadmin')]: 'Org admin',
};

describe(`Organizations ${desc[admin]} journey`, () => {
beforeEach(() => {
// register interceptors/idle handler
cy.intercept('POST', Cypress.env('api'), req => {
aliasQuery(req, 'getOrganization');
aliasMutation(req, 'updateOrganizationFriendlyName');
aliasMutation(req, 'addUserToGroup');
aliasMutation(req, 'addGroupToOrganization');
});

registerIdleHandler('idle');

cy.login(admin, admin);
cy.visit(`${Cypress.env('url')}/organizations/lagoon-demo-organization`);
});

if (admin === Cypress.env('user_orgadmin')) {
it('Fails to change org name and desc - no permission for ORGADMIN', () => {
overview.doFailedChangeOrgFriendlyname(testData.organizations.overview.friendlyName);
overview.closeModal();
overview.doFailedChangeOrgDescription(testData.organizations.overview.description);
overview.closeModal();
});
} else {
it('Changes org name and desc', () => {
overview.changeOrgFriendlyname(testData.organizations.overview.friendlyName);
overview.changeOrgDescription(testData.organizations.overview.description);
});
}

it('Navigates to groups and creates', () => {
cy.waitForNetworkIdle('@idle', 500);

const group1 = testData.organizations.groups.newGroupName;
const group2 = testData.organizations.groups.newGroupName2;

cy.get('.groups').click();
cy.location('pathname').should('equal', '/organizations/lagoon-demo-organization/groups');

group.doAddGroup(group1, group2);
registerIdleHandler('groupQuery');
group.doAddMemberToGroup(testData.organizations.users.email, group1);
});

it('Navigates to projects and creates a new one', () => {
registerIdleHandler('projectsQuery');
cy.intercept('POST', Cypress.env('api'), req => {
aliasMutation(req, 'addProjectToOrganization');
});

cy.waitForNetworkIdle('@idle', 500);

cy.get('.projects').click();
cy.location('pathname').should('equal', '/organizations/lagoon-demo-organization/projects');
cy.waitForNetworkIdle('@projectsQuery', 1000);

project.doAddProject(testData.organizations.project);
});

it('Navigates to notifications and creates a couple', () => {
cy.intercept('POST', Cypress.env('api'), req => {
aliasMutation(req, 'addNotificationSlack');
aliasMutation(req, 'UpdateNotificationSlack');
aliasMutation(req, 'addNotificationRocketChat');
aliasMutation(req, 'addNotificationMicrosoftTeams');
aliasMutation(req, 'addNotificationEmail');
aliasMutation(req, 'addNotificationWebhook');
});

registerIdleHandler('notificationsQuery');

cy.waitForNetworkIdle('@idle', 500);
cy.get('.notifications').click();
cy.location('pathname').should('equal', '/organizations/lagoon-demo-organization/notifications');
cy.waitForNetworkIdle('@notificationsQuery', 1000);

const { slack: slackData, email: emailData, webhook: webhookData } = testData.organizations.notifications;

notifications.doAddNotification('slack', slackData);
notifications.doAddNotification('email', emailData);
notifications.doAddNotification('webhook', webhookData);
});

it('Navigates to a project, adds a group and notifications', () => {
cy.visit(
`${Cypress.env('url')}/organizations/lagoon-demo-organization/projects/${
testData.organizations.project.projectName
}`
);

cy.getBySel('addGroupToProject').click();

cy.get('.react-select__indicator').click({ force: true });
cy.get('#react-select-2-option-0').click();

cy.getBySel('addGroupToProjectConfirm').click();

cy.log('add notifications');

cy.getBySel('addNotificationToProject').click();

cy.get('[class$=control]').click({ force: true });
cy.get('#react-select-3-option-0').click();

cy.getBySel('addNotificationToProjectConfirm').click();
});

// cleanup
after(() => {
registerIdleHandler('projectsQuery');
registerIdleHandler('groupQuery');
cy.intercept('POST', Cypress.env('api'), req => {
aliasMutation(req, 'removeNotification');
aliasMutation(req, 'deleteGroup');
aliasMutation(req, 'deleteProject');
});

cy.waitForNetworkIdle('@idle', 500);
cy.get('.groups').click();

group.doDeleteGroup(testData.organizations.groups.newGroupName);
cy.wait('@gqldeleteGroupMutation');

group.doDeleteGroup(testData.organizations.groups.newGroupName2);
cy.wait('@gqldeleteGroupMutation');

cy.waitForNetworkIdle('@idle', 500);
cy.get('.projects').click();

cy.waitForNetworkIdle('@projectsQuery', 1000);

project.doDeleteProject(testData.organizations.project.projectName);

cy.get('.notifications').click();

cy.waitForNetworkIdle('@idle', 500);

const {
webhook: { name: webhooknName },
email: { name: emailName },
slack: { name: slackName },
} = testData.organizations.notifications;

notifications.doDeleteNotification(webhooknName);
cy.wait('@gqlremoveNotificationMutation'); // wait for a delete mutation instead
notifications.doDeleteNotification(emailName);
cy.wait('@gqlremoveNotificationMutation');
notifications.doDeleteNotification(slackName);
});
});
});
4 changes: 3 additions & 1 deletion cypress/e2e/rbac/reporter.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ describe('REPORTER permission test suites', () => {
});

it('Fails to do cancel a deployment - no permission for REPORTER', () => {
cy.visit(`${Cypress.env('url')}/projects/lagoon-demo/lagoon-demo-staging/deployments`);
cy.visit(`${Cypress.env('url')}/projects/lagoon-demo/lagoon-demo-main/deployments`);

registerIdleHandler('idle');

Expand All @@ -168,6 +168,8 @@ describe('REPORTER permission test suites', () => {
cy.waitForNetworkIdle('@idle', 500);

deployment.navigateToRunningDeployment();

cy.waitForNetworkIdle('@idle', 500);
deployment.doFailedCancelDeployment();
});
});
Expand Down
20 changes: 18 additions & 2 deletions cypress/support/actions/organizations/ManageAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,26 @@ export default class ManageAction {
});
}

doEditOrgViewer(user: string) {
doEditOrgViewerToAdmin(user: string) {
manageRepo.getUserRows().contains(user).parents('.tableRow').find('.link').click();

manageRepo.getUserIsOwnerCheckbox().check();
// admin
manageRepo.getUserRoleDropdown().click({ force: true });
manageRepo.getUserAdminRoleOption().click();

manageRepo.getUpdateBtn().click();

cy.wait('@gqlAddUserToOrganizationMutation');

manageRepo.getUserRows().contains(user).parents('.tableRow').find(':contains("ORG ADMIN")').should('exist');
}

doEditOrgViewerToOwner(user: string) {
manageRepo.getUserRows().contains(user).parents('.tableRow').find('.link').click();

// owner
manageRepo.getUserRoleDropdown().click({ force: true });
manageRepo.getUserOwnerRoleOption().click();

manageRepo.getUpdateBtn().click();

Expand Down
9 changes: 5 additions & 4 deletions cypress/support/actions/organizations/OverviewAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ export default class OverviewAction {

changeOrgFriendlyname(friendlyName: string) {
overviewRepo.getNameEditButton('edit-name').click();
overviewRepo.getEditField().type(friendlyName);

overviewRepo.getEditField().clear().type(friendlyName);
overviewRepo.getSubmitButton().click();

cy.wait('@gqlupdateOrganizationFriendlyNameMutation');
Expand All @@ -53,7 +54,7 @@ export default class OverviewAction {
}
doFailedChangeOrgFriendlyname(friendlyName: string) {
overviewRepo.getNameEditButton('edit-name').click();
overviewRepo.getEditField().type(friendlyName);
overviewRepo.getEditField().clear().type(friendlyName);
overviewRepo.getSubmitButton().click();

cy.wait('@gqlupdateOrganizationFriendlyNameMutation').then(interception => {
Expand All @@ -68,7 +69,7 @@ export default class OverviewAction {

changeOrgDescription(description: string) {
overviewRepo.getDescEditButton('edit-description').click();
overviewRepo.getEditField().type(description);
overviewRepo.getEditField().clear().type(description);
overviewRepo.getSubmitButton().click();

cy.wait('@gqlupdateOrganizationFriendlyNameMutation');
Expand All @@ -85,7 +86,7 @@ export default class OverviewAction {
}
doFailedChangeOrgDescription(description: string) {
overviewRepo.getDescEditButton('edit-description').click();
overviewRepo.getEditField().type(description);
overviewRepo.getEditField().clear().type(description);
overviewRepo.getSubmitButton().click();

cy.wait('@gqlupdateOrganizationFriendlyNameMutation').then(interception => {
Expand Down
Loading

0 comments on commit 479c42a

Please sign in to comment.