2024-03-22 13:02:50 +00:00
|
|
|
import { expect, test } from "@playwright/test";
|
2024-06-12 09:55:14 +00:00
|
|
|
|
|
|
|
import { ADMIN_PASSWORD, ADMIN_USER, DEFAULT_REALM } from "./constants";
|
2024-03-22 13:02:50 +00:00
|
|
|
import { login } from "./login";
|
2024-04-16 15:24:22 +00:00
|
|
|
import { getAdminUrl } from "./utils";
|
2024-03-22 13:02:50 +00:00
|
|
|
|
|
|
|
test.describe("Signing in with referrer link", () => {
|
2024-04-16 15:24:22 +00:00
|
|
|
test("shows a referrer link when a matching client exists", async ({
|
|
|
|
page,
|
|
|
|
}) => {
|
|
|
|
const referrer = "security-admin-console";
|
|
|
|
const referrerUrl = getAdminUrl();
|
|
|
|
const referrerName = "security admin console";
|
|
|
|
|
2024-03-22 13:02:50 +00:00
|
|
|
const queryParams = {
|
2024-04-16 15:24:22 +00:00
|
|
|
referrer,
|
|
|
|
referrer_uri: referrerUrl,
|
2024-03-22 13:02:50 +00:00
|
|
|
};
|
|
|
|
|
2024-04-16 15:24:22 +00:00
|
|
|
await login(page, ADMIN_USER, ADMIN_PASSWORD, DEFAULT_REALM, queryParams);
|
|
|
|
await expect(page.getByTestId("referrer-link")).toContainText(referrerName);
|
2024-03-22 13:02:50 +00:00
|
|
|
|
2024-04-16 15:24:22 +00:00
|
|
|
// Navigate around to ensure the referrer is still shown.
|
2024-03-22 13:02:50 +00:00
|
|
|
await page.getByTestId("accountSecurity").click();
|
|
|
|
await expect(page.getByTestId("account-security/signing-in")).toBeVisible();
|
2024-04-16 15:24:22 +00:00
|
|
|
await expect(page.getByTestId("referrer-link")).toContainText(referrerName);
|
2024-03-22 13:02:50 +00:00
|
|
|
});
|
|
|
|
|
2024-04-16 15:24:22 +00:00
|
|
|
test("shows no referrer link when an invalid URL is passed", async ({
|
|
|
|
page,
|
|
|
|
}) => {
|
|
|
|
const referrer = "security-admin-console";
|
|
|
|
const referrerUrl = "http://i-am-not-an-allowed-url.com";
|
|
|
|
|
2024-03-22 13:02:50 +00:00
|
|
|
const queryParams = {
|
2024-04-16 15:24:22 +00:00
|
|
|
referrer,
|
|
|
|
referrer_uri: referrerUrl,
|
2024-03-22 13:02:50 +00:00
|
|
|
};
|
|
|
|
|
2024-04-16 15:24:22 +00:00
|
|
|
await login(page, ADMIN_USER, ADMIN_PASSWORD, DEFAULT_REALM, queryParams);
|
|
|
|
await expect(page.getByText("Manage your basic information")).toBeVisible();
|
2024-03-22 13:02:50 +00:00
|
|
|
await expect(page.getByTestId("referrer-link")).toBeHidden();
|
|
|
|
});
|
|
|
|
});
|