Update forgehook tests for new folder hierarchy
This commit is contained in:
parent
e6830b3eed
commit
66332ae7b1
|
@ -27,7 +27,7 @@ function testVariousScenarios() {
|
||||||
cd forgecheck
|
cd forgecheck
|
||||||
testOrError "bin/test.sh from specs/forgecheck folder" ../../bin/test.sh
|
testOrError "bin/test.sh from specs/forgecheck folder" ../../bin/test.sh
|
||||||
testOrError "forgecheck/test.sh from specs/forgecheck folder with implicit ../../bin/cli" ./test.sh
|
testOrError "forgecheck/test.sh from specs/forgecheck folder with implicit ../../bin/cli" ./test.sh
|
||||||
testOrError "forgecheck/test.sh from specs/forgecheck folder with explicit result from ../../bin.cli" ./test.sh "$(../../bin/cli)"
|
testOrError "forgecheck/test.sh from specs/forgecheck folder with explicit result from ../../bin/cli" ./test.sh "$(../../bin/cli)"
|
||||||
cd tests
|
cd tests
|
||||||
testOrError "bin/test.sh from specs/forgecheck/tests" ../../../bin/test.sh
|
testOrError "bin/test.sh from specs/forgecheck/tests" ../../../bin/test.sh
|
||||||
testOrError "forgecheck/test.sh from specs/forgecheck/tests" ../test.sh
|
testOrError "forgecheck/test.sh from specs/forgecheck/tests" ../test.sh
|
||||||
|
|
|
@ -4,14 +4,14 @@ SCRIPTDIR="$(dirname "$0")"
|
||||||
ORIGDIR="$(pwd)"
|
ORIGDIR="$(pwd)"
|
||||||
cd "$SCRIPTDIR"
|
cd "$SCRIPTDIR"
|
||||||
|
|
||||||
source tests/helper.bash
|
source ../shared/helper.bash
|
||||||
export FORGEHOOK="$(pwd)/tests/mock-forgehook.sh"
|
export FORGEHOOK="$(pwd)/../shared/mock-forgehook.sh"
|
||||||
# TODO: FORGEHOOKNOTIFY is currently unused
|
# TODO: FORGEHOOKNOTIFY is currently unused
|
||||||
export FORGEHOOKNOTIFY=/bin/true
|
export FORGEHOOKNOTIFY=/bin/true
|
||||||
|
|
||||||
|
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
output="$(findBin "$ORIGDIR"/bin/server ../bin/server)"
|
output="$(findBin "$ORIGDIR"/bin/server ../bin/server ../../bin/server)"
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
if [[ "$(echo "$output" | wc -l)" == "1" ]]; then
|
if [[ "$(echo "$output" | wc -l)" == "1" ]]; then
|
||||||
export FIND_SERVER="$output"
|
export FIND_SERVER="$output"
|
||||||
|
@ -43,7 +43,8 @@ if [ -z "$2" ]; then
|
||||||
# Or try build script from ../whck folder (called from this submodule)
|
# Or try build script from ../whck folder (called from this submodule)
|
||||||
output="$(findBin \
|
output="$(findBin \
|
||||||
whck/bin/cli \
|
whck/bin/cli \
|
||||||
../whck/bin/cli
|
../whck/bin/cli \
|
||||||
|
../../whck/bin/cli
|
||||||
)"
|
)"
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
if [[ "$(echo "$output" | wc -l)" == "1" ]]; then
|
if [[ "$(echo "$output" | wc -l)" == "1" ]]; then
|
||||||
|
@ -72,7 +73,7 @@ else
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
bats tests/web/*.bats
|
bats tests/*.bats
|
||||||
status=$?
|
status=$?
|
||||||
|
|
||||||
cd "$ORIGDIR"
|
cd "$ORIGDIR"
|
||||||
|
|
|
@ -2,18 +2,36 @@
|
||||||
|
|
||||||
# If you give first argument it will be a path to already cloned endpoint
|
# If you give first argument it will be a path to already cloned endpoint
|
||||||
|
|
||||||
|
function testOrError() {
|
||||||
|
message="$1"
|
||||||
|
shift
|
||||||
|
bin="$1"
|
||||||
|
shift
|
||||||
|
output="$("$bin" "$@" 2>&1)"
|
||||||
|
if [ ! $? -eq 0 ]; then
|
||||||
|
echo "FAILURE: "$message""
|
||||||
|
echo "$output" | sed 's/^/ /g'
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
echo "SUCCESS: "$message""
|
||||||
|
}
|
||||||
|
|
||||||
# TODO: save exit codes of various tests so we can know how many failed
|
# TODO: save exit codes of various tests so we can know how many failed
|
||||||
function testVariousScenarios() {
|
function testVariousScenarios() {
|
||||||
echo "Running various tests from "$(pwd)""
|
echo "Running various tests from "$(pwd)""
|
||||||
./bin/test.sh || echo "ERROR running from repo"
|
testOrError "bin/test.sh running from repo" bin/test.sh
|
||||||
cd spec
|
cd specs
|
||||||
./test_web.sh || echo "ERROR test_web.sh failed with implicit ../bin/server"
|
testOrError "forgehook/test.sh with implicit ../bin/server" forgehook/test.sh
|
||||||
./test_web.sh "$(../bin/server)" || echo "ERROR test_cli with explicit result from ../bin/server"
|
testOrError "forgehook/test.sh with explicit result from ../bin/server" forgehook/test.sh "$(../bin/server)"
|
||||||
../bin/test.sh || echo "ERROR bin/test.sh failed called from spec submodule"
|
testOrError "test.sh called from specs submodule" ../bin/test.sh
|
||||||
|
cd forgehook
|
||||||
|
testOrError "bin/test.sh from specs/forgehook folder" ../../bin/test.sh
|
||||||
|
testOrError "forgehook/test.sh from specs/forgehook folder with implicit ../../bin/server" ./test.sh
|
||||||
|
testOrError "forgehook/test.sh from specs/forgehook folder with explicit result from ../../bin/server" ./test.sh "$(../../bin/server)"
|
||||||
cd tests
|
cd tests
|
||||||
../../bin/test.sh || echo "ERROR bin/test.sh failed from spec/tests folder"
|
testOrError "bin/test.sh from specs/forgehook/tests" ../../../bin/test.sh
|
||||||
../test_web.sh || echo "ERROR test_web.sh failed from spec/tests folder with implicit ../../bin/server"
|
testOrError "forgehook/test.sh from specs/forgehook/tests" ../test.sh
|
||||||
../test_web.sh "$(../../bin/server)" || echo "ERROR test_web.sh failed from spec/tests folder with explicit result from ../../bin/server"
|
testOrError "forgehook/test.sh from specs/forgehook/tests folder with explicit result from ../../../bin/server" ../test.sh "$(../../../bin/server)"
|
||||||
}
|
}
|
||||||
|
|
||||||
ORIGDIR="$(pwd)"
|
ORIGDIR="$(pwd)"
|
||||||
|
@ -24,6 +42,9 @@ if [ -z "$1" ]; then
|
||||||
elif [ -x ../bin/server ]; then
|
elif [ -x ../bin/server ]; then
|
||||||
cd ..
|
cd ..
|
||||||
testVariousScenarios
|
testVariousScenarios
|
||||||
|
elif [ -x ../../bin/server ]; then
|
||||||
|
cd ../..
|
||||||
|
testVariousScenarios
|
||||||
else
|
else
|
||||||
TMPDIR="$(mktemp -d)"
|
TMPDIR="$(mktemp -d)"
|
||||||
cd "$TMPDIR"
|
cd "$TMPDIR"
|
||||||
|
@ -43,3 +64,5 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd "$ORIGDIR"
|
cd "$ORIGDIR"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
function setup {
|
function setup {
|
||||||
# Load helper functions
|
# Load helper functions
|
||||||
load ../helper
|
load ../../shared/helper
|
||||||
# Which forgehook implementation to use?
|
# Which forgehook implementation to use?
|
||||||
if [ -z "$FORGEHOOK" ]; then FORGEHOOK="forgehook"; fi
|
if [ -z "$FORGEHOOK" ]; then FORGEHOOK="forgehook"; fi
|
||||||
port=$(find_free_port)
|
port=$(find_free_port)
|
||||||
|
@ -30,7 +30,7 @@ function teardown {
|
||||||
@test "gitea: correct signature works" {
|
@test "gitea: correct signature works" {
|
||||||
repo="https://tildegit.org/forge/hook.sh"
|
repo="https://tildegit.org/forge/hook.sh"
|
||||||
id="$(echo -n "$repo" | base64)"
|
id="$(echo -n "$repo" | base64)"
|
||||||
webhook="$(gen_webhook ../gitea.json "$repo")"
|
webhook="$(gen_webhook ../../shared/gitea.json "$repo")"
|
||||||
secret="$($FORGEHOOK secret $repo)"
|
secret="$($FORGEHOOK secret $repo)"
|
||||||
echo -n "$secret" > "$WHCK_DIR"/"$id"
|
echo -n "$secret" > "$WHCK_DIR"/"$id"
|
||||||
sig="$(hash_hmac sha256 "$webhook" "$secret")"
|
sig="$(hash_hmac sha256 "$webhook" "$secret")"
|
||||||
|
@ -43,7 +43,7 @@ function teardown {
|
||||||
@test "gitea: incorrect signature fails" {
|
@test "gitea: incorrect signature fails" {
|
||||||
repo="https://tildegit.org/forge/hook.sh"
|
repo="https://tildegit.org/forge/hook.sh"
|
||||||
id="$(echo -n "$repo" | base64)"
|
id="$(echo -n "$repo" | base64)"
|
||||||
webhook="$(gen_webhook ../gitea.json "$repo")"
|
webhook="$(gen_webhook ../../shared/gitea.json "$repo")"
|
||||||
# Calculate wrong signature
|
# Calculate wrong signature
|
||||||
secret="$($FORGEHOOK secret $repo)"
|
secret="$($FORGEHOOK secret $repo)"
|
||||||
echo -n "$secret" > "$WHCK_DIR"/"$id"
|
echo -n "$secret" > "$WHCK_DIR"/"$id"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
function setup {
|
function setup {
|
||||||
# Load helper functions
|
# Load helper functions
|
||||||
load ../helper
|
load ../../shared/helper
|
||||||
# Which forgehook implementation to use?
|
# Which forgehook implementation to use?
|
||||||
if [ -z "$FORGEHOOK" ]; then FORGEHOOK="forgehook"; fi
|
if [ -z "$FORGEHOOK" ]; then FORGEHOOK="forgehook"; fi
|
||||||
port=$(find_free_port)
|
port=$(find_free_port)
|
||||||
|
@ -30,7 +30,7 @@ function teardown {
|
||||||
@test "github: correct signature works" {
|
@test "github: correct signature works" {
|
||||||
repo="https://tildegit.org/forge/hook.sh"
|
repo="https://tildegit.org/forge/hook.sh"
|
||||||
id="$(echo -n "$repo" | base64)"
|
id="$(echo -n "$repo" | base64)"
|
||||||
webhook="$(gen_webhook ../github.json "$repo")"
|
webhook="$(gen_webhook ../../shared/github.json "$repo")"
|
||||||
secret="$($FORGEHOOK secret $repo)"
|
secret="$($FORGEHOOK secret $repo)"
|
||||||
echo -n "$secret" > "$WHCK_DIR"/"$id"
|
echo -n "$secret" > "$WHCK_DIR"/"$id"
|
||||||
sig="$(hash_hmac sha256 "$webhook" "$secret")"
|
sig="$(hash_hmac sha256 "$webhook" "$secret")"
|
||||||
|
@ -43,7 +43,7 @@ function teardown {
|
||||||
@test "github: incorrect signature fails" {
|
@test "github: incorrect signature fails" {
|
||||||
repo="https://tildegit.org/forge/hook.sh"
|
repo="https://tildegit.org/forge/hook.sh"
|
||||||
id="$(echo -n "$repo" | base64)"
|
id="$(echo -n "$repo" | base64)"
|
||||||
webhook="$(gen_webhook ../github.json "$repo")"
|
webhook="$(gen_webhook ../../shared/github.json "$repo")"
|
||||||
# Calculate wrong signature
|
# Calculate wrong signature
|
||||||
secret="$($FORGEHOOK secret $repo)"
|
secret="$($FORGEHOOK secret $repo)"
|
||||||
echo -n "$secret" > "$WHCK_DIR"/"$id"
|
echo -n "$secret" > "$WHCK_DIR"/"$id"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
function setup {
|
function setup {
|
||||||
# Load helper functions
|
# Load helper functions
|
||||||
load ../helper
|
load ../../shared/helper
|
||||||
# Which forgehook implementation to use?
|
# Which forgehook implementation to use?
|
||||||
if [ -z "$FORGEHOOK" ]; then FORGEHOOK="forgehook"; fi
|
if [ -z "$FORGEHOOK" ]; then FORGEHOOK="forgehook"; fi
|
||||||
port=$(find_free_port)
|
port=$(find_free_port)
|
||||||
|
@ -30,7 +30,7 @@ function teardown {
|
||||||
@test "gitlab: correct signature works" {
|
@test "gitlab: correct signature works" {
|
||||||
repo="https://tildegit.org/forge/hook.sh"
|
repo="https://tildegit.org/forge/hook.sh"
|
||||||
id="$(echo -n "$repo" | base64)"
|
id="$(echo -n "$repo" | base64)"
|
||||||
webhook="$(gen_webhook ../gitlab.json "$repo")"
|
webhook="$(gen_webhook ../../shared/gitlab.json "$repo")"
|
||||||
secret="$($FORGEHOOK secret $repo)"
|
secret="$($FORGEHOOK secret $repo)"
|
||||||
echo -n "$secret" > "$WHCK_DIR"/"$id"
|
echo -n "$secret" > "$WHCK_DIR"/"$id"
|
||||||
sig="$secret"
|
sig="$secret"
|
||||||
|
@ -43,7 +43,7 @@ function teardown {
|
||||||
@test "gitlab: incorrect signature fails" {
|
@test "gitlab: incorrect signature fails" {
|
||||||
repo="https://tildegit.org/forge/hook.sh"
|
repo="https://tildegit.org/forge/hook.sh"
|
||||||
id="$(echo -n "$repo" | base64)"
|
id="$(echo -n "$repo" | base64)"
|
||||||
webhook="$(gen_webhook ../gitlab.json "$repo")"
|
webhook="$(gen_webhook ../../shared/gitlab.json "$repo")"
|
||||||
# Calculate wrong signature
|
# Calculate wrong signature
|
||||||
secret="$($FORGEHOOK secret $repo)"
|
secret="$($FORGEHOOK secret $repo)"
|
||||||
echo -n "$secret" > "$WHCK_DIR"/"$id"
|
echo -n "$secret" > "$WHCK_DIR"/"$id"
|
||||||
|
|
Loading…
Reference in New Issue