From 201a4a4c566515095c641a4a41431695f332f748 Mon Sep 17 00:00:00 2001 From: Louis Chemineau Date: Wed, 4 Dec 2024 16:50:06 +0100 Subject: [PATCH] feat: Send Origin header in login request This is need as the server is now checking that header too: https://github.com/nextcloud/server/pull/49560 Signed-off-by: Louis Chemineau --- lib/commands/sessions.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/commands/sessions.ts b/lib/commands/sessions.ts index ddbf91e8..9a8cdbfb 100644 --- a/lib/commands/sessions.ts +++ b/lib/commands/sessions.ts @@ -8,7 +8,7 @@ import type { User } from "./users" /** * You should always upload files and/or create users * before login, so that the cookies are NOT YET defined. - * + * * @see https://docs.cypress.io/api/commands/session */ export const login = function(user: User) { @@ -18,13 +18,15 @@ export const login = function(user: User) { cy.request({ method: 'POST', url: '/login', - body: { - user: user.userId, - password: user.password, + body: { + user: user.userId, + password: user.password, requesttoken: requestToken }, headers: { 'Content-Type': 'application/x-www-form-urlencoded', + // Add the Origin header so that the request is not blocked by the browser. + 'Origin': (Cypress.config('baseUrl') ?? '').replace('index.php/', ''), }, followRedirect: false, })