-
-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feature] Added support for password expiration feature #713
Closes #713
- Loading branch information
Showing
18 changed files
with
399 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
OPENWISP_USERS_USER_PASSWORD_EXPIRATION = 1 | ||
OPENWISP_USERS_STAFF_USER_PASSWORD_EXPIRATION = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import {until} from "selenium-webdriver"; | ||
import { | ||
getDriver, | ||
getElementByCss, | ||
urls, | ||
initialData, | ||
initializeData, | ||
tearDown, | ||
successToastSelector, | ||
} from "./utils"; | ||
|
||
describe("Selenium tests for expired password flow />", () => { | ||
let driver; | ||
|
||
beforeAll(async () => { | ||
await initializeData("expiredPassword"); | ||
driver = await getDriver(); | ||
}, 30000); | ||
|
||
afterAll(async () => { | ||
await tearDown(driver); | ||
}); | ||
|
||
it("should force user to change password before captive portal login", async () => { | ||
// login with original password | ||
await driver.get(urls.login); | ||
const data = initialData(); | ||
let username = await getElementByCss(driver, "input#username"); | ||
username.sendKeys(data.expiredPasswordUser.email); | ||
let password = await getElementByCss(driver, "input#password"); | ||
password.sendKeys(data.expiredPasswordUser.password); | ||
let submitBtn = await getElementByCss(driver, "input[type=submit]"); | ||
submitBtn.click(); | ||
await driver.wait(until.urlContains("change-password"), 5000); | ||
let successToastDiv = await getElementByCss(driver, "div[role=alert]"); | ||
await driver.wait(until.elementIsVisible(successToastDiv)); | ||
expect(await successToastDiv.getText()).toEqual("Login successful"); | ||
const warningToastMessage = await getElementByCss( | ||
driver, | ||
".Toastify__toast--warning", | ||
); | ||
await driver.wait(until.elementIsVisible(warningToastMessage)); | ||
expect(await warningToastMessage.getText()).toEqual( | ||
"Your password has expired, please update it.", | ||
); | ||
|
||
// Try visiting the status page, but the user should redirected | ||
// back to change password page | ||
await driver.get(urls.status); | ||
await driver.wait(until.urlContains("change-password"), 5000); | ||
|
||
// changing password | ||
await getElementByCss(driver, "div#password-change"); | ||
const currPassword = await getElementByCss( | ||
driver, | ||
"input#current-password", | ||
); | ||
currPassword.sendKeys(data.expiredPasswordUser.password); | ||
const newPassword = "newPassword@"; | ||
const changePassword = await getElementByCss(driver, "input#new-password"); | ||
changePassword.sendKeys(newPassword); | ||
const changePasswordConfirm = await getElementByCss( | ||
driver, | ||
"input#password-confirm", | ||
); | ||
changePasswordConfirm.sendKeys(newPassword); | ||
submitBtn = await getElementByCss(driver, "input[type=submit]"); | ||
submitBtn.click(); | ||
await getElementByCss(driver, "div#status"); | ||
successToastDiv = await getElementByCss(driver, successToastSelector); | ||
await driver.wait(until.elementIsVisible(successToastDiv)); | ||
expect(await successToastDiv.getText()).toEqual( | ||
"Password updated successfully", | ||
); | ||
|
||
// login with new password | ||
await driver.manage().deleteAllCookies(); | ||
await driver.get(urls.login); | ||
await driver.wait(until.urlContains("login"), 5000); | ||
username = await getElementByCss(driver, "input#username"); | ||
username.sendKeys(data.expiredPasswordUser.email); | ||
password = await getElementByCss(driver, "input#password"); | ||
password.sendKeys(newPassword); | ||
submitBtn = await getElementByCss(driver, "input[type=submit]"); | ||
submitBtn.click(); | ||
await getElementByCss(driver, "div#status"); | ||
successToastDiv = await getElementByCss(driver, "div[role=alert]"); | ||
await driver.wait(until.elementIsVisible(successToastDiv)); | ||
expect(await successToastDiv.getText()).toEqual("Login successful"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,11 @@ | |
"password": "testuser", | ||
"organization": "default" | ||
}, | ||
"expiredPasswordUser": { | ||
"email": "[email protected]", | ||
"password": "testuser", | ||
"organization": "default" | ||
}, | ||
"mobileVerificationTestUser": { | ||
"phoneNumber": "+911234567890", | ||
"password": "testuser", | ||
|
144 changes: 144 additions & 0 deletions
144
client/components/password-change/__snapshots__/password-change.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.