Skip to Content
AgentShield
Contributing

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 lint

Suites

SuiteCommandCovers
Gogo 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 contractspython -m unittest discover -s tests -vRequired tables and documents, OpenAPI paths, migration packaging, sample signing, SDK and integration behavior
Intelligence enginePYTHONPATH=apps/intelligence-engine python -m unittest discover -s apps/intelligence-engine/tests -vAttack and benign corpora, limits, HTTP handling, metrics
Nodenpm testControl plane configuration, policy documents, health, member rules, audit chain, mailer; dashboard proxy guard, permissions, policy drafts, invite tokens; TypeScript SDK JSON, signing, client

Lint

CheckCommand
Go formattingtest -z "$(gofmt -l runtime)"
Pythonpython -m ruff check apps/intelligence-engine tests sdk/python integrations examples/sample-agent benchmarks
TypeScriptnpm 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 -d

Control 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 -v

CI 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.py

Compare 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:links

What CI runs

JobChecks
goGo tests; benchmarks still run
pythonRepository and intelligence tests; Ruff; the analyzer benchmark still runs
integrationsLangChain and CrewAI installed; fails if their tests skip
nodenpm ci, npm test, npm run lint
containersBuilds 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
kubernetesRenders 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?

On this page