This project includes integration tests that run against a real Contrast TeamServer instance.
-
Copy the environment template:
cp .env.integration-test.template .env.integration-test
-
Fill in your Contrast credentials: Edit
.env.integration-testwith your actual credentials:CONTRAST_HOST_NAME- Your TeamServer host (e.g.,app.contrastsecurity.com)CONTRAST_API_KEY- Your API keyCONTRAST_SERVICE_KEY- Your service keyCONTRAST_USERNAME- Your usernameCONTRAST_ORG_ID- Your organization ID
That's it. Gradle sources .env.integration-test itself; no source step is needed. Real environment variables override file values, so CI secrets and one-off shells win without editing the file.
The library integration tests require at least one application whose libraries contain all of the following:
- A populated vulnerabilities array
- A vulnerability whose name starts with
CVE- - Actively used classes (
classesUsed > 0)
Discovery queries /ng/{orgId}/libraries/filter across the organization with
quickFilter=VULNERABLE and expand=vulns,apps, then confirms candidate data through the
application-scoped library endpoint.
Discovery responses are cached under contrast-mcp-stdio-app/test-cache/. Use these controls when
troubleshooting changing seed data:
CONTRAST_TEST_CACHE_DISABLE=truedisables the disk cache.CONTRAST_TEST_CACHE_CLEAR=trueclears cached entries before the next run.CONTRAST_TEST_CACHE_TTL_HOURS=Noverrides the cache lifetime (default 12 hours).
If discovery reports requires seeded app with vulnerable CVE — see INTEGRATION_TESTS.md, seed the
organization with a qualifying application. Editing or weakening the tests does not fix this
missing-data precondition.
make verify./gradlew :contrast-mcp-stdio-app:integrationTest./gradlew test- Unit tests (
*Test.java) run with the Gradletesttask - Integration tests (
*IT.java) run with the Gradle:contrast-mcp-stdio-app:integrationTesttask - Credentials resolve from real environment variables first, then
.env.integration-test verifyfails loudly when no credentials are available (ADR 0004) — a verify that ran zero integration tests has not verified- Bare
integrationTestskips instead whenCONTRAST_HOST_NAMEis unset, so forks and credential-less checkouts still build
For GitHub Actions, add these secrets to your repository:
CONTRAST_HOST_NAMECONTRAST_API_KEYCONTRAST_SERVICE_KEYCONTRAST_USERNAMECONTRAST_ORG_ID
Integration tests run in two CI contexts:
- PR builds (
build.yml): Theintegration-testjob runs on every internal PR (fork PRs are skipped because they have no access to secrets). It runs after thebuildjob passes. - Release builds (
gradle-release.yml): Theverifylifecycle runs integration tests as part of the release validation build.
- Create a new test class in
contrast-mcp-stdio-app/src/test/javawith theITsuffix (e.g.,MyFeatureIT.java) - Annotate with
@EnabledIfEnvironmentVariable(named = "CONTRAST_HOST_NAME", matches = ".+") - Use real Contrast SDK calls (no mocking)
- Run with
./gradlew :contrast-mcp-stdio-app:integrationTestto execute
Integration tests don't run:
- Verify environment variables are set:
echo $CONTRAST_HOST_NAME - Make sure you're running
./gradlew :contrast-mcp-stdio-app:integrationTest(not just./gradlew test) - Check that test class name ends with
IT.java
Tests fail with authentication errors:
- Verify your credentials are correct
- Check that your API key has appropriate permissions
- Ensure your organization ID is correct