Skip to content

Commit

Permalink
Merge pull request #108 from bcgov/feat--ssoteam-1369-sso-plan-set-up
Browse files Browse the repository at this point in the history
Feat:  ssoteam-1369 sso plan set up
  • Loading branch information
rstens authored Mar 15, 2024
2 parents ad1935e + 3d0823b commit 5f61005
Show file tree
Hide file tree
Showing 20 changed files with 1,003 additions and 342 deletions.
23 changes: 22 additions & 1 deletion .github/workflows/main-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,31 @@ jobs:
spec: |
cypress/e2e/**/integration-990-deleteAllIntegrations.cy.ts
cypress/e2e/**/team-900-*.cy.ts
browser: electron
browser: chrome
# project: ./e2e
ci-build-id: ${{ github.event.number }}

- name: Run the reports
run: |
cd testing
npm run report
- name: Upload Test Reports
uses: actions/upload-artifact@v4
with:
name: pre-req-results
path: testing/mochawesome-report/report.html

- name: Rocket.Chat Notification
uses: RocketChat/Rocket.Chat.GitHub.Action.Notification@master
if: always() && github.ref == 'refs/heads/main'
with:
type: ${{ job.status }}
job_name: '*Pre-Reqs*'
mention_if: 'failure'
channel: '#sso-ops'
url: ${{ secrets.ROCKETCHAT_WEBHOOK }}

smoke-test:
runs-on: ubuntu-latest
strategy:
Expand Down
71 changes: 29 additions & 42 deletions testing/cypress/appActions/Request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class Request {
this.reqPage.startRequest();

// Tab 1: Requester Info
this.reqPage.setProjectName(this.projectName + '@' + this.getDate());
this.reqPage.setProjectName(this.projectName + '@' + util.getDate());
this.reqPage.setTeam(this.usesTeam);
if (this.usesTeam) {
if (this.newteam) {
Expand Down Expand Up @@ -368,7 +368,7 @@ class Request {

// Tab 1: Requester Info
if (this.projectName !== '') {
this.reqPage.setProjectName(this.projectName + '@' + this.getDate());
this.reqPage.setProjectName(this.projectName + '@' + util.getDate());
}
if (this.reqPage.usesTeam) {
this.reqPage.setTeam(this.usesTeam);
Expand Down Expand Up @@ -525,30 +525,10 @@ class Request {
// matching criteria
if (regex.test(t)) {
cy.get(this.reqPage.integrationsTable).eq(index).scrollIntoView();
cy.get(this.reqPage.integrationsTableStatus)
.eq(index)
.then(($status) => {
cy.log($status.text());

// Wait for the request to complete before deleting
while (!$status.text().includes('Completed')) {
cy.wait(10000);
cy.reload();
cy.get(this.reqPage.integrationsTableStatus)
.eq(index)
.then(($status) => {
cy.log($status.text());
});
}
if ($status.text().includes('Completed')) {
cy.get(this.reqPage.deleteButton).eq(index).click({ force: true });
cy.wait(3000);
this.reqPage.confirmDeleteIntegration(id);
cy.log('Delete Request: ' + id.toString());
} else {
cy.log('Request is not in Completed status. Cannot delete.');
}
});
cy.get(this.reqPage.deleteButton).eq(index).click({ force: true });
cy.wait(3000);
this.reqPage.confirmDeleteIntegration(id);
cy.log('Delete Request: ' + id.toString());
}
});
}
Expand Down Expand Up @@ -1123,13 +1103,18 @@ class Request {
cy.get('[data-testid="team-name"]')
.clear()
.type(this.teamName + '-' + myuuid);
cy.get(this.teamPage.userEmail)
.eq(0)
cy.get('#react-select-2-input').focus().clear();
cy.get('#react-select-2-input')
.type('pathfinder.ssotraining2@gov.bc.ca', {
force: true,
delay: util.getRandomInt(50, 500),
})
.trigger('input');
cy.contains('.select-inner__menu', 'pathfinder.ssotraining2@gov.bc.ca').click();
.trigger('select');
cy.wait(3000);
cy.realPress('Tab');
cy.realPress('Tab');
cy.wait(3000);

cy.get(this.teamPage.userRole).eq(0).select('Admin');
cy.get('[data-testid="send-invitation"]').click({ force: true });
});
Expand Down Expand Up @@ -1169,18 +1154,20 @@ class Request {
}
}

getDate(): string {
let today = new Date();
let dd: any = today.getDate();
let mm: any = today.getMonth() + 1; //January is 0!
let yyyy = today.getFullYear();
if (dd < 10) {
dd = '0' + dd;
}
if (mm < 10) {
mm = '0' + mm;
}
return yyyy + mm + dd;
getID(name: string) {
return cy
.log('Get ID: ' + name) // Start the command chain with a log.
.visit(this.reqPage.path) // Visit the page.
.contains('td', name, { timeout: 10000 })
.scrollIntoView() // Find the name and scroll into view.
.contains('td', name, { timeout: 10000 }) // Find the name again to ensure visibility.
.prev() // Get the previous element, presumably the ID.
.then(($id) => {
const idText = $id.text();
Cypress.env('integration_id', idText);
this.id = idText; // Set the ID on your class instance.
cy.log('Found ID: ' + idText); // Log the found ID.
});
}
}

Expand Down
6 changes: 5 additions & 1 deletion testing/cypress/appActions/Team.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ class Team {
if (n > 0) {
cy.get(this.teamPage.addUser, { timeout: 10000 }).first().click({ force: true });
}
cy.get(this.teamPage.userEmail, { timeout: 10000 }).eq(n).type(this.userEmail[n]);
cy.get(this.teamPage.userEmail, { timeout: 10000 }).eq(n).type(this.userEmail[n]).trigger('select');
cy.wait(3000);
cy.realPress('Tab');
cy.realPress('Tab');
cy.wait(3000);
cy.get(this.teamPage.userRole, { timeout: 10000 }).eq(n).select(this.userRole[n]);
n++;
}
Expand Down
18 changes: 18 additions & 0 deletions testing/cypress/appActions/Utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,23 @@ class Utilities {
md5(data: string): string {
return MD5(data).toString();
}
getDate(): string {
let today = new Date();
let dd: any = today.getDate();
let mm: any = today.getMonth() + 1; //January is 0!
let yyyy = today.getFullYear();
if (dd < 10) {
dd = '0' + dd;
}
if (mm < 10) {
mm = '0' + mm;
}
return yyyy + mm + dd;
}
getRandomInt(min, max) {
const minCeiled = Math.ceil(min);
const maxFloored = Math.floor(max);
return Math.floor(Math.random() * (maxFloored - minCeiled) + minCeiled); // The maximum is exclusive and the minimum is inclusive
}
}
export default Utilities;
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('Github BCGov integration', () => {
playground.fillInPlayground(
'https://dev.sandbox.loginproxy.gov.bc.ca/auth',
'standard',
kebabCase(githubBCGovIDP.create.projectname) + '-' + req.getDate() + '-' + Number(Cypress.env('test')),
kebabCase(githubBCGovIDP.create.projectname) + '-' + util.getDate() + '-' + Number(Cypress.env('test')),
);
playground.clickLogin();

Expand All @@ -48,7 +48,7 @@ describe('Github BCGov integration', () => {
playground.fillInPlayground(
'https://dev.sandbox.loginproxy.gov.bc.ca/auth',
'standard',
kebabCase(githubBCGovIDP.create.projectname) + '-' + req.getDate() + '-' + Number(Cypress.env('test')),
kebabCase(githubBCGovIDP.create.projectname) + '-' + util.getDate() + '-' + Number(Cypress.env('test')),
);
playground.clickLogin();

Expand Down Expand Up @@ -94,7 +94,7 @@ describe('Github public integration', () => {
playground.fillInPlayground(
'https://dev.sandbox.loginproxy.gov.bc.ca/auth',
'standard',
kebabCase(githubPublicIDP.create.projectname) + '-' + req.getDate() + '-' + Number(Cypress.env('test')),
kebabCase(githubPublicIDP.create.projectname) + '-' + util.getDate() + '-' + Number(Cypress.env('test')),
);
playground.clickLogin();

Expand Down
2 changes: 1 addition & 1 deletion testing/cypress/e2e/disabled-idpstopper-060-saml.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('Run IDP Stopper SAML Test', () => {
req.showCreateContent(data);
req.populateCreateContent(data);
req.createRequest();
Cypress.env('name', data.create.projectname + '@' + req.getDate());
Cypress.env('name', data.create.projectname + '@' + util.getDate());
cy.logout(null);
cy.clearAllSessionStorage();
});
Expand Down
2 changes: 1 addition & 1 deletion testing/cypress/e2e/idpstopper-010-test7-8.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('Run IDP Stopper Test', () => {
.type(
kebabCase(data.create.projectname) +
'-' +
req.getDate() +
util.getDate() +
'-' +
Number(Cypress.env(util.md5(data.create.projectname))) +
'{enter}',
Expand Down
2 changes: 1 addition & 1 deletion testing/cypress/e2e/idpstopper-020-test11.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('Run IDP Stopper Test', () => {
playground.setClientId(
kebabCase(data.create.projectname) +
'-' +
req.getDate() +
util.getDate() +
'-' +
Number(Cypress.env(util.md5(data.create.projectname))),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('Create Integration Requests For login page capitalization', () => {
.type(
kebabCase(request.projectname) +
'-' +
req.getDate() +
util.getDate() +
'-' +
Number(Cypress.env(util.md5(request.projectname))) +
'{enter}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ describe('Delete All Integrations', () => {
after(() => {
cy.cleanGC();
});

let req = new Request();
it('Delete All Requests as default user', function () {
cy.setid(null).then(() => {
cy.login(null, null, null, null);
});
let req = new Request();
req.deleteAllRequests();
cy.logout(null);
});
Expand Down
102 changes: 102 additions & 0 deletions testing/cypress/e2e/sso-020-sessions.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import data from '../fixtures/sso-test.json'; // The data file will drive the tests
import Playground from '../pageObjects/playgroundPage';
import Request from '../appActions/Request';
import Utilities from '../appActions/Utilities';
import cypress from 'cypress';
var kebabCase = require('lodash.kebabcase');
let util = new Utilities();
let req = new Request();

let testData = data;

describe('SSO Tests', () => {
beforeEach(() => {
//Establish the session with CSS Sandbox: IDIR
});

after(() => {
cy.cleanGC();
});

testData.forEach((data, index) => {
it('Find Integration IDs', function () {
cy.setid(null).then(() => {
cy.login(null, null, null, null);
});

req.getID(data.integration_1).then(() => {
Cypress.env('integration_1_id', req.id);
});
req.getID(data.integration_2).then(() => {
Cypress.env('integration_2_id', req.id);
});

cy.logout(null);
cy.clearAllSessionStorage();
});

it(`Test: "${data.id}": ${data.idp_hint_1}/ ${data.idp_hint_2}`, function () {
// In the playground set the IDP hint to bceidbasic and click login
// Different application, different client, different IDP
cy.clearAllSessionStorage();
cy.cleanGC();
let playground = new Playground();
cy.visit(playground.path);
playground.selectConfig();
playground.setAuthServerUrl();
playground.setRealm();
playground.setClientId(
kebabCase(data.integration_1) + '-' + util.getDate() + '-' + Number(Cypress.env('integration_1_id')),
);

playground.selectOptions();
playground.setIDPHint(data.idp_hint_1);

playground.selectConfig();
playground.clickUpdate();
playground.clickLogin();

// Log in
if (data.idp_hint_1 === 'idir') {
cy.setid(null).then(() => {
playground.loginIDIR(Cypress.env('username'), Cypress.env('password'));
});
} else if (data.idp_hint_1 === 'bceidbasic') {
cy.setid(data.idp_hint_1).then(() => {
playground.loginBasicBCeID(Cypress.env('username'), Cypress.env('password'));
});
}

// Second Login
cy.visit('http://localhost:3000');
playground.selectConfig();
playground.setAuthServerUrl();
playground.setRealm();
playground.setClientId(
kebabCase(data.integration_2) + '-' + util.getDate() + '-' + Number(Cypress.env('integration_2_id')),
);

/* playground.selectOptions();
playground.setIDPHint(data.idp_hint_2); */

playground.selectConfig();
playground.clickUpdate();
playground.clickLogin();

// Log in
if (data.idp_hint_2 === 'bceidbasic') {
cy.setid('bceidbasic').then(() => {
playground.loginBasicBCeID(Cypress.env('username'), Cypress.env('password'));
});
} else if (data.idp_hint_2 === 'idir') {
cy.setid(null).then(() => {
playground.loginIDIR(Cypress.env('username'), Cypress.env('password'));
});
}
cy.pause();
// This tells of a succesfull log in and that the session is attached to the user
cy.get('button', { timeout: 10000 }).contains('Logout').should('exist');
cy.get('button', { timeout: 10000 }).contains('Logout').click({ force: true });
});
});
});
27 changes: 27 additions & 0 deletions testing/cypress/e2e/teamtest.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Update of Integration request variants

import Request from '../appActions/Request';

describe('teamtest', () => {
before(() => {
cy.cleanGC();
});
/* after(() => {
cy.cleanGC();
}); */
beforeEach(() => {
cy.setid(null).then(() => {
cy.login(null, null, null, null);
});
});

/* afterEach(() => {
cy.logout(null);
}); */

// Remove Roles
it(`test`, () => {
cy.visit('');
cy.pause();
});
});
Loading

0 comments on commit 5f61005

Please sign in to comment.