diff --git a/tests/gitea.bats b/tests/gitea.bats index 85e1a48..fc0303c 100644 --- a/tests/gitea.bats +++ b/tests/gitea.bats @@ -28,7 +28,7 @@ function teardown { @test "correct signature works" { repo="https://tildegit.org/forge/hook.sh" - webhook="$(gen_webhook tests/gitea.json "$repo")" + webhook="$(gen_webhook gitea.json "$repo")" sig="$(hash_hmac sha256 "$webhook" "$($FORGEHOOK secret $repo)")" run send_webhook "${FORGEHOOKSRV}?action=gitea" "$webhook" "$sig" "X-Gitea-Signature" [ $status -eq 0 ] @@ -37,7 +37,7 @@ function teardown { @test "incorrect signature fails" { repo="https://tildegit.org/forge/hook.sh" - webhook="$(gen_webhook tests/gitea.json "$repo")" + webhook="$(gen_webhook gitea.json "$repo")" # Calculate wrong signature sig="$(hash_hmac sha256 "EXTRA$webhook" "$($FORGEHOOK secret $repo)")" run send_webhook "${FORGEHOOKSRV}?action=gitea" "$webhook" "$sig" "X-Gitea-Signature" diff --git a/tests/github.bats b/tests/github.bats index 349bdaf..40fe841 100644 --- a/tests/github.bats +++ b/tests/github.bats @@ -28,7 +28,7 @@ function teardown { @test "correct signature works" { repo="https://tildegit.org/forge/hook.sh" - webhook="$(gen_webhook tests/github.json "$repo")" + webhook="$(gen_webhook github.json "$repo")" sig="$(hash_hmac sha256 "$webhook" "$($FORGEHOOK secret $repo)")" run send_webhook "${FORGEHOOKSRV}?action=github" "$webhook" "$sig" "X-Hub-Signature" [ $status -eq 0 ] @@ -37,7 +37,7 @@ function teardown { @test "incorrect signature fails" { repo="https://tildegit.org/forge/hook.sh" - webhook="$(gen_webhook tests/gitea.json "$repo")" + webhook="$(gen_webhook github.json "$repo")" # Calculate wrong signature sig="$(hash_hmac sha256 "EXTRA$webhook" "$($FORGEHOOK secret $repo)")" run send_webhook "${FORGEHOOKSRV}?action=github" "$webhook" "$sig" "X-Hub-Signature" diff --git a/tests/gitlab.bats b/tests/gitlab.bats index d6759f5..1d159db 100644 --- a/tests/gitlab.bats +++ b/tests/gitlab.bats @@ -28,7 +28,7 @@ function teardown { @test "correct token works" { repo="https://tildegit.org/forge/hook.sh" - webhook="$(gen_webhook tests/gitlab.json "$repo")" + webhook="$(gen_webhook gitlab.json "$repo")" run send_webhook "${FORGEHOOKSRV}?action=gitlab" "$webhook" "$($FORGEHOOK secret $repo)" "X-Gitlab-Token" [ $status -eq 0 ] [[ "$output" = "200" ]] @@ -36,7 +36,7 @@ function teardown { @test "incorrect token fails" { repo="https://tildegit.org/forge/hook.sh" - webhook="$(gen_webhook tests/gitlab.json "$repo")" + webhook="$(gen_webhook gitlab.json "$repo")" # Send FAKE token run send_webhook "${FORGEHOOKSRV}?action=gitlab" "$webhook" "FAKE" "X-Gitlab-Token" [ "$status" -eq 2 ] diff --git a/tests/helper.bash b/tests/helper.bash index 7108bc1..57a5b9b 100755 --- a/tests/helper.bash +++ b/tests/helper.bash @@ -12,7 +12,7 @@ function find_free_port { function gen_webhook() { export repo_url="$2" - envsubst < "$1" + envsubst < "$BATS_TEST_DIRNAME"/"$1" } # send_webhook "ENDPOINT" "PAYLOAD" "SECRET" "HEADER"