Make hurl tests work on GUI page requiring login (#35652)

* Adding hurl tests to Dolibarr

* modifying run.sh to get it past commit checks

* change the APIHEADER to be read from the environment

* spell fix

* test to see if build system will accept this file

* deleting script method that doesn't work

* beginning to make hurl tests accept environment variables for the location

* Add GUI login to hurl tests

* Fix CI

* clean code (#35640)

* clean code

* clean code

* clean code

* clean code

* clean code

* clean code

* clean code

* clean code

* clean code

* clean code

* clean code

* clean code

* clean code

* clean code

* clean code

* clean code

* Fix warning

* Clean code

* PHPStan > Update baseline (#35644)

Co-authored-by: Dolibot <dolibarr-bot@users.noreply.github.com>

* NEW Can drag and drop in BOM card

* WIP Upload files

* WIP Upload files

* Adding hurl tests to Dolibarr

* using hostnport variable for all remaining tests

* Add some asserts and gui login tests

* double quotes around shell variables

* adding -r to read

* expand mass mail gui test with all 6 columns in the table

---------

Co-authored-by: Jon Bendtsen <xcodeauthor@jonb.dk>
Co-authored-by: ldestailleur <eldy@destailleur.fr>
Co-authored-by: Frédéric FRANCE <frederic34@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Dolibot <dolibarr-bot@users.noreply.github.com>
This commit is contained in:
Jon Bendtsen
2025-10-06 01:38:44 +02:00
committed by GitHub
parent 2da06f9fb1
commit 1cb221efe9
14 changed files with 83 additions and 16 deletions

View File

@@ -72,6 +72,7 @@ DoliStore modules must come with hurl tests.
## Howto Usage
1. Create the .settings/ directory
2. Set these environment variables to know how to authenticate and where to reach your Dolibarr installation
DOLAPIKEY="DOLAPIKEY: _replace_with_your_Dolibarr_Token_for_API_"
@@ -80,7 +81,11 @@ DoliStore modules must come with hurl tests.
DOLIPORT="8080"
DOLISUBURL="/dolibarr" # if you're not just using / and no need to set /
DOLISUBURL="/dolibarr" # if your dolibarr is available at / - no need to set it
DOLIUSERNAME="foobar" # for GUI tests - if omitted, it will ask you
DOLIPASSWORD="topsecret" # for GUI tests - if omitted, it will ask you
3. On Linux and mac execute ./run.sh

View File

@@ -1,5 +1,5 @@
# Check status
GET http://localhost:8080/api/index.php/setup/company
GET http://{{hostnport}}/api/index.php/setup/company
HTTP 200
[Asserts]
jsonpath "$.id" == 0 # Check the value of the id

View File

@@ -1,3 +1,3 @@
# Check status
GET http://localhost:8080/api/index.php/setup/conf
GET http://{{hostnport}}/api/index.php/setup/conf
HTTP 200

View File

@@ -1,5 +1,5 @@
# Check status
GET http://localhost:8080/api/index.php/setup/modules
GET http://{{hostnport}}/api/index.php/setup/modules
HTTP 200
[Asserts]
jsonpath "$" count > 2

View File

@@ -1,3 +1,3 @@
# Check status
GET http://localhost:8080/api/index.php/status
GET http://{{hostnport}}/api/index.php/status
HTTP 401

View File

@@ -1,3 +1,3 @@
# Check status
GET http://localhost:8080/api/index.php/status
GET http://{{hostnport}}/api/index.php/status
HTTP 200

View File

@@ -1,3 +1,6 @@
# Check status
GET http://localhost:8080/
# Check login page
GET http://{{hostnport}}/
HTTP 200
[Asserts]
body contains "Enter login details"
body not contains "<!-- Show logo on menu -->"

View File

@@ -0,0 +1,6 @@
# Check login page
GET http://{{hostnport}}/
HTTP 200
[Asserts]
body not contains "Enter login details"
body contains "<!-- Show logo on menu -->"

View File

@@ -0,0 +1,12 @@
# Check mailing
GET http://{{hostnport}}/comm/mailing/list.php?leftmenu=mailing
HTTP 200
[Asserts]
body not contains "Enter login details"
body contains "Mass EMails"
body contains "Ref."
body contains "Title"
body contains "Creation date"
body contains "No. of EMails"
body contains "Date of latest sending"
body contains "Status"

View File

@@ -0,0 +1,9 @@
# Check status
GET http://{{hostnport}}/
HTTP 200
[Captures]
token: xpath "normalize-space(//meta[@name='anti-csrf-newtoken']/@content)"
# Check status
POST http://{{hostnport}}/index.php?token={{token}}&actionlogin=login&loginfunction=loginfunction&username={{username}}&password={{password}}
HTTP 200

View File

@@ -1,2 +1,2 @@
GET http://localhost:8080/public/onlinesign/newonlinesign.php
GET http://{{hostnport}}/public/onlinesign/newonlinesign.php
HTTP 400

View File

@@ -1,3 +1,3 @@
GET http://localhost:8080/public/payment/newpayment.php
GET http://{{hostnport}}/public/payment/newpayment.php
HTTP 200
`Bad parameters - amount or source`

View File

@@ -24,12 +24,13 @@ if [[ -z ${DOLAPIKEY+x} ]]; then
echo "DOLAPIKEY bash variable is unset, no API tests that require authentication"
else
echo "Now we are ready to run API tests that do require authentication"
find api/ -type f -iname '10*.hurl' -not -iname '00*.hurl' -exec hurl --header "${DOLAPIKEY}" --test "{}" \;
find api/ -type f -iname '10*.hurl' -not -iname '00*.hurl' -exec hurl --variable "hostnport=${hostnport}" --header "${DOLAPIKEY}" --test "{}" \;
fi
if [[ -z ${GUIHEADER+x} ]]; then
echo "GUIHEADER bash variable is unset, no GUI tests that require authentication"
else
echo "Now we are ready to run GUI tests that do require authentication"
find gui/ -type f -iname '10*.hurl' -not -iname '00*.hurl' -exec hurl --header "${GUIHEADER}" --test "{}" \;
./save_login_cookie.sh
if [[ -z ${COOKIEJAR+x} ]]; then
COOKIEJAR=/tmp/cookie.jar
fi
echo "Now we are ready to run GUI tests that do require authentication"
find gui/ -type f -iname '10*.hurl' -not -iname 'save_login_cookie.hurl' -not -iname '00*.hurl' -exec hurl --variable "hostnport=${hostnport}" --cookie "${COOKIEJAR}" --test "{}" \;
rm -rf "${COOKIEJAR}"

31
test/hurl/save_login_cookie.sh Executable file
View File

@@ -0,0 +1,31 @@
#!/bin/bash
if [[ -z ${DOLIHOST+x} ]]; then
DOLIHOST="localhost"
fi
hostnport="${DOLIHOST}"
if [[ -z ${DOLIPORT+x} ]]; then
hostnport="${hostnport}:8080"
else
hostnport="${hostnport}:${DOLIPORT}"
fi
if [[ -z ${DOLISUBURL+x} ]]; then
DOLISUBURL=""
fi
if [[ "" != "${DOLISUBURL}" ]]; then
hostnport="${hostnport}/${DOLISUBURL}"
fi
if [[ -z ${DOLIUSERNAME+x} ]]; then
read -rp "Your Dolibarr Username: " DOLIUSERNAME
fi
if [[ -z ${DOLIPASSWORD+x} ]]; then
read -rsp "Your Dolibarr Password: " DOLIPASSWORD
echo ""
fi
if [[ -z ${COOKIEJAR+x} ]]; then
COOKIEJAR=/tmp/cookie.jar
fi
hurl --variable "hostnport=${hostnport}" --variable "username=${DOLIUSERNAME}" --secret "password=${DOLIPASSWORD}" --test gui/save_login_cookie.hurl --cookie-jar "${COOKIEJAR}"