From 1382395cd4dbf925baa144c9f3a6d226023a55d8 Mon Sep 17 00:00:00 2001 From: Marcus Rohrmoser Date: Mon, 16 May 2016 23:36:35 +0200 Subject: [PATCH] clean, add new release, prep for #6 --- .travis.yml | 1 + tests/test-login-fail.sh | 10 +++++----- tests/test-login-ok.sh | 10 +++++----- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6d77ac4..5e49210 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,6 +26,7 @@ env: - GITHUB=shaarli/Shaarli/archive/v0.5.4 - GITHUB=shaarli/Shaarli/archive/v0.6.4 - GITHUB=shaarli/Shaarli/archive/v0.6.5 + - GITHUB=shaarli/Shaarli/archive/v0.7.0 - GITHUB=shaarli/Shaarli/archive/master - GITHUB=shaarli/Shaarli/archive/stable # - GITHUB=mro/Shaarli/archive/feature/thumbnails diff --git a/tests/test-login-fail.sh b/tests/test-login-fail.sh index cb34fa3..7f44dc1 100644 --- a/tests/test-login-fail.sh +++ b/tests/test-login-fail.sh @@ -35,7 +35,7 @@ fetch_token() { --write-out '%{url_effective}' 2>/dev/null) # todo: errmsg=$(xmllint --html --nowarning --xpath 'string(/html[1 = count(*)]/head[1 = count(*)]/script[starts-with(.,"alert(")])' curl.tmp.html) - [ "${errmsg}" = "" ] || assert_fail 107 "error: '${errmsg}'" + assert_equal "" "${errmsg}" 107 "error: '${errmsg}'" echo $(xmllint --html --nowarning --xpath 'string(/html/body//form[@name="loginform"]//input[@name="token"]/@value)' curl.tmp.html) # string(..) http://stackoverflow.com/a/18390404 } @@ -65,7 +65,7 @@ rm curl.* LOCATION="${BASE_URL}/?do=login" TOKEN="$(fetch_token "${LOCATION}")" # the precise length doesn't matter, it just has to be significantly larger than '' -[ $(printf "%s" ${TOKEN} | wc -c) -eq 40 ] || assert_fail 68 "expected TOKEN of 40 characters, but found ${TOKEN} of $(printf "%s" ${TOKEN} | wc -c)" +assert_equal 40 $(printf "%s" ${TOKEN} | wc -c) 68 "found TOKEN=${TOKEN}" echo "POST ${LOCATION}" LOCATION=$(curl --url "${LOCATION}" \ @@ -87,7 +87,7 @@ rm curl.* LOCATION="${BASE_URL}/?do=login" TOKEN="$(fetch_token "${LOCATION}")" # the precise length doesn't matter, it just has to be significantly larger than '' -[ $(printf "%s" ${TOKEN} | wc -c) -eq 40 ] || assert_fail 90 "expected TOKEN of 40 characters, but found ${TOKEN} of $(printf "%s" ${TOKEN} | wc -c)" +assert_equal 40 $(printf "%s" ${TOKEN} | wc -c) 90 "found TOKEN=${TOKEN}" echo "POST ${LOCATION}" LOCATION=$(curl --url "${LOCATION}" \ @@ -109,7 +109,7 @@ rm curl.* LOCATION="${BASE_URL}/?do=login" TOKEN="$(fetch_token "${LOCATION}")" # the precise length doesn't matter, it just has to be significantly larger than '' -[ $(printf "%s" ${TOKEN} | wc -c) -eq 40 ] || assert_fail 112 "expected TOKEN of 40 characters, but found ${TOKEN} of $(printf "%s" ${TOKEN} | wc -c)" +assert_equal 40 $(printf "%s" ${TOKEN} | wc -c) 112 "found TOKEN=${TOKEN}" echo "POST ${LOCATION}" LOCATION=$(curl --url "${LOCATION}" \ @@ -131,4 +131,4 @@ rm curl.* LOCATION="${BASE_URL}/?do=login" TOKEN="$(fetch_token "${LOCATION}")" errmsg=$(xmllint --html --nowarning --xpath 'string(normalize-space(/html/body//*[@id="headerform"]))' curl.tmp.html) -[ "${errmsg}" = "You have been banned from login after too many failed attempts. Try later." ] || assert_fail 134 "error: '${errmsg}'" +assert_equal "You have been banned from login after too many failed attempts. Try later." "${errmsg}" 134 "expected failure" diff --git a/tests/test-login-ok.sh b/tests/test-login-ok.sh index c824560..b631a52 100644 --- a/tests/test-login-ok.sh +++ b/tests/test-login-ok.sh @@ -46,12 +46,12 @@ LOCATION=$(curl --get --url "${BASE_URL}/?do=login" \ --write-out '%{url_effective}' 2>/dev/null) # todo: errmsg=$(xmllint --html --nowarning --xpath 'string(/html[1 = count(*)]/head[1 = count(*)]/script[starts-with(.,"alert(")])' curl.tmp.html) -[ "${errmsg}" = "" ] || assert_fail 107 "error: '${errmsg}'" +assert_equal "" "${errmsg}" 58 "error: '${errmsg}'" TOKEN=$(xmllint --html --nowarning --xpath 'string(/html/body//form[@name="loginform"]//input[@name="token"]/@value)' curl.tmp.html) # string(..) http://stackoverflow.com/a/18390404 # the precise length doesn't matter, it just has to be significantly larger than '' -[ $(printf "%s" ${TOKEN} | wc -c) -eq 40 ] || assert_fail 6 "expected TOKEN of 40 characters, but found ${TOKEN} of $(printf "%s" ${TOKEN} | wc -c)" +assert_equal 40 $(printf "%s" ${TOKEN} | wc -c) 63 "found TOKEN=${TOKEN}" echo "######################################################" echo "## Step 2: follow the redirect, do the login and redirect to ?do=changepasswd " @@ -68,15 +68,15 @@ LOCATION=$(curl --url "${LOCATION}" \ --write-out '%{url_effective}' 2>/dev/null) # todo: errmsg=$(xmllint --html --nowarning --xpath 'string(/html[1 = count(*)]/head[1 = count(*)]/script[starts-with(.,"alert(")])' curl.tmp.html) -[ "${errmsg}" = "" ] || assert_fail 108 "error: '${errmsg}'" -[ "${BASE_URL}/?do=changepasswd" = "${LOCATION}" ] || assert_fail 108 "expected to be redirected to do=changepassword, but got '${LOCATION}'" +assert_equal "" "${errmsg}" 80 "error during login" +assert_equal "${BASE_URL}/?do=changepasswd" "${LOCATION}" 81 "redirect after login" # [ 1 -eq $(xmllint --html --nowarning --xpath "count(/html/body//a[@href = '?do=logout'])" curl.tmp.html 2>/dev/null) ] || assert_fail 13 "I expected a logout link." # check presence of various mandatory form fields: for field in oldpassword setpassword token do - [ $(xmllint --html --nowarning --xpath "count(/html/body//form[@name = 'changepasswordform']//input[@name='${field}'])" curl.tmp.html) -eq 1 ] || assert_fail 8 "expected to have a '${field}'" + assert_equal 1 $(xmllint --html --nowarning --xpath "count(/html/body//form[@name = 'changepasswordform']//input[@name='${field}'])" curl.tmp.html) 88 "expected to have a '${field}'" done -- 2.11.4.GIT