Fix subuser auth E2E regressions
This commit is contained in:
@@ -7,6 +7,7 @@ import { isPasskeySupported, authenticateWithPasskey } from "@/services/PasskeyA
|
||||
import TwoFactorVerify from "@/components/forms/auth/TwoFactorVerify.vue";
|
||||
import { clearEdgeGatewayWorkspaceCache } from "@/services/edgeGateways.js";
|
||||
import { unauthenticatedRequest } from "@/components/session/authenticatedRequest.vue";
|
||||
import { getSubuserPasswordPolicyError } from "@/services/subuserPasswordPolicy.js";
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
@@ -39,6 +40,12 @@ const twoFactorToken = ref('');
|
||||
const login = async () => {
|
||||
clearErrors();
|
||||
|
||||
const passwordPolicyError = getSubuserPasswordPolicyError(password.value);
|
||||
if (passwordPolicyError) {
|
||||
addError(passwordPolicyError, 'auth');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
let requestBody = { password: password.value };
|
||||
|
||||
|
||||
@@ -27,6 +27,35 @@ async function primeSession(page, { token, permissions, sessionData = {} }) {
|
||||
await seedAuthenticatedState(page, token);
|
||||
}
|
||||
|
||||
async function mockSelectedSubuserGrant(page, { customerNumber = 12345679, permissions = ["user"] } = {}) {
|
||||
await page.route("**/subusers/me", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
data: {
|
||||
id: 71,
|
||||
username: "driver-user",
|
||||
name: "Driver User",
|
||||
email: "driver@example.test",
|
||||
phone_country_code: 45,
|
||||
phone: 12345678,
|
||||
grants: [
|
||||
{
|
||||
id: 7101,
|
||||
billing_customer_number: customerNumber,
|
||||
permissions,
|
||||
},
|
||||
],
|
||||
created_at: "2026-01-01T00:00:00.000Z",
|
||||
updated_at: "2026-01-01T00:00:00.000Z",
|
||||
suspended_at: null,
|
||||
},
|
||||
}),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function seedGeolocation(context) {
|
||||
await context.grantPermissions(["geolocation"]);
|
||||
await context.setGeolocation({
|
||||
@@ -945,6 +974,7 @@ test.describe("Self-serve wash", () => {
|
||||
},
|
||||
selfServe: true,
|
||||
});
|
||||
await mockSelectedSubuserGrant(page);
|
||||
await primeSession(page, {
|
||||
token: "self-serve-subuser-grant-token",
|
||||
permissions: ["user"],
|
||||
|
||||
@@ -58,8 +58,8 @@ test("[PROFILE][Subuser][Security] logs out and requires re-authentication", asy
|
||||
await expect(logoutDialog).toBeVisible();
|
||||
await logoutDialog.locator(".swal2-confirm").click();
|
||||
|
||||
await expect(page).toHaveURL(/\/login(?:\?.*)?$/);
|
||||
await expect(page.locator('input[name="customer_number"]')).toBeVisible();
|
||||
await expect(page).toHaveURL(/\/login\/driver(?:\?.*)?$/);
|
||||
await expect(page.locator('input[name="phone_country_code"]')).toBeVisible();
|
||||
|
||||
await page.goto("/user/profile");
|
||||
await expect(page).toHaveURL(/\/login(?:\?.*)?$/);
|
||||
|
||||
Reference in New Issue
Block a user