Fix webhook regression: allow -1 to ignore status
This commit is contained in:
parent
66320a6b92
commit
44e94a16b0
|
|
@ -294,8 +294,8 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if *flWebhookURL != "" {
|
if *flWebhookURL != "" {
|
||||||
if *flWebhookStatusSuccess <= 0 {
|
if *flWebhookStatusSuccess < -1 {
|
||||||
fmt.Fprintf(os.Stderr, "ERROR: --webhook-success-status must be greater than 0\n")
|
fmt.Fprintf(os.Stderr, "ERROR: --webhook-success-status must be a valid HTTP code or -1\n")
|
||||||
flag.Usage()
|
flag.Usage()
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
32
test_e2e.sh
32
test_e2e.sh
|
|
@ -658,9 +658,9 @@ assert_file_eq "$ROOT"/link/file "$TESTCASE 1"
|
||||||
pass
|
pass
|
||||||
|
|
||||||
##############################################
|
##############################################
|
||||||
# Test webhook
|
# Test webhook success
|
||||||
##############################################
|
##############################################
|
||||||
testcase "webhook"
|
testcase "webhook-success"
|
||||||
freencport
|
freencport
|
||||||
# First sync
|
# First sync
|
||||||
echo "$TESTCASE 1" > "$REPO"/file
|
echo "$TESTCASE 1" > "$REPO"/file
|
||||||
|
|
@ -671,6 +671,7 @@ GIT_SYNC \
|
||||||
--repo="file://$REPO" \
|
--repo="file://$REPO" \
|
||||||
--root="$ROOT" \
|
--root="$ROOT" \
|
||||||
--webhook-url="http://127.0.0.1:$NCPORT" \
|
--webhook-url="http://127.0.0.1:$NCPORT" \
|
||||||
|
--webhook-success-status=200 \
|
||||||
--dest="link" \
|
--dest="link" \
|
||||||
> "$DIR"/log."$TESTCASE" 2>&1 &
|
> "$DIR"/log."$TESTCASE" 2>&1 &
|
||||||
# check that basic call works
|
# check that basic call works
|
||||||
|
|
@ -700,6 +701,33 @@ fi
|
||||||
# Wrap up
|
# Wrap up
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
##############################################
|
||||||
|
# Test webhook fire-and-forget
|
||||||
|
##############################################
|
||||||
|
testcase "webhook-fire-and-forget"
|
||||||
|
freencport
|
||||||
|
# First sync
|
||||||
|
echo "$TESTCASE 1" > "$REPO"/file
|
||||||
|
git -C "$REPO" commit -qam "$TESTCASE 1"
|
||||||
|
GIT_SYNC \
|
||||||
|
--logtostderr \
|
||||||
|
--v=5 \
|
||||||
|
--repo="file://$REPO" \
|
||||||
|
--root="$ROOT" \
|
||||||
|
--webhook-url="http://127.0.0.1:$NCPORT" \
|
||||||
|
--webhook-success-status=-1 \
|
||||||
|
--dest="link" \
|
||||||
|
> "$DIR"/log."$TESTCASE" 2>&1 &
|
||||||
|
# check that basic call works
|
||||||
|
{ (echo -e "HTTP/1.1 404 Not Found\r\n" | nc -q1 -l $NCPORT > /dev/null) &}
|
||||||
|
NCPID=$!
|
||||||
|
sleep 3
|
||||||
|
if kill -0 $NCPID > /dev/null 2>&1; then
|
||||||
|
fail "webhook 1 not called, server still running"
|
||||||
|
fi
|
||||||
|
# Wrap up
|
||||||
|
pass
|
||||||
|
|
||||||
##############################################
|
##############################################
|
||||||
# Test http handler
|
# Test http handler
|
||||||
##############################################
|
##############################################
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue