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

add login with pin test #361

Merged
merged 6 commits into from
Apr 30, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
18 changes: 17 additions & 1 deletion src/test/js/shared/idam_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ class IdamHelper extends Helper {
const helper = this.helpers['Puppeteer'];
helper.page.setRequestInterception(true);
helper.page.on('request', request => {
if (request.url().indexOf('/login') > 0 || request.url().indexOf('/register') > 0 || request.url().indexOf('/activate') > 0 || request.url().indexOf('/verification') > 0) {
if (request.url().indexOf('/login') > 0 || request.url().indexOf('/register') > 0 || request.url().indexOf('/activate') > 0 || request.url().indexOf('/verification') > 0 | request.url().indexOf('/pin') > 0) {
shravanmechineni marked this conversation as resolved.
Show resolved Hide resolved
request.continue();
} else {
request.respond({
Expand Down Expand Up @@ -604,6 +604,22 @@ class IdamHelper extends Helper {
})
}

getOidcUserInfo(accessToken) {
return fetch(`${TestData.IDAM_API}/o/userinfo`, {
agent: agent,
method: 'GET',
headers: {
'Authorization': 'Bearer ' + accessToken
}
}).then(response => {
if (response.status != 200) {
console.log('Error getting user details', response.status);
throw new Error()
}
return response.json();
})
}

grantRoleToUser(roleName, accessToken) {
return fetch(`${TestData.IDAM_API}/account/role`, {
agent: agent,
Expand Down
23 changes: 23 additions & 0 deletions src/test/js/uplift_user_test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const TestData = require('./config/test_data');
const randomData = require('./shared/random_data');
const chai = require('chai');
const {expect} = chai;

Feature('I am able to uplift a user');

Expand Down Expand Up @@ -48,6 +50,27 @@ AfterSuite(async (I) => {
return await I.deleteAllTestData(randomData.TEST_BASE_PREFIX);
});

Scenario('@functional @loginWithPin As a Defendant, I should be able to login with the pin received from the Claimant', async (I) => {
let pinUser = await I.getPinUser(randomUserFirstName, randomUserLastName);
I.amOnPage(`${TestData.WEB_PUBLIC_URL}/login/pin?redirect_uri=${TestData.SERVICE_REDIRECT_URI}&client_id=${serviceName}`);
I.waitForText('Enter security code', 30, 'h1');
I.fillField('#pin', pinUser.pin);

I.interceptRequestsAfterSignin();
I.click('Continue');
I.waitForText(TestData.SERVICE_REDIRECT_URI);
I.see('code=');

let pageSource = await I.grabSource();
let code = pageSource.match(/\?code=([^&]*)(.*)/)[1];
let accessToken = await I.getAccessToken(code, serviceName, TestData.SERVICE_REDIRECT_URI, TestData.SERVICE_CLIENT_SECRET);

let userInfo = await I.retry({retries: 3, minTimeout: 10000}).getOidcUserInfo(accessToken);
expect(userInfo.roles).to.eql(['letter-holder']);

I.resetRequestInterception();
shravanmechineni marked this conversation as resolved.
Show resolved Hide resolved
});

Scenario('@functional @uplift @upliftvalid User Validation errors', (I) => {
I.amOnPage(`${TestData.WEB_PUBLIC_URL}/login/uplift?client_id=${serviceName}&redirect_uri=${TestData.SERVICE_REDIRECT_URI}&jwt=${accessToken}`);
I.waitForText('Create an account or sign in', 30, 'h1');
Expand Down