Running Tests
Run AgentShield's Go, Python, and Node test suites and linters locally, and understand what CI checks on every change.
Everything at once
make test
make lintSuites
| Suite | Command | Covers |
|---|---|---|
| Go | go test ./runtime/gateway/... ./runtime/identity/... ./runtime/policy-engine/... | Signatures and the shared vector, policy precedence, redaction, the audit hash, gateway decisions, adapters, limits, the relay, the chaos harness |
| Repository contracts | python -m unittest discover -s tests -v | Required tables and documents, OpenAPI paths, migration packaging, sample signing, SDK and integration behavior |
| Intelligence engine | PYTHONPATH=apps/intelligence-engine python -m unittest discover -s apps/intelligence-engine/tests -v | Attack and benign corpora, limits, HTTP handling, metrics |
| Node | npm test | Control plane configuration, policy documents, health, member rules, audit chain, mailer; dashboard proxy guard, permissions, policy drafts, invite tokens; TypeScript SDK JSON, signing, client |
Lint
| Check | Command |
|---|---|
| Go formatting | test -z "$(gofmt -l runtime)" |
| Python | python -m ruff check apps/intelligence-engine tests sdk/python integrations examples/sample-agent benchmarks |
| TypeScript | npm run lint (tsc --noEmit per workspace) |
Tests that need services
Some suites exercise real PostgreSQL behavior, such as the audit-insert rollback, the control plane's integration flows, and the relay. Start the data services first:
docker compose up -dControl plane integration specs (phase*.integration.spec.ts) run when PostgreSQL is reachable. The Go store and relay tests use AGENTSHIELD_TEST_DATABASE_URL when set.
Framework integrations
LangChain and CrewAI tests run only when those frameworks are installed:
python -m pip install "langchain-core>=0.3" "crewai>=0.100"
python -m unittest tests.test_langchain_gateway tests.test_crewai_gateway -vCI installs both and fails if their tests are skipped.
Benchmarks
go test -run '^$' -bench . -benchtime 2s -count 5 \
./runtime/gateway/internal/authz/ ./runtime/policy-engine/ ./runtime/identity/
PYTHONPATH=apps/intelligence-engine python benchmarks/analyzer_bench.pyCompare numbers only on the same machine. benchmarks/README.md records the baseline and its conditions.
Documentation site
cd apps/docs
npm run types:check
npm run lint
npm run build
npm run check:linksWhat CI runs
| Job | Checks |
|---|---|
go | Go tests; benchmarks still run |
python | Repository and intelligence tests; Ruff; the analyzer benchmark still runs |
integrations | LangChain and CrewAI installed; fails if their tests skip |
node | npm ci, npm test, npm run lint |
containers | Builds every image, starts the stack, waits for readiness, checks non-root users and read-only filesystems, bootstraps and signs in, verifies Prometheus scrapes and the Grafana dashboard |
kubernetes | Renders both overlays, deploys dev to kind, validates production against the API server, signs in, verifies the analyzer refuses everything but the gateway |
Writing security tests
AgentShield is a security control. For every change to enforcement behavior, add a test that fails if the protection regresses, not only a happy-path test. Examples from the codebase:
- A deny in either document beats an allow in the other.
- A replayed nonce is rejected.
- A failed execution is not run again.
- An approval with a different payload hash is refused.
- A redirect from an allowed host is not followed.
Was this page helpful?