Load webhook template from bats test dir

This commit is contained in:
southerntofu 2020-09-30 09:10:49 -04:00
parent e81a3b4b25
commit 1693ec91b5
4 changed files with 7 additions and 7 deletions

View File

@ -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"

View File

@ -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"

View File

@ -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 ]

View File

@ -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"