Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.2 into perftest #421

Closed
wants to merge 52 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
e4e3f46
Adding support for multiple affinity cookies (#331)
nikola-naydenov-hmcts Mar 12, 2020
10c55e5
SIDM-2686 - Cross browser tests (#333)
henrydobson Mar 12, 2020
a8d7a0c
Welsh language (#334)
Mar 25, 2020
9373d04
Add locale passing interceptor.
Mar 27, 2020
39b5079
Inject LocalePassingInterceptor to the global REST Template.
Mar 17, 2020
38efe85
Ignore other local profiles.
Mar 27, 2020
7de33c7
Extend the locale cookie expiration.
Mar 27, 2020
985683d
Increase the cookie expiration to 10 years.
Mar 27, 2020
3a0d814
Merge branch 'preview' into SIDM-3932_idm_notifications
Mar 27, 2020
4c8a13e
Cleanup debug code.
Mar 30, 2020
57b3729
Don't overwrite the language header set in another thread in the inte…
Mar 30, 2020
e26b392
SIDM-3353 Create password - add additional guidance text. (#337)
dfourn Mar 31, 2020
07819f6
Improve test coverage. (#347)
Apr 1, 2020
f447d72
More test coverage for Welsh. (#348)
Apr 1, 2020
9ffe97d
SIDM-3977 Add test to check if activation link can be used after the …
dfourn Apr 6, 2020
a8c0c04
COVID-19 Contact Us pages changes (post Welsh) (#350)
Apr 9, 2020
572105a
Sidm 3831 externalise text (#342)
Apr 9, 2020
e4ee728
SIDM-3831 Fix Welsh translations. (#355)
Apr 15, 2020
b8aca08
SIDM-3582 SIDM-3404 Account Activation link expired screen (#354)
dfourn Apr 15, 2020
147db73
Welsh - fix AKS languages (#357)
Apr 16, 2020
15bb408
Sidm 4015 welsh functional tests (#352)
Apr 21, 2020
2767c79
Merge demo to preview after merging master to demo (#365)
Apr 29, 2020
7ca98bb
add login with pin test (#361)
shravanmechineni Apr 30, 2020
179fc13
Fix CVE-2020-9488 vulnerability. (#367)
May 13, 2020
3ada921
Make /activate POST request redirect to a GET endpoint that can have …
May 15, 2020
fdf66bc
Sidm 4120 welsh post requests (#368)
May 18, 2020
e55dffb
Sidm 4120 welsh post requests (#370)
May 18, 2020
e44e3bc
V2 1 intermediary master bfg (#374)
henrydobson Jun 8, 2020
792d59d
Increase test code coverage. (#377)
Jun 9, 2020
c2894a9
fix: remove reference to idam-master tf state (#378)
Jun 9, 2020
6c88dca
Sonar failure fix attempt. (#381)
Jun 9, 2020
7498843
V2 1 rc2 master into preview (#386)
tbamido Jun 10, 2020
f048f30
Bump java version to 11. (#360)
Jun 12, 2020
9a967c9
Set default response to HTML (#396)
nikola-naydenov-hmcts Jun 19, 2020
9c936e0
Extend media type list
Jun 19, 2020
21420ba
SIDM 4211 (#391)
jitumiah Jun 25, 2020
b8c2949
upgrade bom to 2.2.4 (#398)
dfourn Jun 26, 2020
e0a6643
SIDM-4347 - Deprecate App Service Site (#400)
henrydobson Jun 29, 2020
c0c9205
Sidm4235 azure redis cache (#402)
Jul 2, 2020
fcfac0f
added reset password page after stale user tries logging in (#401)
jitumiah Jul 3, 2020
57ec6eb
improved unit testing for stale user login (#403)
jitumiah Jul 3, 2020
aa1aa54
Vulnerability fixes
Jul 6, 2020
a5d7df0
Sidm4403 disable session affinity cookie (#406)
Jul 7, 2020
02ed6b2
fixed issue when redirecting we lose some variables. also fixed issue…
jitumiah Jul 8, 2020
5161789
possible quality gate fix (#408)
jitumiah Jul 8, 2020
ad23099
optional request params (#411)
jitumiah Jul 9, 2020
5bb8cc1
changed text within try again link (#413)
jitumiah Jul 10, 2020
9265ac9
feat(redis): make sandbox redis public for local dev (#410)
Jul 10, 2020
7efc706
redirect user on activation to reset password success if user is a st…
jitumiah Jul 13, 2020
2ccb748
SIDM-4092 FR AuthTrees (#390)
Jul 14, 2020
a0e1c59
Stale user tests (#404)
shravanmechineni Jul 14, 2020
e39bd33
chore(redis): remove redis tf code for 2.2 release (#420)
Jul 20, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions Jenkinsfile_nightly
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ properties([
])
])

@Library("Infrastructure")
@Library("Infrastructure") _

def type = "java"

@@ -36,18 +36,25 @@ static LinkedHashMap<String, Object> secret(String secretName, String envVar) {
}

withNightlyPipeline(type, product, component) {

env.TEST_URL = params.URL_TO_TEST

env.IDAMAPI = params.API_URL_TO_TEST

loadVaultSecrets(secrets)

enableSecurityScan()

enableMutationTest()

enableFullFunctionalTest(200)
enableCrossBrowserTest()

after('crossBrowserTest') {
try {
withSauceConnect("reform_tunnel") {
sh "./gradlew functionalSauce"
steps.archiveArtifacts allowEmptyArchive: true, artifacts: 'functional-output/**/*'
}
}
finally {
steps.saucePublisher()
}
}

after('fullFunctionalTest') {

21 changes: 20 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -153,6 +153,26 @@ allprojects {
commandLine 'node_modules/codeceptjs/bin/codecept.js', 'run', '--grep', '@functional', '--verbose', '--reporter', 'mocha-multi'
}

task smokeSauce(dependsOn: ':codeceptSmokeSauce') {
group = 'Delivery pipeline'
description = 'Executes non-destructive smoke tests against a running instance'
}

task codeceptSmokeSauce(type: Exec, dependsOn: ':yarnInstall') {
workingDir '.'
commandLine 'node_modules/codeceptjs/bin/codecept.js', 'run', '--config', 'saucelabs.conf.js','--steps', '--grep', '@smoke', '--verbose', '--debug', '--reporter', 'mochawesome'
}

task functionalSauce(dependsOn: ':codeceptFunctionalSauce') {
group = 'Delivery pipeline'
description = 'Executes non-destructive smoke tests against a running instance'
}

task codeceptFunctionalSauce(type: Exec, dependsOn: [':yarnInstall', ':notifyClientInstall']) {
workingDir '.'
commandLine 'node_modules/codeceptjs/bin/codecept.js', 'run-multiple', '--all', '--config', 'saucelabs.conf.js', '--grep', '@crossbrowser', '--verbose', '--debug', '--reporter', 'mochawesome'
}

task pa11y(type: Exec, dependsOn: 'pa11yInstall') {
workingDir '.'
commandLine './node_modules/.bin/pa11y', '--config', 'pa11y.conf.js', System.getenv('TEST_URL')
@@ -215,4 +235,3 @@ test.finalizedBy jacocoTestReport
bootRun {
systemProperties = System.properties
}

2 changes: 0 additions & 2 deletions functional-output/zapreports

This file was deleted.

9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -11,7 +11,6 @@
"codeceptjs": "^1.2.0",
"codeceptjs-resemblehelper": "^1.9.0",
"deep-equal-in-any-order": "^1.0.13",
"electron": "^2.0.8",
"mocha-junit-reporter": "^1.17.0",
"mocha-multi": "^1.0.1",
"mochawesome": "^3.0.2",
@@ -20,6 +19,12 @@
"pa11y": "^4.13.2",
"proxy-agent": "^3.0.1",
"puppeteer": "^2.0.0",
"node-fetch": "^2.6.0"
"node-fetch": "^2.6.0",
"wdio-sauce-service": "^0.4.4",
"webdriverio": "^4.14.2"
},
"scripts": {
"test-crossbrowser-e2e": "NODE_PATH=. codeceptjs run-multiple --all -c saucelabs.conf.js --steps --grep '@crossbrowser' --reporter mochawesome",
"test:crossbrowser": "runSauceLabsTests.sh"
}
}
63 changes: 63 additions & 0 deletions saucelabs.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
const supportedBrowsers = require('./src/test/js/config/supportedBrowsers.js');
const browser = process.env.SAUCE_BROWSER || 'chrome';
const tunnelName = process.env.TUNNEL_IDENTIFIER || 'reformtunnel';

const waitForTimeout = 60000;
const smartWait = 5000;

const getBrowserConfig = browserGroup => {
const browserConfig = [];
for (const candidateBrowser in supportedBrowsers[browserGroup]) {
if (candidateBrowser) {
const desiredCapability = supportedBrowsers[browserGroup][candidateBrowser];
desiredCapability.acceptSslCerts = true;
desiredCapability.tunnelIdentifier = tunnelName;
desiredCapability.tags = ['idam-web-public'];
browserConfig.push({
browser: desiredCapability.browserName,
desiredCapabilities: desiredCapability
});
} else {
console.error('ERROR: supportedBrowsers.js is empty or incorrectly defined');
}
}
return browserConfig;
};

const setupConfig = {
tests: './src/test/js/cross_browser_test.js',
output: `${process.cwd()}/functional-output`,
helpers: {
WebDriverIO: {
url: process.env.TEST_URL,
browser : 'chrome',
waitForTimeout,
smartWait,
cssSelectorsEnabled: 'true',
host: 'ondemand.eu-central-1.saucelabs.com',
port: 80,
region: 'eu',
sauceConnect: true,
services: ['sauce'],
acceptSslCerts : true,
user: process.env.SAUCE_USERNAME,
key: process.env.SAUCE_ACCESS_KEY,
desiredCapabilities: { }
},
SauceLabsReportingHelper: { require: './src/test/js/shared/sauceLabsReportingHelper.js' },
idam_helper: { require: './src/test/js/shared/idam_helper.js' }
},
include: { I: './src/test/js/shared/custom_steps.js' },

multiple: {
chrome: {
browsers: getBrowserConfig('chrome')
},
firefox: {
browsers: getBrowserConfig('firefox')
}
},
name: 'Idam web public'
};

exports.config = setupConfig;
30 changes: 30 additions & 0 deletions src/test/js/config/runUITestsSauceLabs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
supportedBrowsers=`sed '/\/\//d' ./supportedBrowsers.js | sed '/\/\//d' | sed "s/[\'\:\{ ]//g"`
browsersArray=(${supportedBrowsers//$'\n'/ })

outputDirectory="${E2E_CROSSBROWSER_OUTPUT_DIR:-functional-output/crossbrowser/reports}"

echo
echo "*****************************************"
echo "* The following browsers will be tested *"
echo "*****************************************"
echo "$supportedBrowsers"
echo "****************************************"
echo
echo

for i in "${browsersArray[@]}"
do
echo "*** Testing $i ***"

FOLDERNAME="$i-$(date +%s)"

mkdir ../../../../output/$FOLDERNAME

SAUCELABS_BROWSER=$i TUNNEL_IDENTIFIER=reformtunnel npm run test-crossbrowser-e2e

for f in ../../../../output/*.*; do
echo $f
mv $f ../../../../output/$FOLDERNAME
done
done
32 changes: 32 additions & 0 deletions src/test/js/config/supportedBrowsers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const supportedBrowsers = {
chrome: {
chrome_win_latest: {
browserName: 'chrome',
name: 'DIV_WIN_CHROME_LATEST',
platform: 'Windows 10',
version: 'latest'
},
chrome_mac_latest: {
browserName: 'chrome',
name: 'MAC_CHROME_LATEST',
platform: 'macOS 10.13',
version: 'latest'
}
},
firefox: {
firefox_win_latest: {
browserName: 'firefox',
name: 'WIN_FIREFOX_LATEST',
platform: 'Windows 10',
version: 'latest'
},
firefox_mac_latest: {
browserName: 'firefox',
name: 'MAC_FIREFOX_LATEST',
platform: 'macOS 10.13',
version: 'latest'
}
}
};

module.exports = supportedBrowsers;
2 changes: 1 addition & 1 deletion src/test/js/config/test_data.js
Original file line number Diff line number Diff line change
@@ -6,6 +6,6 @@ module.exports = {
NOTIFY_API_KEY: process.env.NOTIFY_API_KEY,
SCENARIO_RETRY_LIMIT: 3,
PASSWORD: "Passw0rdIDAM",
SERVICE_REDIRECT_URI: 'https://idam.testservice.gov.uk',
SERVICE_REDIRECT_URI: 'http://idam.testservice.gov.uk',
SERVICE_CLIENT_SECRET: 'autotestingservice',
};
119 changes: 119 additions & 0 deletions src/test/js/cross_browser_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
const chai = require('chai');
const {expect} = chai;
const TestData = require('./config/test_data');
const randomData = require('./shared/random_data');

Feature('Users can sign in');

let randomUserFirstName;
let citizenEmail;
let userFirstNames = [];
let roleNames = [];
let serviceNames = [];
let randomUserLastName;
let existingCitizenEmail;
let pinUserFirstName;
let pinUserLastName;
let pinaccessToken;

const serviceName = randomData.getRandomServiceName();

const selfRegUrl = `${TestData.WEB_PUBLIC_URL}/users/selfRegister?redirect_uri=${TestData.SERVICE_REDIRECT_URI}&client_id=${serviceName}`;

BeforeSuite(async (I) => {
randomUserFirstName = randomData.getRandomUserName();
const adminEmail = 'admin.' + randomData.getRandomEmailAddress();
citizenEmail = 'citizen.' + randomData.getRandomEmailAddress();
existingCitizenEmail = 'existingcitizen.' + randomData.getRandomEmailAddress();
pinUserLastName = randomData.getRandomUserName() + 'pinępinç';
pinUserFirstName = randomData.getRandomUserName() + 'ępinçłpin';

let token = await I.getAuthToken();
let response;
response = await I.createRole(randomData.getRandomRoleName() + "_beta", 'beta description', '', token);
const serviceBetaRole = response.name;
response = await I.createRole(randomData.getRandomRoleName() + "_admin", 'admin description', serviceBetaRole, token);
const serviceAdminRole = response.name;
response = await I.createRole(randomData.getRandomRoleName() + "_super", 'super description', serviceAdminRole, token);
const serviceSuperRole = response.name;
const serviceRoles = [serviceBetaRole, serviceAdminRole, serviceSuperRole];
roleNames.push(serviceRoles);
await I.createServiceWithRoles(serviceName, serviceRoles, serviceBetaRole, token);
serviceNames.push(serviceName);
await I.createUserWithRoles(adminEmail, randomUserFirstName + 'Admin', [serviceAdminRole, "IDAM_ADMIN_USER"]);
userFirstNames.push(randomUserFirstName + 'Admin');
await I.createUserWithRoles(citizenEmail, randomUserFirstName + 'Citizen', ["citizen"]);
userFirstNames.push(randomUserFirstName + 'Citizen');
randomUserLastName = randomData.getRandomUserName();
await I.createUserWithRoles(citizenEmail, randomUserFirstName, ["citizen"]);
userFirstNames.push(randomUserFirstName);
await I.createUserWithRoles(existingCitizenEmail, randomUserFirstName + 'Citizen', ["citizen"]);
userFirstNames.push(randomUserFirstName + 'Citizen');

const pinUser = await I.getPinUser(pinUserFirstName, pinUserLastName);
const code = await I.loginAsPin(pinUser.pin, serviceName, TestData.SERVICE_REDIRECT_URI);
pinaccessToken = await I.getAccessToken(code, serviceName, TestData.SERVICE_REDIRECT_URI, TestData.SERVICE_CLIENT_SECRET);
});

AfterSuite(async (I) => {
return I.deleteAllTestData(randomData.TEST_BASE_PREFIX)
});

Scenario('@functional @crossbrowser Idam Web public cross browser tests', async (I) => {

const email = 'test_citizen.' + randomData.getRandomEmailAddress();
citizenEmail = 'citizen.' + randomData.getRandomEmailAddress();

const loginPage = `${TestData.WEB_PUBLIC_URL}/login?redirect_uri=${TestData.SERVICE_REDIRECT_URI}&client_id=${serviceName}&state=selfreg`;
I.amOnPage(selfRegUrl);
I.waitInUrl('users/selfRegister', 180);
I.waitForText('Create an account or sign in', 20, 'h1');
I.see('Create an account');
I.fillField('firstName', randomUserFirstName);
I.fillField('lastName', randomUserLastName);
I.fillField('email', citizenEmail);
I.click("Continue");
I.waitForText('Check your email', 20, 'h1');
I.wait(5);
const userActivationUrl = await I.extractUrl(citizenEmail);
I.amOnPage(userActivationUrl);
I.waitForText('Create a password', 20, 'h1');
I.seeTitleEquals('User Activation - HMCTS Access');
I.fillField('#password1', TestData.PASSWORD);
I.fillField('#password2', TestData.PASSWORD);
I.click('Continue');
I.waitForText('Account created', 20, 'h1');
I.see('You can now sign in to your account.');
I.wait(5);
I.lockAccount(citizenEmail, serviceName);
I.click('reset your password');
I.waitForText('Reset your password', 20, 'h1');
I.fillField('#email', citizenEmail);
I.click('Submit');
I.waitForText('Check your email', 20, 'h1');
I.wait(5);
const resetPasswordUrl = await I.extractUrl(citizenEmail);
I.amOnPage(resetPasswordUrl);
I.waitForText('Create a new password', 20, 'h1');
I.seeTitleEquals('Reset Password - HMCTS Access');
I.fillField('#password1', 'Passw0rd1234');
I.fillField('#password2', 'Passw0rd1234');
I.click('Continue');
I.waitForText('Your password has been changed', 20, 'h1');
I.see('You can now sign in with your new password.');

const userInfo = await I.retry({retries: 3, minTimeout: 10000}).getUserByEmail(citizenEmail);
expect(userInfo.active).to.equal(true);
expect(userInfo.email).to.equal(citizenEmail);
expect(userInfo.forename).to.equal(randomUserFirstName);
expect(userInfo.id).to.not.equal(null);
expect(userInfo.roles).to.eql(['citizen']);

I.amOnPage(`${TestData.WEB_PUBLIC_URL}/login/uplift?client_id=${serviceName}&redirect_uri=${TestData.SERVICE_REDIRECT_URI}&jwt=${pinaccessToken}`);
I.waitForText('Sign in to your account.', 30);
I.click('Sign in to your account.');
I.fillField('#username', existingCitizenEmail);
I.wait(2)
I.fillField('#password', TestData.PASSWORD);
I.click('Sign in');
});
2 changes: 0 additions & 2 deletions src/test/js/policy_check_functional_test.js
Original file line number Diff line number Diff line change
@@ -36,8 +36,6 @@ BeforeSuite(async (I) => {
roleNames.push(serviceRoles);
await I.createServiceWithRoles(serviceName, serviceRoles, serviceBetaRole, token);
serviceNames.push(serviceName);
await I.createUserWithRoles(adminEmail, randomUserFirstName + 'Admin', [serviceAdminRole, "IDAM_ADMIN_USER"]);
userFirstNames.push(randomUserFirstName + 'Admin');
await I.createUserWithRoles(citizenEmail, randomUserFirstName + 'Citizen', ["citizen"]);
userFirstNames.push(randomUserFirstName + 'Citizen');

2 changes: 1 addition & 1 deletion src/test/js/shared/random_data.js
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ function randomAlphabeticString(length = 10) {
return randomString
}

const testBasePrefix = "SIDMTESTWP" + randomAlphabeticString();
const testBasePrefix = "SIDMTESTWP_" + randomAlphabeticString();
const testUserPrefix = testBasePrefix + "USER";
const testRolePrefix = testBasePrefix + "ROLE_";
const testServicePrefix = testBasePrefix + "SERVICE_";
30 changes: 30 additions & 0 deletions src/test/js/shared/sauceLabsReportingHelper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* eslint-disable no-process-env, no-console, prefer-template */

const event = require('codeceptjs').event;
const container = require('codeceptjs').container;
const exec = require('child_process').exec;

const sauceUsername = process.env.SAUCE_USERNAME;
const sauceKey = process.env.SAUCE_ACCESS_KEY;


function updateSauceLabsResult(result, sessionId) {
console.log('SauceOnDemandSessionID=' + sessionId + ' job-name=idam-web-public-Uitests');
// eslint-disable-next-line max-len
return 'curl -X PUT -s -d \'{"passed": ' + result + '}\' -u ' + sauceUsername + ':' + sauceKey + ' https://eu-central-1.saucelabs.com/rest/v1/' + sauceUsername + '/jobs/' + sessionId;
}

// eslint-disable-next-line
module.exports = function() {
// Setting test success on SauceLabs
event.dispatcher.on(event.test.passed, () => {
const sessionId = container.helpers('WebDriverIO').browser.requestHandler.sessionID;
exec(updateSauceLabsResult('true', sessionId));
});

// Setting test failure on SauceLabs
event.dispatcher.on(event.test.failed, () => {
const sessionId = container.helpers('WebDriverIO').browser.requestHandler.sessionID;
exec(updateSauceLabsResult('false', sessionId));
});
};