blob: 30b2e8a6e6297f84036599f03acf4101ecc20f6e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
/*!
* Matomo - free/libre analytics platform
*
* Screenshot integration tests.
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
describe("TwoFactorAuthUsersManager", function () {
this.fixture = "Piwik\\Plugins\\TwoFactorAuth\\tests\\Fixtures\\TwoFactorUsersManagerFixture";
var generalParams = 'idSite=1&period=day&date=2010-01-03',
usersManager = '?module=UsersManager&action=index&' + generalParams;
before(function () {
testEnvironment.pluginsToLoad = ['TwoFactorAuth'];
testEnvironment.save();
});
it('shows users with 2fa and not 2fa', async function () {
await page.goto(usersManager);
await page.evaluate(function () {
$('td#last_seen').html(''); // fix random test failure
});
expect(await page.screenshotSelector('#content,#notificationContainer')).to.matchImage('list');
});
it('menu should show 2fa tab', async function () {
await page.webpage.setViewport({
width: 1250,
height: 768
});
await page.click('#manageUsersTable #row2 .edituser');
await page.evaluate(function () {
$('.userEditForm .menuUserTwoFa a').click();
});
await page.waitForTimeout(250);
await page.waitForSelector('.twofa-reset > p', { visible: true });
expect(await page.screenshotSelector('#content,#notificationContainer')).to.matchImage('edit_with_2fa');
});
it('should ask for confirmation before resetting 2fa', async function () {
await page.click('.userEditForm .twofa-reset .resetTwoFa .btn');
const modal = await page.waitForSelector('.modal.open', { visible: true });
await page.waitForTimeout(1000); // animation
expect(await modal.screenshot()).to.matchImage('edit_with_2fa_reset_confirm');
});
it('should be possible to confirm the reset', async function () {
await page.type('.twofa-confirm-modal input[name=currentUserPassword]', 'superUserPass');
await page.click('.twofa-confirm-modal .modal-close:not(.modal-no)');
await page.waitForTimeout(500); // wait for modal to close
expect(await page.screenshotSelector('#content,#notificationContainer')).to.matchImage('edit_with_2fa_reset_confirmed');
});
});
|