diff --git a/test/hurl/README.md b/test/hurl/README.md index 4591e761ad8..87ba7dfea16 100644 --- a/test/hurl/README.md +++ b/test/hurl/README.md @@ -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 diff --git a/test/hurl/api/setup/10_setup_company.hurl b/test/hurl/api/setup/10_setup_company.hurl index 2b7a29b51bd..469680e4f8a 100644 --- a/test/hurl/api/setup/10_setup_company.hurl +++ b/test/hurl/api/setup/10_setup_company.hurl @@ -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 diff --git a/test/hurl/api/setup/10_setup_conf.hurl b/test/hurl/api/setup/10_setup_conf.hurl index c426fb374fd..bb91bcf1517 100644 --- a/test/hurl/api/setup/10_setup_conf.hurl +++ b/test/hurl/api/setup/10_setup_conf.hurl @@ -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 diff --git a/test/hurl/api/setup/10_setup_modules.hurl b/test/hurl/api/setup/10_setup_modules.hurl index fd8853159f3..00421136acd 100644 --- a/test/hurl/api/setup/10_setup_modules.hurl +++ b/test/hurl/api/setup/10_setup_modules.hurl @@ -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 diff --git a/test/hurl/api/status/00_status.hurl b/test/hurl/api/status/00_status.hurl index 1111c069fcb..00cb9db97ca 100644 --- a/test/hurl/api/status/00_status.hurl +++ b/test/hurl/api/status/00_status.hurl @@ -1,3 +1,3 @@ # Check status -GET http://localhost:8080/api/index.php/status +GET http://{{hostnport}}/api/index.php/status HTTP 401 diff --git a/test/hurl/api/status/10_status.hurl b/test/hurl/api/status/10_status.hurl index 97581435e58..146bcfc1bb3 100644 --- a/test/hurl/api/status/10_status.hurl +++ b/test/hurl/api/status/10_status.hurl @@ -1,3 +1,3 @@ # Check status -GET http://localhost:8080/api/index.php/status +GET http://{{hostnport}}/api/index.php/status HTTP 200 diff --git a/test/hurl/gui/00_HOME.hurl b/test/hurl/gui/00_HOME.hurl index 256758220fd..dda4bb3a46f 100644 --- a/test/hurl/gui/00_HOME.hurl +++ b/test/hurl/gui/00_HOME.hurl @@ -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 "" diff --git a/test/hurl/gui/10_HOME.hurl b/test/hurl/gui/10_HOME.hurl new file mode 100644 index 00000000000..63588c59d5b --- /dev/null +++ b/test/hurl/gui/10_HOME.hurl @@ -0,0 +1,6 @@ +# Check login page +GET http://{{hostnport}}/ +HTTP 200 +[Asserts] +body not contains "Enter login details" +body contains "" diff --git a/test/hurl/gui/comm/mailing/10_mailing.hurl b/test/hurl/gui/comm/mailing/10_mailing.hurl new file mode 100644 index 00000000000..fb77794eddc --- /dev/null +++ b/test/hurl/gui/comm/mailing/10_mailing.hurl @@ -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" diff --git a/test/hurl/gui/save_login_cookie.hurl b/test/hurl/gui/save_login_cookie.hurl new file mode 100644 index 00000000000..1876f4e3d66 --- /dev/null +++ b/test/hurl/gui/save_login_cookie.hurl @@ -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 diff --git a/test/hurl/public/onlinesign/00_onlinesign_newonlinesign.hurl b/test/hurl/public/onlinesign/00_onlinesign_newonlinesign.hurl index db55099d091..a32598eaa6b 100644 --- a/test/hurl/public/onlinesign/00_onlinesign_newonlinesign.hurl +++ b/test/hurl/public/onlinesign/00_onlinesign_newonlinesign.hurl @@ -1,2 +1,2 @@ -GET http://localhost:8080/public/onlinesign/newonlinesign.php +GET http://{{hostnport}}/public/onlinesign/newonlinesign.php HTTP 400 diff --git a/test/hurl/public/payment/00_payment_newpayment.hurl b/test/hurl/public/payment/00_payment_newpayment.hurl index a0a24a4b3b1..48ee2b26d75 100644 --- a/test/hurl/public/payment/00_payment_newpayment.hurl +++ b/test/hurl/public/payment/00_payment_newpayment.hurl @@ -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` diff --git a/test/hurl/run.sh b/test/hurl/run.sh index 4f8c729f31c..dfe3870eb0d 100755 --- a/test/hurl/run.sh +++ b/test/hurl/run.sh @@ -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}" diff --git a/test/hurl/save_login_cookie.sh b/test/hurl/save_login_cookie.sh new file mode 100755 index 00000000000..c18d2426b0f --- /dev/null +++ b/test/hurl/save_login_cookie.sh @@ -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}"