Repository navigation
[feature] Enhance the captive-portal upgrade experience #1145 #1147 #1146
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
Merged
Merged
Changes from all commits
Commits
Show all changes
57 commits
Select commit
Hold shift + click to select a range
73b7008
[fix] Show payment failure page for plan-upgrade payments #1145
pandafy a442348
[fix] Fixes by @coderabbita
pandafy fe33f6e
[fix] Fixes by @coderabbitai
pandafy dd7d661
[fix] Perform captive portal login when user upgrades to paid plan #1147
pandafy 4461cba
[change] Added flow for cancelling an ongoing upgrade
pandafy 5356460
[feature] Added captive_portal_supports_coa flag
pandafy 04b9cc5
[fix] Fixed captive portal login flow
pandafy 2fe11cc
[fix] Refresh radius token before attempting upgrade
pandafy 765d828
[change] Logout user from captive portal when upgrade is abandoned
pandafy a5f64ed
[fix] Fixed redirect to login after captive portal login
pandafy 191e928
[fix] Payment retry should re-login the user to captive portal
pandafy 2b1da49
[fix] Fixed bugs
pandafy dc31152
[chores] Fixed test suite
pandafy ae3a8eb
[fix] Fixed bugs
pandafy f198f60
[fix] Added handling for non-destructive authMessage
pandafy 3e96b32
[fix] Don't hide loaded on status page for authMessage
pandafy fafcc69
Merge remote-tracking branch 'origin/master' into fix-payment-failed-…
pandafy e7b2e94
[feature] Support `?next=` query param in the login url
pandafy 9f6b7c7
[qa] Fixed docs formatting
pandafy 21aae2e
[feature] Added aliases for query params
pandafy ea19528
[tests] Added browser tests for login continuation and sync auth
pandafy 3492e3d
[feature] Added copyable payment link to /payment/draft
pandafy 8cefe1a
[fix] Added payment return URL handling
pandafy 6e82900
[fix] Fixed browser tests
pandafy 1154b8e
[fix] Fixes by @coderabbitai
pandafy 44841d9
[change] Improved copyable payment link
pandafy a949781
[feature] Allowed users to select the payment gateway
pandafy 0b56799
[qa] Fixed qa errors
pandafy 2dffad6
[tests] Fixed failing tests
pandafy fded425
[fix] Allow user to abandom upgrade from payment gateway selection
pandafy 6ae1194
[change] Udpated /payment/draft message
pandafy 8f31b1a
[fix] Fixed failing tests
pandafy a4f22e4
[qa] Fixed qa issues
pandafy 1daa1a3
[fix] Fixes from review of GPT 6.1 Astra
pandafy edcb8de
[fix] Don't remove loader when users comes back from sync auth login
pandafy 10e1950
[fix] Login user to captive portal after successful payment
pandafy cb303ba
[fix] Restore internet for payment with iframe and without internet
pandafy b3d85be
Merge branch 'master' into fix-payment-failed-redirect
pandafy 37909ec
[fix] Fixed captive portal re-login
pandafy 8c3af09
[fix] Handle payment cancellation
pandafy 928c3ad
[chores] Updated message for cancel button
pandafy 9391300
[fix] Restored captive portal access after payment
pandafy 2a33c37
[chores] Fixed browser tests
pandafy 1b815a0
[fix] Fixes by @coderabbitai
pandafy 34a8de6
[chores] Added prefix to the captive portal logout form fields
pandafy cc9d312
[tests] Fixed browser tests
pandafy da623c9
[change] Don't enable internet mode when sycn auth is enabled
pandafy fad50a0
[fix] Fixes by @coderabbitai
pandafy d03788e
[fix] Removed blank lines and de-slopification
pandafy ca3468d
[chores] Addressed review feedback
pandafy 871eb07
[chores] Addressed review feedback
pandafy bc57c12
[chores] Addressed review feedback
pandafy 762c80e
[fix] Fixes by @coderabbitai
pandafy f6a9257
[fix] Fixes by @coderabbitai
pandafy d0d61f2
[fix] Fixes by @coderabbitai
pandafy 4d2a2fd
Merge branch 'master' into fix-payment-failed-redirect
pandafy e0f267d
[ci] Fixes by @coderabbitai
pandafy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,122 @@ | ||
| import {until} from "selenium-webdriver"; | ||
| import { | ||
| baseUrl, | ||
| getDriver, | ||
| getElementByCss, | ||
| urls, | ||
| initialData, | ||
| initializeData, | ||
| tearDown, | ||
| successToastSelector, | ||
| } from "./utils"; | ||
|
|
||
| // The marker is lost only when the browser leaves the single page app, | ||
| // which proves the captive portal form was submitted in the top-level window. | ||
| const setMarker = (driver) => | ||
| driver.executeScript("window.syncAuthMarker = true"); | ||
| const waitForMarkerLoss = (driver) => | ||
| driver.wait( | ||
| async () => !(await driver.executeScript("return window.syncAuthMarker")), | ||
| 10000, | ||
| ); | ||
|
|
||
| describe("Selenium tests for synchronous captive portal authentication", () => { | ||
| let driver; | ||
|
|
||
| beforeAll(async () => { | ||
| await initializeData("syncAuth"); | ||
| driver = await getDriver(); | ||
| }, 30000); | ||
|
|
||
| afterAll(async () => { | ||
| await tearDown(driver); | ||
| }); | ||
|
|
||
| it("should login and logout through the captive portal in the top-level window", async () => { | ||
| const data = initialData().syncAuthTestUser; | ||
| const loginUrl = urls.verificationLogin(data.organization); | ||
| await driver.get(loginUrl); | ||
| await setMarker(driver); | ||
| const username = await getElementByCss(driver, "input#username"); | ||
| await username.sendKeys(data.email); | ||
| const password = await getElementByCss(driver, "input#password"); | ||
| await password.sendKeys(data.password); | ||
| const submitBtn = await getElementByCss(driver, "input[type=submit]"); | ||
| await submitBtn.click(); | ||
| await waitForMarkerLoss(driver); | ||
| await driver.wait( | ||
| until.urlIs(`${baseUrl}/${data.organization}/status`), | ||
| 10000, | ||
| ); | ||
| const loginForm = await getElementByCss(driver, "#cp-login-form"); | ||
| expect(await loginForm.getAttribute("target")).toEqual("_self"); | ||
| const loginRedirect = await getElementByCss( | ||
| driver, | ||
| "#cp-login-form input[name=redirurl]", | ||
| ); | ||
| expect(await loginRedirect.getAttribute("value")).toEqual( | ||
| `${baseUrl}/${data.organization}/status`, | ||
| ); | ||
| const emailElement = await getElementByCss( | ||
| driver, | ||
| "#status .main-column > .inner > p:nth-child(5) > span", | ||
| ); | ||
| await driver.wait(until.elementTextIs(emailElement, data.email)); | ||
| // the active session is created by the captive portal mock login view | ||
| const activeSessionTr = await getElementByCss( | ||
| driver, | ||
| "table tr.active-session", | ||
| ); | ||
| await driver.wait(until.elementIsVisible(activeSessionTr)); | ||
| const logoutRedirect = await getElementByCss( | ||
| driver, | ||
| "#cp-logout-form input[name=redirurl]", | ||
| ); | ||
| expect(await logoutRedirect.getAttribute("value")).toEqual( | ||
| `${baseUrl}/${data.organization}/status`, | ||
| ); | ||
| await setMarker(driver); | ||
| const logoutBtn = await getElementByCss(driver, ".logout input.button"); | ||
| await logoutBtn.click(); | ||
| const noBtn = await getElementByCss( | ||
| driver, | ||
| ".modal.is-visible .modal-buttons button:nth-child(2)", | ||
| ); | ||
| await driver.wait(until.elementIsVisible(noBtn)); | ||
| await noBtn.click(); | ||
| await waitForMarkerLoss(driver); | ||
| await driver.wait(until.urlIs(loginUrl), 10000); | ||
| const successToastDiv = await getElementByCss(driver, successToastSelector); | ||
| await driver.wait(until.elementIsVisible(successToastDiv)); | ||
| expect(await successToastDiv.getText()).toEqual("Logout successful"); | ||
| }); | ||
|
|
||
| it("should follow the login continuation after the captive portal redirect", async () => { | ||
| const data = initialData().syncAuthTestUser; | ||
| const destination = `/${data.organization}/change-password`; | ||
| await driver.get( | ||
| `${urls.verificationLogin(data.organization)}?${new URLSearchParams({next: destination})}`, | ||
| ); | ||
| const username = await getElementByCss(driver, "input#username"); | ||
| await username.sendKeys(data.email); | ||
| const password = await getElementByCss(driver, "input#password"); | ||
| await password.sendKeys(data.password); | ||
| await setMarker(driver); | ||
| const submitBtn = await getElementByCss(driver, "input[type=submit]"); | ||
| await submitBtn.click(); | ||
| await waitForMarkerLoss(driver); | ||
| await driver.wait(until.urlIs(`${baseUrl}${destination}`), 10000); | ||
| await getElementByCss(driver, "#password-change"); | ||
| expect( | ||
| await driver.executeScript( | ||
| "return window.sessionStorage.getItem('ow_continuation');", | ||
| ), | ||
| ).toEqual(null); | ||
| await driver.get(`${baseUrl}/${data.organization}/status`); | ||
| const activeSessionTr = await getElementByCss( | ||
| driver, | ||
| "table tr.active-session", | ||
| ); | ||
| await driver.wait(until.elementIsVisible(activeSessionTr)); | ||
| }); | ||
| }); |
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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,90 @@ | ||
| /* eslint-disable camelcase */ | ||
| const child_process = require("child_process"); | ||
| const path = require("path"); | ||
| const fs = require("fs"); | ||
| const yaml = require("js-yaml"); | ||
| const data = require("./testData.json"); | ||
|
|
||
| const writeOutput = (result) => { | ||
| if (result.stdout) { | ||
| process.stdout.write(`${result.stdout}\n`); | ||
| } | ||
| if (result.stderr) { | ||
| process.stderr.write(`${result.stderr}\n`); | ||
| } | ||
| if (result.status !== 0) { | ||
| process.exit(result.status); | ||
| } | ||
| }; | ||
|
|
||
| const jsDir = path.resolve(__dirname, "../organizations/js"); | ||
|
|
||
| const createOrganization = (org, extraOptions, editConfig) => { | ||
| const configDirPath = path.resolve(__dirname, `../organizations/${org}`); | ||
| const configPath = path.join(configDirPath, `${org}.yml`); | ||
| if (fs.existsSync(configDirPath)) { | ||
| fs.rmSync(configDirPath, {recursive: true}); | ||
| } | ||
| const options = { | ||
| name: org, | ||
| slug: org, | ||
| uuid: "organization_uuid", | ||
| secret_key: "organization_secret_key", | ||
| mobile_phone_verification: false, | ||
| subscriptions: false, | ||
| login_action_url: "http://localhost:8000/captive-portal-mock/login/", | ||
| logout_action_url: "http://localhost:8000/captive-portal-mock/logout/", | ||
| logout_by_session_ID: true, | ||
| remember_me: true, | ||
| openwisp_radius_url: "http://127.0.0.1:8000", | ||
| assets_confirm: true, | ||
| ...extraOptions, | ||
| }; | ||
| const result = child_process.spawnSync("yarn", [ | ||
| "add-org", | ||
| "--noprompt", | ||
| JSON.stringify(options), | ||
| ]); | ||
| writeOutput(result); | ||
| const content = yaml.load(fs.readFileSync(configPath, "utf8")); | ||
| editConfig(content, options); | ||
| fs.writeFileSync(configPath, yaml.dump(content)); | ||
| }; | ||
|
|
||
| try { | ||
| createOrganization( | ||
| data.mobileVerificationTestUser.organization, | ||
| {mobile_phone_verification: true}, | ||
| (content) => { | ||
| Object.assign(content, {server: {...content.server, timeout: 5}}); | ||
| const {client} = content; | ||
| client.languages = [ | ||
| {text: "english", slug: "en"}, | ||
| {text: "italiano", slug: "it"}, | ||
| ]; | ||
| }, | ||
| ); | ||
| const syncAuthOrg = data.syncAuthTestUser.organization; | ||
| createOrganization(syncAuthOrg, {}, (content, options) => { | ||
| const {components} = content.client; | ||
| // The redirurl host must match the one used by the browser tests, | ||
| // otherwise WLP cookies and localStorage are lost after the redirect. | ||
| const redirurl = () => [ | ||
| {name: "redirurl", value: `http://127.0.0.1:8080/${syncAuthOrg}/status`}, | ||
| ]; | ||
| components.captive_portal_sync_auth = true; | ||
| components.captive_portal_login_form = { | ||
| ...components.captive_portal_login_form, | ||
| additional_fields: redirurl(), | ||
| }; | ||
| components.captive_portal_logout_form = { | ||
| ...components.captive_portal_logout_form, | ||
| action: options.logout_action_url, | ||
| additional_fields: redirurl(), | ||
| }; | ||
| }); | ||
| fs.writeFileSync(path.join(jsDir, data.allOrgScript), ""); | ||
| } catch (err) { | ||
| console.error(err); | ||
| process.exitCode = 1; | ||
| } |
This file contains hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.