Replace WaitRedirected assertion by VerifyUrlIs.
parent
036d1a4f51
commit
3702d6607d
|
@ -1,5 +0,0 @@
|
||||||
import SeleniumWebdriver, { WebDriver } from "selenium-webdriver";
|
|
||||||
|
|
||||||
export default async function(driver: WebDriver, url: string, timeout: number = 5000) {
|
|
||||||
await driver.wait(SeleniumWebdriver.until.urlIs(url), timeout);
|
|
||||||
}
|
|
|
@ -1,7 +1,6 @@
|
||||||
import LoginAndRegisterTotp from "../../../helpers/LoginAndRegisterTotp";
|
import LoginAndRegisterTotp from "../../../helpers/LoginAndRegisterTotp";
|
||||||
import FillLoginPageWithUserAndPasswordAndClick from "../../../helpers/FillLoginPageAndClick";
|
import FillLoginPageWithUserAndPasswordAndClick from "../../../helpers/FillLoginPageAndClick";
|
||||||
import ValidateTotp from "../../../helpers/ValidateTotp";
|
import ValidateTotp from "../../../helpers/ValidateTotp";
|
||||||
import WaitRedirected from "../../../helpers/WaitRedirected";
|
|
||||||
import { WebDriver } from "selenium-webdriver";
|
import { WebDriver } from "selenium-webdriver";
|
||||||
import VisitPageAndWaitUrlIs from "../../../helpers/behaviors/VisitPageAndWaitUrlIs";
|
import VisitPageAndWaitUrlIs from "../../../helpers/behaviors/VisitPageAndWaitUrlIs";
|
||||||
import VisitPage from "../../../helpers/VisitPage";
|
import VisitPage from "../../../helpers/VisitPage";
|
||||||
|
@ -19,11 +18,11 @@ export default function(this: Mocha.ISuiteCallbackContext) {
|
||||||
await VisitPageAndWaitUrlIs(driver, "https://login.example.com:8080/?rd=https://admin.example.com:8080/secret.html");
|
await VisitPageAndWaitUrlIs(driver, "https://login.example.com:8080/?rd=https://admin.example.com:8080/secret.html");
|
||||||
await FillLoginPageWithUserAndPasswordAndClick(driver, 'john', 'password', false);
|
await FillLoginPageWithUserAndPasswordAndClick(driver, 'john', 'password', false);
|
||||||
await ValidateTotp(driver, this.secret);
|
await ValidateTotp(driver, this.secret);
|
||||||
await WaitRedirected(driver, "https://admin.example.com:8080/secret.html");
|
await VerifyUrlIs(driver, "https://admin.example.com:8080/secret.html");
|
||||||
await VisitPageAndWaitUrlIs(driver, "https://home.example.com:8080/");
|
await VisitPageAndWaitUrlIs(driver, "https://home.example.com:8080/");
|
||||||
await driver.sleep(6000);
|
await driver.sleep(6000);
|
||||||
await driver.get("https://admin.example.com:8080/secret.html");
|
await driver.get("https://admin.example.com:8080/secret.html");
|
||||||
await WaitRedirected(driver, "https://login.example.com:8080/?rd=https://admin.example.com:8080/secret.html");
|
await VerifyUrlIs(driver, "https://login.example.com:8080/?rd=https://admin.example.com:8080/secret.html");
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should disconnect user after cookie expiration', async function() {
|
it('should disconnect user after cookie expiration', async function() {
|
||||||
|
@ -31,7 +30,7 @@ export default function(this: Mocha.ISuiteCallbackContext) {
|
||||||
await VisitPageAndWaitUrlIs(driver, "https://login.example.com:8080/?rd=https://admin.example.com:8080/secret.html");
|
await VisitPageAndWaitUrlIs(driver, "https://login.example.com:8080/?rd=https://admin.example.com:8080/secret.html");
|
||||||
await FillLoginPageWithUserAndPasswordAndClick(driver, 'john', 'password', false);
|
await FillLoginPageWithUserAndPasswordAndClick(driver, 'john', 'password', false);
|
||||||
await ValidateTotp(driver, this.secret);
|
await ValidateTotp(driver, this.secret);
|
||||||
await WaitRedirected(driver, "https://admin.example.com:8080/secret.html");
|
await VerifyUrlIs(driver, "https://admin.example.com:8080/secret.html");
|
||||||
await VisitPageAndWaitUrlIs(driver, "https://home.example.com:8080/");
|
await VisitPageAndWaitUrlIs(driver, "https://home.example.com:8080/");
|
||||||
|
|
||||||
await driver.sleep(4000);
|
await driver.sleep(4000);
|
||||||
|
@ -41,7 +40,7 @@ export default function(this: Mocha.ISuiteCallbackContext) {
|
||||||
|
|
||||||
await driver.sleep(2000);
|
await driver.sleep(2000);
|
||||||
await driver.get("https://admin.example.com:8080/secret.html");
|
await driver.get("https://admin.example.com:8080/secret.html");
|
||||||
await WaitRedirected(driver, "https://login.example.com:8080/?rd=https://admin.example.com:8080/secret.html");
|
await VerifyUrlIs(driver, "https://login.example.com:8080/?rd=https://admin.example.com:8080/secret.html");
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -51,7 +50,7 @@ export default function(this: Mocha.ISuiteCallbackContext) {
|
||||||
await VisitPageAndWaitUrlIs(driver, "https://login.example.com:8080/?rd=https://admin.example.com:8080/secret.html");
|
await VisitPageAndWaitUrlIs(driver, "https://login.example.com:8080/?rd=https://admin.example.com:8080/secret.html");
|
||||||
await FillLoginPageWithUserAndPasswordAndClick(driver, 'john', 'password', true);
|
await FillLoginPageWithUserAndPasswordAndClick(driver, 'john', 'password', true);
|
||||||
await ValidateTotp(driver, this.secret);
|
await ValidateTotp(driver, this.secret);
|
||||||
await WaitRedirected(driver, "https://admin.example.com:8080/secret.html");
|
await VerifyUrlIs(driver, "https://admin.example.com:8080/secret.html");
|
||||||
await VisitPageAndWaitUrlIs(driver, "https://home.example.com:8080/");
|
await VisitPageAndWaitUrlIs(driver, "https://home.example.com:8080/");
|
||||||
await driver.sleep(6000);
|
await driver.sleep(6000);
|
||||||
await VisitPage(driver, "https://admin.example.com:8080/secret.html");
|
await VisitPage(driver, "https://admin.example.com:8080/secret.html");
|
||||||
|
|
|
@ -2,22 +2,22 @@ import SeleniumWebDriver from 'selenium-webdriver';
|
||||||
|
|
||||||
import ClickOnLink from '../../../helpers/ClickOnLink';
|
import ClickOnLink from '../../../helpers/ClickOnLink';
|
||||||
import ClickOn from '../../../helpers/ClickOn';
|
import ClickOn from '../../../helpers/ClickOn';
|
||||||
import WaitRedirected from '../../../helpers/WaitRedirected';
|
|
||||||
import FillField from "../../../helpers/FillField";
|
import FillField from "../../../helpers/FillField";
|
||||||
import {GetLinkFromEmail} from "../../../helpers/GetIdentityLink";
|
import {GetLinkFromEmail} from "../../../helpers/GetIdentityLink";
|
||||||
import FillLoginPageAndClick from "../../../helpers/FillLoginPageAndClick";
|
import FillLoginPageAndClick from "../../../helpers/FillLoginPageAndClick";
|
||||||
import IsSecondFactorStage from "../../../helpers/assertions/VerifyIsSecondFactorStage";
|
import IsSecondFactorStage from "../../../helpers/assertions/VerifyIsSecondFactorStage";
|
||||||
import VisitPageAndWaitUrlIs from '../../../helpers/behaviors/VisitPageAndWaitUrlIs';
|
import VisitPageAndWaitUrlIs from '../../../helpers/behaviors/VisitPageAndWaitUrlIs';
|
||||||
import VerifyNotificationDisplayed from '../../../helpers/assertions/VerifyNotificationDisplayed';
|
import VerifyNotificationDisplayed from '../../../helpers/assertions/VerifyNotificationDisplayed';
|
||||||
|
import VerifyUrlIs from '../../../helpers/assertions/VerifyUrlIs';
|
||||||
|
|
||||||
export default function() {
|
export default function() {
|
||||||
it("should reset password for john", async function() {
|
it("should reset password for john", async function() {
|
||||||
await VisitPageAndWaitUrlIs(this.driver, "https://login.example.com:8080/");
|
await VisitPageAndWaitUrlIs(this.driver, "https://login.example.com:8080/");
|
||||||
await ClickOnLink(this.driver, "Forgot password\?");
|
await ClickOnLink(this.driver, "Forgot password\?");
|
||||||
await WaitRedirected(this.driver, "https://login.example.com:8080/forgot-password");
|
await VerifyUrlIs(this.driver, "https://login.example.com:8080/forgot-password");
|
||||||
await FillField(this.driver, "username", "john");
|
await FillField(this.driver, "username", "john");
|
||||||
await ClickOn(this.driver, SeleniumWebDriver.By.id('next-button'));
|
await ClickOn(this.driver, SeleniumWebDriver.By.id('next-button'));
|
||||||
await WaitRedirected(this.driver, 'https://login.example.com:8080/confirmation-sent');
|
await VerifyUrlIs(this.driver, 'https://login.example.com:8080/confirmation-sent');
|
||||||
|
|
||||||
await this.driver.sleep(500); // Simulate the time it takes to receive the e-mail.
|
await this.driver.sleep(500); // Simulate the time it takes to receive the e-mail.
|
||||||
const link = await GetLinkFromEmail();
|
const link = await GetLinkFromEmail();
|
||||||
|
@ -25,7 +25,7 @@ export default function() {
|
||||||
await FillField(this.driver, "password1", "newpass");
|
await FillField(this.driver, "password1", "newpass");
|
||||||
await FillField(this.driver, "password2", "newpass");
|
await FillField(this.driver, "password2", "newpass");
|
||||||
await ClickOn(this.driver, SeleniumWebDriver.By.id('reset-button'));
|
await ClickOn(this.driver, SeleniumWebDriver.By.id('reset-button'));
|
||||||
await WaitRedirected(this.driver, "https://login.example.com:8080/");
|
await VerifyUrlIs(this.driver, "https://login.example.com:8080/");
|
||||||
await FillLoginPageAndClick(this.driver, "john", "newpass");
|
await FillLoginPageAndClick(this.driver, "john", "newpass");
|
||||||
|
|
||||||
// The user reaches the second factor page using the new password.
|
// The user reaches the second factor page using the new password.
|
||||||
|
@ -35,21 +35,21 @@ export default function() {
|
||||||
it("should persuade reset password is initiated for unknown user", async function() {
|
it("should persuade reset password is initiated for unknown user", async function() {
|
||||||
await VisitPageAndWaitUrlIs(this.driver, "https://login.example.com:8080/");
|
await VisitPageAndWaitUrlIs(this.driver, "https://login.example.com:8080/");
|
||||||
await ClickOnLink(this.driver, "Forgot password\?");
|
await ClickOnLink(this.driver, "Forgot password\?");
|
||||||
await WaitRedirected(this.driver, "https://login.example.com:8080/forgot-password");
|
await VerifyUrlIs(this.driver, "https://login.example.com:8080/forgot-password");
|
||||||
await FillField(this.driver, "username", "unknown");
|
await FillField(this.driver, "username", "unknown");
|
||||||
await ClickOn(this.driver, SeleniumWebDriver.By.id('next-button'));
|
await ClickOn(this.driver, SeleniumWebDriver.By.id('next-button'));
|
||||||
|
|
||||||
// The malicious user thinks the confirmation has been sent.
|
// The malicious user thinks the confirmation has been sent.
|
||||||
await WaitRedirected(this.driver, 'https://login.example.com:8080/confirmation-sent');
|
await VerifyUrlIs(this.driver, 'https://login.example.com:8080/confirmation-sent');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should notify passwords are different in reset form", async function() {
|
it("should notify passwords are different in reset form", async function() {
|
||||||
await VisitPageAndWaitUrlIs(this.driver, "https://login.example.com:8080/");
|
await VisitPageAndWaitUrlIs(this.driver, "https://login.example.com:8080/");
|
||||||
await ClickOnLink(this.driver, "Forgot password\?");
|
await ClickOnLink(this.driver, "Forgot password\?");
|
||||||
await WaitRedirected(this.driver, "https://login.example.com:8080/forgot-password");
|
await VerifyUrlIs(this.driver, "https://login.example.com:8080/forgot-password");
|
||||||
await FillField(this.driver, "username", "john");
|
await FillField(this.driver, "username", "john");
|
||||||
await ClickOn(this.driver, SeleniumWebDriver.By.id('next-button'));
|
await ClickOn(this.driver, SeleniumWebDriver.By.id('next-button'));
|
||||||
await WaitRedirected(this.driver, 'https://login.example.com:8080/confirmation-sent');
|
await VerifyUrlIs(this.driver, 'https://login.example.com:8080/confirmation-sent');
|
||||||
|
|
||||||
await this.driver.sleep(500); // Simulate the time it takes to receive the e-mail.
|
await this.driver.sleep(500); // Simulate the time it takes to receive the e-mail.
|
||||||
const link = await GetLinkFromEmail();
|
const link = await GetLinkFromEmail();
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import FillLoginPageWithUserAndPasswordAndClick from '../../../helpers/FillLoginPageAndClick';
|
import FillLoginPageWithUserAndPasswordAndClick from '../../../helpers/FillLoginPageAndClick';
|
||||||
import WaitRedirected from '../../../helpers/WaitRedirected';
|
|
||||||
import ValidateTotp from '../../../helpers/ValidateTotp';
|
import ValidateTotp from '../../../helpers/ValidateTotp';
|
||||||
import VerifySecretObserved from "../../../helpers/assertions/VerifySecretObserved";
|
import VerifySecretObserved from "../../../helpers/assertions/VerifySecretObserved";
|
||||||
import LoginAndRegisterTotp from '../../../helpers/LoginAndRegisterTotp';
|
import LoginAndRegisterTotp from '../../../helpers/LoginAndRegisterTotp';
|
||||||
import { AUTHENTICATION_TOTP_FAILED } from '../../../../shared/UserMessages';
|
import { AUTHENTICATION_TOTP_FAILED } from '../../../../shared/UserMessages';
|
||||||
import VisitPageAndWaitUrlIs from '../../../helpers/behaviors/VisitPageAndWaitUrlIs';
|
import VisitPageAndWaitUrlIs from '../../../helpers/behaviors/VisitPageAndWaitUrlIs';
|
||||||
import VerifyNotificationDisplayed from '../../../helpers/assertions/VerifyNotificationDisplayed';
|
import VerifyNotificationDisplayed from '../../../helpers/assertions/VerifyNotificationDisplayed';
|
||||||
|
import VerifyUrlIs from '../../../helpers/assertions/VerifyUrlIs';
|
||||||
|
|
||||||
export default function() {
|
export default function() {
|
||||||
/**
|
/**
|
||||||
|
@ -21,7 +21,7 @@ export default function() {
|
||||||
await VisitPageAndWaitUrlIs(this.driver, "https://login.example.com:8080/?rd=https://admin.example.com:8080/secret.html");
|
await VisitPageAndWaitUrlIs(this.driver, "https://login.example.com:8080/?rd=https://admin.example.com:8080/secret.html");
|
||||||
await FillLoginPageWithUserAndPasswordAndClick(this.driver, 'john', 'password');
|
await FillLoginPageWithUserAndPasswordAndClick(this.driver, 'john', 'password');
|
||||||
await ValidateTotp(this.driver, secret);
|
await ValidateTotp(this.driver, secret);
|
||||||
await WaitRedirected(this.driver, "https://admin.example.com:8080/secret.html");
|
await VerifyUrlIs(this.driver, "https://admin.example.com:8080/secret.html");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should access the secret", async function() {
|
it("should access the secret", async function() {
|
||||||
|
|
Loading…
Reference in New Issue