diff --git a/.github/workflows/deploy-integ.yml b/.github/workflows/deploy-integ.yml
index 1f61d97c3f..ef2568a9c0 100644
--- a/.github/workflows/deploy-integ.yml
+++ b/.github/workflows/deploy-integ.yml
@@ -102,6 +102,8 @@ jobs:
CYPRESS_BASE_URL: ${{ secrets.CYPRESS_BASE_URL}}
CYPRESS_researcherEmail: ${{ secrets.CYPRESS_RESEARCHER_EMAIL}}
CYPRESS_researcherPassword: ${{ secrets.CYPRESS_RESEARCHER_PASSWORD}}
+ CYPRESS_adminEmail: ${{ secrets.CYPRESS_ADMIN_EMAIL}}
+ CYPRESS_adminPassword: ${{ secrets.CYPRESS_ADMIN_PASSWORD}}
merge-develop-to-mainline:
name: Merge develop to mainline
runs-on: ubuntu-18.04
diff --git a/addons/addon-base-raas-ui/packages/base-raas-ui/src/parts/users/User.js b/addons/addon-base-raas-ui/packages/base-raas-ui/src/parts/users/User.js
index eb82064dab..ca60601825 100644
--- a/addons/addon-base-raas-ui/packages/base-raas-ui/src/parts/users/User.js
+++ b/addons/addon-base-raas-ui/packages/base-raas-ui/src/parts/users/User.js
@@ -15,7 +15,7 @@
import React from 'react';
import { Tab, Segment, Container } from 'semantic-ui-react';
-import { observer } from 'mobx-react';
+import { inject, observer } from 'mobx-react';
import { withRouter } from 'react-router-dom';
import RolesList from './RolesList';
import UsersList from './UsersList';
@@ -28,14 +28,17 @@ const panes = [
// eslint-disable-next-line react/prefer-stateless-function
class User extends React.Component {
render() {
+ if (!this.props.userStore.cloneUser.isAdmin) {
+ this.props.history.push('/');
+ }
return (
-
+
);
}
}
-export default withRouter(observer(User));
+export default inject('userStore')(withRouter(observer(User)));
diff --git a/main/end-to-end-tests/README.md b/main/end-to-end-tests/README.md
index 58171a64f8..d9a156e597 100644
--- a/main/end-to-end-tests/README.md
+++ b/main/end-to-end-tests/README.md
@@ -11,6 +11,7 @@ In this section we will discuss how you can run these tests from your desktop.
To run the E2E tests, you will need the following items:
- A Service Workbench environment setup with Service Catalog
+- Username and password of an admin for the Service Workbench environment
- Username and password of a researcher for the Service Workbench environment
- A project set up for that researcher that can launch EC2 workspaces and Sagemaker workspaces
- A configured EC2 workspace
diff --git a/main/end-to-end-tests/cypress.json b/main/end-to-end-tests/cypress.json
index d3ab611916..c43229ccd0 100644
--- a/main/end-to-end-tests/cypress.json
+++ b/main/end-to-end-tests/cypress.json
@@ -6,6 +6,8 @@
"env": {
"researcherEmail": "",
"researcherPassword": "",
+ "adminEmail": "",
+ "adminPassword": "",
"isCognitoEnabled": false,
"workspaces": {
"sagemaker": {
diff --git a/main/end-to-end-tests/cypress/integration/login.spec.js b/main/end-to-end-tests/cypress/integration/login.spec.js
index d6a6cffbde..90430dbb59 100644
--- a/main/end-to-end-tests/cypress/integration/login.spec.js
+++ b/main/end-to-end-tests/cypress/integration/login.spec.js
@@ -14,6 +14,6 @@
*/
describe('Login', () => {
it('should login as researcher successfully', () => {
- cy.login();
+ cy.login('researcher');
});
});
diff --git a/main/end-to-end-tests/cypress/integration/page-routing.spec.js b/main/end-to-end-tests/cypress/integration/page-routing.spec.js
new file mode 100644
index 0000000000..4d8269b495
--- /dev/null
+++ b/main/end-to-end-tests/cypress/integration/page-routing.spec.js
@@ -0,0 +1,14 @@
+describe('page routing', () => {
+ describe('should navigate to /users page correctly', () => {
+ it('should redirect researchers trying to access /users page', () => {
+ cy.login('researcher');
+ cy.visit('/users');
+ cy.get("div[data-testid='page-title'] div").contains('Dashboard');
+ });
+ it('should allow admin to access /users page', () => {
+ cy.login('admin');
+ cy.visit('/users');
+ cy.get("div[data-testid='users-table']");
+ });
+ });
+});
diff --git a/main/end-to-end-tests/cypress/integration/workspaces.spec.js b/main/end-to-end-tests/cypress/integration/workspaces.spec.js
index ca383e753c..d35ccd1e6b 100644
--- a/main/end-to-end-tests/cypress/integration/workspaces.spec.js
+++ b/main/end-to-end-tests/cypress/integration/workspaces.spec.js
@@ -15,7 +15,7 @@
describe('Launch a new sagemaker workspace', () => {
before(() => {
- cy.login();
+ cy.login('researcher');
navigateToWorkspaces();
terminatePrexistingWorkspaces();
});
diff --git a/main/end-to-end-tests/cypress/support/commands.js b/main/end-to-end-tests/cypress/support/commands.js
index 358f594921..7a1b2f84eb 100644
--- a/main/end-to-end-tests/cypress/support/commands.js
+++ b/main/end-to-end-tests/cypress/support/commands.js
@@ -44,11 +44,19 @@
// TODO: If an environment is configured with an Identity Provider, the login steps needs to select an
// identity provider
-Cypress.Commands.add('login', () => {
- const loginInfo = {
- researcherEmail: Cypress.env('researcherEmail'),
- researcherPassword: Cypress.env('researcherPassword'),
- };
+Cypress.Commands.add('login', role => {
+ let loginInfo = {};
+ if (role === 'researcher') {
+ loginInfo = {
+ email: Cypress.env('researcherEmail'),
+ password: Cypress.env('researcherPassword'),
+ };
+ } else if (role === 'admin') {
+ loginInfo = {
+ email: Cypress.env('adminEmail'),
+ password: Cypress.env('adminPassword'),
+ };
+ }
const isCognitoEnabled = Cypress.env('isCognitoEnabled');
if (isCognitoEnabled) {
@@ -56,8 +64,8 @@ Cypress.Commands.add('login', () => {
} else {
cy.visit('/');
}
- cy.get("div[data-testid='username'] input").type(loginInfo.researcherEmail);
- cy.get("div[data-testid='password'] input").type(loginInfo.researcherPassword);
+ cy.get("div[data-testid='username'] input").type(loginInfo.email);
+ cy.get("div[data-testid='password'] input").type(loginInfo.password);
cy.get("button[data-testid='login']").click();
cy.get("div[data-testid='page-title'] div").contains('Dashboard');
});