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

feat(DTFS2-6711): link up account blocked page #2326

Merged
merged 42 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
2e3ffe2
feat(DTFS2-6777): add e2e tests for sign in link
lmarrai-sw Nov 8, 2023
94682bf
feat(DTFS2-6711): fix api tests
AlexBramhill Nov 20, 2023
16e74dc
feat(DTFS2-6711): fix api tests
AlexBramhill Nov 20, 2023
5c20833
feat(DTFS2-6711): initial functionality
AlexBramhill Nov 16, 2023
e6842a9
feat(DTFS2-6711): update handling of redirect for blocked user
AlexBramhill Nov 17, 2023
354ea2a
feat(DTFS2-6711): update handling of reactivating user
AlexBramhill Nov 17, 2023
241359d
feat(DTFS2-6711): update repository tests
AlexBramhill Nov 17, 2023
c18ef70
feat(DTFS2-6711): update repository tests
AlexBramhill Nov 17, 2023
e103a41
feat(DTFS2-6711): update sign in link service tests
AlexBramhill Nov 17, 2023
075b779
feat(DTFS2-6711): update sign in link service tests
AlexBramhill Nov 17, 2023
8b47d31
feat(DTFS2-6711): update functions to unset as apposed to set null
AlexBramhill Nov 21, 2023
9d23884
feat(DTFS2-6711): uncomment test area
AlexBramhill Nov 21, 2023
0ea15a5
feat(DTFS2-6711): fix sign-in-link.controller tests
AlexBramhill Nov 22, 2023
3a3f77c
feat(DTFS2-6711): fix check-your-email tests
AlexBramhill Nov 22, 2023
ae31d81
feat(DTFS2-6711): fix check-your-email tests
AlexBramhill Nov 22, 2023
3e66b7d
feat(DTFS2-6711): fix check-your-email tests
AlexBramhill Nov 22, 2023
b815a6f
feat(DTFS2-6711): fix check-your-email tests
AlexBramhill Nov 22, 2023
ee49762
feat(DTFS2-6711): fix check-your-email tests
AlexBramhill Nov 22, 2023
5724f15
feat(DTFS2-6711): fix unit tests
AlexBramhill Nov 27, 2023
0402863
feat(DTFS2-6711): fix tests
AlexBramhill Nov 27, 2023
54f353b
feat(DTFS2-6711): fix tests
AlexBramhill Nov 27, 2023
52fa1a1
feat(DTFS2-6711): fix tests
AlexBramhill Nov 27, 2023
b01e349
feat(DTFS2-6711): fix api-tests
AlexBramhill Nov 27, 2023
b5c5d22
feat(DTFS2-6711): fix api-tests
AlexBramhill Nov 27, 2023
24a1fb4
feat(DTFS2-6711): fix api-tests
AlexBramhill Nov 29, 2023
2676515
feat(DTFS2-6711): fix api-tests
AlexBramhill Nov 29, 2023
9bab818
feat(DTFS2-6711): update wipedb to databasehelper
AlexBramhill Nov 29, 2023
d8c0c13
feat(DTFS2-6711): fix unit-test
AlexBramhill Nov 29, 2023
231a091
feat(DTFS2-6711): fix unit-test
AlexBramhill Nov 29, 2023
96b1227
feat(DTFS2-6711): fix unit tetst
AlexBramhill Nov 29, 2023
6148747
feat(DTFS2-6711): fix unit tetst
AlexBramhill Nov 29, 2023
a8ba506
feat(DTFS2-6711): refactor unset
AlexBramhill Nov 29, 2023
3a542c7
feat(DTFS2-6711): refactor unset
AlexBramhill Nov 29, 2023
48136e8
feat(DTFS2-6711): refactor to review comments
AlexBramhill Nov 29, 2023
66506b6
feat(DTFS2-6711): refactor to review comments
AlexBramhill Nov 29, 2023
488349c
feat(DTFS2-6711): refactor to review comments
AlexBramhill Nov 30, 2023
15c5e86
feat(DTFS2-6711): refactor to review comments
AlexBramhill Nov 30, 2023
a6b6ad1
feat(DTFS2-6711): refactor to review comments
AlexBramhill Nov 30, 2023
ba9c5be
feat(DTFS2-6711): refactor to review comments
AlexBramhill Nov 30, 2023
bc383b0
feat(DTFS2-6711): refactor to review comments
AlexBramhill Nov 30, 2023
db50ea9
feat(DTFS2-6711): refactor to review comments
AlexBramhill Nov 30, 2023
c0c8a78
feat(DTFS2-6711): refactor to review comments
AlexBramhill Nov 30, 2023
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { checkYourEmail, signInLink } = require('../../pages');
const { checkYourEmail, signInLink, landingPage } = require('../../pages');
const relative = require('../../relativeURL');
const MOCK_USERS = require('../../../../../e2e-fixtures');

Expand Down Expand Up @@ -64,6 +64,23 @@ context('Resending sign in links', () => {
checkYourEmail.attemptsRemaining().should('not.exist');
checkYourEmail.sendNewSignInLinkButton().should('not.exist');
});

it('The user is blocked if they attempt to sign in after using all resend email attempts', () => {
checkYourEmail.attemptsRemaining().should('contain', '2 attempts remaining');
checkYourEmail.visit();
checkYourEmail.sendNewSignInLink();

checkYourEmail.visit();
checkYourEmail.sendNewSignInLink();

checkYourEmail.visit();
landingPage.visit();
cy.enterUsernameAndPassword(BANK1_MAKER1);

landingPage.accountSuspended().should('exist');
checkYourEmail.visit();
checkYourEmail.accountSuspended().should('exist');
});
});
});

Expand Down
1 change: 1 addition & 0 deletions e2e-tests/portal/cypress/e2e/pages/landingPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const landingPage = {
emailError: (text) => cy.get('[data-cy="email-error"]').contains(text),
passwordError: (text) => cy.get('[data-cy="password-error"]').contains(text),
expectError: (text) => cy.get('[data-cy="error-summary"]').contains(text),
accountSuspended: () => cy.get('[data-cy="account-suspended"]'),
};

module.exports = landingPage;
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const checkYourEmail = {
obscuredSignInLinkTargetEmailAddressText: () => cy.get('[data-cy="obscured-sign-in-link-target-email-address"]'),
attemptsRemaining: () => cy.get('[data-cy="attempts-remaining"]'),
sendNewSignInLink: () => checkYourEmail.sendNewSignInLinkButton().click(),
accountSuspended: () => cy.get('[data-cy="account-suspended"]'),
csrfToken: () => cy.get('[data-cy=csrf-input]').then((csrfInput) => csrfInput.attr('value')),
};

Expand Down
4 changes: 2 additions & 2 deletions portal-api/api-tests/api-test-users.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const api = require('./api');
const db = require('../src/drivers/db-client');
const { genPassword } = require('../src/crypto/utils');
const wipeDB = require('./wipeDB');
const databaseHelper = require('./database-helper');
const { MAKER, CHECKER, ADMIN, READ_ONLY } = require('../src/v1/roles/roles');
const { FEATURE_FLAGS } = require('../src/config/feature-flag.config');
const { createLoggedInUserSession } = require('../test-helpers/api-test-helpers/database/user-repository');
Expand Down Expand Up @@ -266,7 +266,7 @@ const setUpApiTestUser = async (as) => {

const initialise = async (app) => {
if (notYetInitialised) {
await wipeDB.wipe(['users']);
await databaseHelper.wipe(['users']);

const { as } = api(app);

Expand Down
76 changes: 76 additions & 0 deletions portal-api/api-tests/database-helper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
const { ObjectId } = require('mongodb');
const db = require('../src/drivers/db-client');

const wipe = async (collections) => {
const drop = async (collection) =>
new Promise((resolve) => {
db.getCollection(collection).then((c) => c.drop(() => resolve()));
});

const dropPromises = [];
for (const collection of collections) {
dropPromises.push(drop(collection));
}
const dropped = await Promise.all(dropPromises);
return dropped;
};

const wipeAll = async () => {
const wiped = await wipe([
'deals',
'facilities',
'banks',
'transactions',
'industrySectors',
'mandatoryCriteria',
'eligibilityCriteria',
'users',
'gef-mandatoryCriteriaVersioned',
]);
return wiped;
};

const deleteUser = async (user) => {
const { username } = user;

if (typeof username !== 'string') {
throw new Error('Invalid Username');
}

const usersCollection = await db.getCollection('users');
await usersCollection.deleteMany({ username: { $eq: username } });
};

const unsetUserProperties = async ({ username, properties }) => {
if (typeof username !== 'string') {
throw new Error('Invalid Username');
}

const unsetUpdate = properties.reduce((acc, property) => {
acc[property] = null;
return acc;
}, {});

const usersCollection = await db.getCollection('users');
await usersCollection.updateOne({ username: { $eq: username } }, { $unset: unsetUpdate });
};

const setUserProperties = async ({ username, update }) => {
if (typeof username !== 'string') {
throw new Error('Invalid Username');
}

const usersCollection = await db.getCollection('users');
await usersCollection.updateOne({ username: { $eq: username } }, { $set: update });
};

const getUserById = async (userId) => (await db.getCollection('users')).findOne({ _id: { $eq: ObjectId(userId) } });

module.exports = {
wipe,
wipeAll,
deleteUser,
unsetUserProperties,
setUserProperties,
getUserById,
};
4 changes: 2 additions & 2 deletions portal-api/api-tests/v1/banks/banks.api-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const app = require('../../../src/createApp');
const testUserCache = require('../../api-test-users');
const wipeDB = require('../../wipeDB');
const databaseHelper = require('../../database-helper');

const { as } = require('../../api')(app);
const { expectMongoId, expectMongoIds } = require('../../expectMongoIds');
Expand Down Expand Up @@ -28,7 +28,7 @@ describe.skip('/v1/banks', () => {
});

beforeEach(async () => {
await wipeDB.wipe(['banks']);
await databaseHelper.wipe(['banks']);
});

describe('GET /v1/banks', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const moment = require('moment');
const aDeal = require('../deals/deal-builder');
const wipeDB = require('../../wipeDB');
const databaseHelper = require('../../database-helper');
const app = require('../../../src/createApp');
const testUserCache = require('../../api-test-users');
const { as } = require('../../api')(app);
Expand Down Expand Up @@ -73,8 +73,8 @@ describe('/v1/deals/:id/bond/:bondId/change-cover-start-date', () => {
});

beforeEach(async () => {
await wipeDB.wipe(['deals']);
await wipeDB.wipe(['facilities']);
await databaseHelper.wipe(['deals']);
await databaseHelper.wipe(['facilities']);
});

describe('PUT /v1/deals/:id/bond/:bondId/change-cover-start-date', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const moment = require('moment');
const wipeDB = require('../../wipeDB');
const databaseHelper = require('../../database-helper');
const aDeal = require('../deals/deal-builder');
const app = require('../../../src/createApp');
const testUserCache = require('../../api-test-users');
Expand Down Expand Up @@ -78,8 +78,8 @@ describe('/v1/deals/:id/bond/change-cover-start-date', () => {
});

beforeEach(async () => {
await wipeDB.wipe(['deals']);
await wipeDB.wipe(['facilities']);
await databaseHelper.wipe(['deals']);
await databaseHelper.wipe(['facilities']);
await createDealAndBond();
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const moment = require('moment');
const aDeal = require('../deals/deal-builder');
const wipeDB = require('../../wipeDB');
const databaseHelper = require('../../database-helper');
const app = require('../../../src/createApp');
const testUserCache = require('../../api-test-users');
const { as } = require('../../api')(app);
Expand Down Expand Up @@ -75,8 +75,8 @@ describe('/v1/deals/:id/bond/:bondId/issue-facility', () => {
});

beforeEach(async () => {
await wipeDB.wipe(['deals']);
await wipeDB.wipe(['facilities']);
await databaseHelper.wipe(['deals']);
await databaseHelper.wipe(['facilities']);
});

describe('PUT /v1/deals/:id/bond/:bondId/issue-facility', () => {
Expand Down
6 changes: 3 additions & 3 deletions portal-api/api-tests/v1/bonds/bond-issue-facility.api-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const moment = require('moment');
const wipeDB = require('../../wipeDB');
const databaseHelper = require('../../database-helper');
const aDeal = require('../deals/deal-builder');
const app = require('../../../src/createApp');
const testUserCache = require('../../api-test-users');
Expand Down Expand Up @@ -90,8 +90,8 @@ describe('/v1/deals/:id/bond/:id/issue-facility', () => {
});

beforeEach(async () => {
await wipeDB.wipe(['deals']);
await wipeDB.wipe(['facilities']);
await databaseHelper.wipe(['deals']);
await databaseHelper.wipe(['facilities']);
await createBond();
});

Expand Down
6 changes: 3 additions & 3 deletions portal-api/api-tests/v1/bonds/bonds-validation.api-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const moment = require('moment');
const wipeDB = require('../../wipeDB');
const databaseHelper = require('../../database-helper');
const aDeal = require('../deals/deal-builder');
const app = require('../../../src/createApp');
const testUserCache = require('../../api-test-users');
Expand Down Expand Up @@ -61,8 +61,8 @@ describe('/v1/deals/:id/bond', () => {
});

beforeEach(async () => {
await wipeDB.wipe(['deals']);
await wipeDB.wipe(['facilities']);
await databaseHelper.wipe(['deals']);
await databaseHelper.wipe(['facilities']);

const dealResponse = await as(aBarclaysMaker).post(newDeal).to('/v1/deals/');
deal = dealResponse.body;
Expand Down
6 changes: 3 additions & 3 deletions portal-api/api-tests/v1/bonds/bonds.api-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const moment = require('moment');
const wipeDB = require('../../wipeDB');
const databaseHelper = require('../../database-helper');
const aDeal = require('../deals/deal-builder');
const app = require('../../../src/createApp');
const testUserCache = require('../../api-test-users');
Expand Down Expand Up @@ -98,8 +98,8 @@ describe('/v1/deals/:id/bond', () => {
});

beforeEach(async () => {
await wipeDB.wipe(['deals']);
await wipeDB.wipe(['facilities']);
await databaseHelper.wipe(['deals']);
await databaseHelper.wipe(['facilities']);
});

describe('GET /v1/deals/:id/bond/:id', () => {
Expand Down
4 changes: 2 additions & 2 deletions portal-api/api-tests/v1/deals/deal-clone.api-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const wipeDB = require('../../wipeDB');
const databaseHelper = require('../../database-helper');
const app = require('../../../src/createApp');
const testUserCache = require('../../api-test-users');
const completedDeal = require('../../fixtures/deal-fully-completed');
Expand Down Expand Up @@ -57,7 +57,7 @@ describe('/v1/deals/:id/clone', () => {
});

beforeEach(async () => {
await wipeDB.wipe(['deals', 'facilities']);
await databaseHelper.wipe(['deals', 'facilities']);
});

describe('POST /v1/deals/:id/clone', () => {
Expand Down
6 changes: 3 additions & 3 deletions portal-api/api-tests/v1/deals/deal-comments.api-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const wipeDB = require('../../wipeDB');
const databaseHelper = require('../../database-helper');

const app = require('../../../src/createApp');
const testUserCache = require('../../api-test-users');
Expand Down Expand Up @@ -31,8 +31,8 @@ describe('deal comments controller', () => {
});

afterEach(async () => {
await wipeDB.wipe(['deals']);
await wipeDB.wipe(['facilities']);
await databaseHelper.wipe(['deals']);
await databaseHelper.wipe(['facilities']);
});

it('should update a comment', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const wipeDB = require('../../wipeDB');
const databaseHelper = require('../../database-helper');
const aDeal = require('./deal-builder');

const app = require('../../../src/createApp');
Expand Down Expand Up @@ -34,8 +34,8 @@ describe('/v1/deals/:id/eligibility-criteria', () => {
});

beforeEach(async () => {
await wipeDB.wipe(['deals']);
await wipeDB.wipe(['facilities']);
await databaseHelper.wipe(['deals']);
await databaseHelper.wipe(['facilities']);
});

describe('PUT /v1/deals/:id/eligibility-criteria', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const wipeDB = require('../../wipeDB');
const databaseHelper = require('../../database-helper');
const aDeal = require('./deal-builder');

const app = require('../../../src/createApp');
Expand Down Expand Up @@ -33,8 +33,8 @@ describe('/v1/deals/:id/eligibility-documentation', () => {
});

beforeEach(async () => {
await wipeDB.wipe(['deals']);
await wipeDB.wipe(['facilities']);
await databaseHelper.wipe(['deals']);
await databaseHelper.wipe(['facilities']);
});

describe('GET /v1/deals/:id/eligibility-documentation/:fieldname/:filename', () => {
Expand Down
6 changes: 3 additions & 3 deletions portal-api/api-tests/v1/deals/deal-name.api-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const wipeDB = require('../../wipeDB');
const databaseHelper = require('../../database-helper');
const aDeal = require('./deal-builder');

const app = require('../../../src/createApp');
Expand Down Expand Up @@ -36,8 +36,8 @@ describe('/v1/deals/:id/additionalRefName', () => {
});

beforeEach(async () => {
await wipeDB.wipe(['deals']);
await wipeDB.wipe(['facilities']);
await databaseHelper.wipe(['deals']);
await databaseHelper.wipe(['facilities']);
});

describe('PUT /v1/deals/:id/additionalRefName', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const moment = require('moment');
const wipeDB = require('../../wipeDB');
const databaseHelper = require('../../database-helper');

const app = require('../../../src/createApp');
const testUserCache = require('../../api-test-users');
Expand All @@ -14,8 +14,8 @@ describe('PUT /v1/deals/:id/status - to `Accepted by UKEF`', () => {
let aSuperuser;

beforeAll(async () => {
await wipeDB.wipe(['deals']);
await wipeDB.wipe(['facilities']);
await databaseHelper.wipe(['deals']);
await databaseHelper.wipe(['facilities']);
const testUsers = await testUserCache.initialise(app);
const barclaysMakers = testUsers().withRole(MAKER).withBankName('Barclays Bank').all();
[aBarclaysMaker] = barclaysMakers;
Expand Down
6 changes: 3 additions & 3 deletions portal-api/api-tests/v1/deals/deal-validation.api-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const wipeDB = require('../../wipeDB');
const databaseHelper = require('../../database-helper');
const app = require('../../../src/createApp');
const testUserCache = require('../../api-test-users');
const { as } = require('../../api')(app);
Expand All @@ -13,8 +13,8 @@ describe('/v1/deals', () => {
});

beforeEach(async () => {
await wipeDB.wipe(['deals']);
await wipeDB.wipe(['facilities']);
await databaseHelper.wipe(['deals']);
await databaseHelper.wipe(['facilities']);
});

describe('POST /v1/deals', () => {
Expand Down
Loading
Loading