Extend integration tests: webhook secrets CRUD + drift report submission/history/deletion

This commit is contained in:
2026-03-02 05:04:11 +00:00
parent c537022fa8
commit aea88065b4

View File

@@ -171,3 +171,34 @@ else
echo -e "${RED}$PASSED/$TOTAL passed ($((TOTAL - PASSED)) failed)${NC}"
exit 1
fi
# ─── P3 Webhook Secrets Management ───
echo -e "\n${YELLOW}P3 Webhook Secrets Management (:3003)${NC}"
resp=$(api PUT 3003 /api/v1/webhooks/secrets "$ALERT_TOKEN" \
-d '{"provider":"datadog","secret":"whsec_test_datadog_secret_123"}')
echo "$resp" | grep -q "success" && check "Register Datadog webhook secret" "pass" || check "Register Datadog webhook secret" "fail"
resp=$(api GET 3003 /api/v1/webhooks/secrets "$ALERT_TOKEN")
echo "$resp" | grep -q "datadog" && check "List webhook secrets" "pass" || check "List webhook secrets" "fail"
code=$(curl -s -o /dev/null -w "%{http_code}" -X DELETE "$(url 3003 /api/v1/webhooks/secrets/datadog)" \
-H "Authorization: Bearer $ALERT_TOKEN")
[ "$code" = "200" ] && check "Delete webhook secret" "pass" || check "Delete webhook secret (HTTP $code)" "fail"
# ─── P2 Drift Report Submission ───
echo -e "\n${YELLOW}P2 Drift Report Submission (:3002)${NC}"
resp=$(api POST 3002 /api/v1/reports "$DRIFT_TOKEN" \
-d '{"stack_name":"vpc-prod","stack_fingerprint":"abc123","state_serial":42,"total_resources":15,"drift_score":12.5,"raw_report":{"drifted_resources":["aws_security_group.main"]}}')
echo "$resp" | grep -q "vpc-prod" && check "Submit drift report" "pass" || check "Submit drift report" "fail"
resp=$(api GET 3002 /api/v1/stacks "$DRIFT_TOKEN")
echo "$resp" | grep -q "vpc-prod" && check "List stacks (has submitted)" "pass" || check "List stacks (has submitted)" "fail"
resp=$(api GET 3002 "/api/v1/stacks/vpc-prod/history" "$DRIFT_TOKEN")
echo "$resp" | grep -q "drift_score" && check "Stack drift history" "pass" || check "Stack drift history" "fail"
code=$(curl -s -o /dev/null -w "%{http_code}" -X DELETE "$(url 3002 /api/v1/stacks/vpc-prod)" \
-H "Authorization: Bearer $DRIFT_TOKEN")
[ "$code" = "200" ] && check "Delete stack" "pass" || check "Delete stack (HTTP $code)" "fail"