Skip to content

test(ci): assert status codes and response shape for /webhook/manual in integration job - #107

Merged
OkiriGabriel merged 1 commit into
open-devops-agent:mainfrom
OpeyemiAdeniji:ci/assert-webhook-responses
Oct 22, 2026
Merged

OkiriGabriel merged 1 commit into
open-devops-agent:mainfrom
OpeyemiAdeniji:ci/assert-webhook-responses

Conversation

@OpeyemiAdeniji

@OpeyemiAdeniji OpeyemiAdeniji commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Description

The integration job posted incidents to /webhook/manual with || echo "Expected to fail gracefully without real API key". curl exits 0 on HTTP 4xx/5xx unless -f is given, so those steps could only fail if the connection itself failed; they never checked what the server returned.

Each webhook step now captures the HTTP status and body and asserts:

  • k8s, cicd and argocd incidents: HTTP 200, status == "queued", a non-empty string incident_id, context.type equal to the type sent, and context.source == "manual"
  • missing type: HTTP 400 with 'type' field required
  • invalid JSON: HTTP 400 with JSON object required

On a mismatch the step exits non-zero and prints the status code and body, so failures are debuggable from the CI log.

Part of #18 (this covers /webhook/manual only; it does not close the issue)

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Performance improvement
  • Code refactoring
  • New platform/collector support

CI configuration change (none of the listed types fit).

Platform/Component

  • Core Agent
  • Kubernetes
  • CI/CD (specify: GitHub Actions workflow, integration-test job)
  • Cloud Provider
  • ArgoCD
  • Docker
  • API Server
  • Tools/Executor
  • Documentation
  • Tests

Testing

  • Unit tests added/updated

  • Integration tests pass

  • Manual testing performed

  • Tested with dummy data

  • Tested in production-like environment

  • Probed the real /webhook/manual route in-process with FastAPI's TestClient: no server and no queue worker started, in-memory storage, WEBHOOK_SECRET unset, DevOpsAgent and SlackNotifier patched, .env loading disabled. Results: the three incident types returned 200 with status: "queued", an INC-... incident_id and the echoed context (source: "manual"); a missing type returned 400 'type' field required; invalid JSON returned 400 JSON object required.

  • Parsed the workflow with yaml.safe_load and ran bash -n on each new run: script.

  • jq isn't installed on my machine, so I evaluated the same conditions in Python against the captured responses locally.

  • CI result on this PR: all 10 checks pass, including the integration job running the new jq assertions against the live server.

  • Full test suite locally (Windows): 436 passed, 2 skipped, 1 failed. The failure is tests/test_nginx_bamboo.py::TestNginxTools::test_write_file_command_prevents_shell_expansion, which shells out to python3; that isn't on my Windows PATH (sh: python3: command not found). It is unrelated to this workflow-only change, and the Test Agent jobs in CI run it on Linux.

Test Configuration

OS: Windows (Git Bash)
Python Version: 3.12.10 (CI integration job uses 3.10)
Kubernetes Version: N/A
Cloud Provider: N/A

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas (N/A)
  • I have made corresponding changes to the documentation (N/A)
  • My changes generate no new warnings (N/A: workflow-only change)
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes (436 passed, 2 skipped; 1 Windows-only failure unrelated to this change, see Testing)
  • Any dependent changes have been merged and published

Screenshots (if applicable)

N/A

Breaking Changes

None to the application. In CI, a change to the status code or body shape of /webhook/manual will now fail the integration job. #64 (fail-closed webhook defaults) will need to update these steps when it lands.

Additional Notes

  • Scope: only /webhook/manual is asserted here. /webhook/github, /alertmanager, /grafana, /gitlab and /bitbucket are not covered yet; happy to follow up with those if you'd like.
  • The Audit step is unchanged.
  • Black, Safety and coverage are untouched; waiting on the answers in Make CI lint and security scans fail the build #18.

Reviewer Checklist

  • Code quality is acceptable
  • Tests are comprehensive
  • Documentation is updated
  • No security concerns
  • Performance impact is acceptable

The integration job posted incidents to /webhook/manual with
`|| echo "Expected to fail gracefully"`. curl exits 0 on HTTP 4xx/5xx
unless -f is given, so those steps could only fail on a connection
error and never checked what the server returned.

Capture the HTTP status and body for each request and assert:
- k8s, cicd and argocd incidents: 200, status "queued", a non-empty
  incident_id, and the echoed context (type as sent, source "manual")
- missing "type": 400 "'type' field required"
- invalid JSON: 400 "JSON object required"

On a mismatch the step exits non-zero and prints the status and body.
Other /webhook/* routes are not covered yet.

Part of open-devops-agent#18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants