Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #32 +/- ##
==========================================
+ Coverage 78.22% 78.37% +0.14%
==========================================
Files 27 27
Lines 1208 1216 +8
==========================================
+ Hits 945 953 +8
Misses 223 223
Partials 40 40 ☔ View full report in Codecov by Sentry. |
Implements a WireMock-based mock service to enable development and testing without requiring an actual StackRox Central instance. Features: - Standalone Java-based WireMock service (no Docker required) - gRPC support via WireMock gRPC extension - Token-based authentication validation - Parameter-based response mappings for different CVE queries - Easy-to-edit JSON fixture files - Automated setup scripts for downloading JARs and generating proto descriptors - Make targets for service lifecycle management (start/stop/restart/status/logs) - Comprehensive smoke test suite - CI integration via GitHub Actions Scripts: - scripts/download-wiremock.sh: Download WireMock JARs from Maven Central - scripts/setup-proto-files.sh: Copy proto files from stackrox repo - scripts/generate-proto-descriptors.sh: Generate proto descriptors for gRPC - scripts/start-mock-central.sh: Start WireMock service - scripts/stop-mock-central.sh: Stop WireMock service - scripts/smoke-test-wiremock.sh: Run comprehensive smoke tests Make targets: - make mock-download: Download WireMock JARs - make mock-start/stop/restart: Control service lifecycle - make mock-status: Check service status - make mock-logs: View service logs - make mock-test: Run smoke tests Test scenarios included: - CVE-2021-44228 (Log4j): Returns 3 affected deployments - CVE-2024-1234: Returns 1 custom deployment - Authentication: Validates Bearer tokens (test-token-*) - Empty queries: Returns empty results CI Integration: - Automated smoke tests run on PRs touching WireMock files - Verifies all required files are committed - Tests WireMock setup, authentication, CVE queries, and MCP integration - Uploads logs on failure for debugging Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> # Conflicts: # .gitignore
- Removed file existence checks (unnecessary - tests fail anyway if files missing) - Reduced from 28 tests to 7 focused integration tests - Test flow: setup → start WireMock → test endpoints → verify MCP integration - Added cleanup trap for better resource management - 30 lines shorter and more maintainable Tests now verify: 1. WireMock starts and runs 2. Admin API works 3. Authentication validation works 4. CVE queries return correct data 5. MCP server can connect with WireMock config All 7 tests passing.
- Remove unnecessary comments and verbose logging from all scripts - Simplify README sections and fix outdated smoke test documentation - Update CI workflow to run on all PRs (removed path-based triggers) - Reduce code verbosity while maintaining functionality All smoke tests passing (7/7). Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Replace manual proto file copying from ../stackrox repository with automated
approach using Go mod cache, following the stackrox repository pattern.
Changes:
- Update setup-proto-files.sh to use `go list -f '{{.Dir}}' -m` for module discovery
- Get proto files from github.com/stackrox/rox module
- Get scanner protos from github.com/stackrox/scanner module
- Add Makefile targets: proto-setup, proto-generate, proto-clean, proto-check
- Simplify GitHub Actions workflow (removed external repo checkout)
- Update documentation to reflect new approach
- Add proto-version.sh script for version tracking
Benefits:
- No external repository dependencies
- Works automatically in CI/CD environments
- Version-locked to go.mod for reproducibility
- Handles read-only mod cache files with chmod
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
54e2b8f to
4b7b1e4
Compare
Implemented comprehensive E2E testing framework with complete eval coverage: - Test runner supports --mock and --real flags - Mock mode: WireMock with TLS (self-signed cert) - Real mode: staging.demo.stackrox.com - Automatic WireMock lifecycle management - Self-signed certificate generation (wiremock/generate-cert.sh) - HTTPS on port 8081 with proper TLS - Uses InsecureSkipTLSVerify (no client code changes needed) - Idempotent cert generation with keytool dependency check - Added 3 new test tasks: log4shell, multiple CVEs, RHSA - Total 11 E2E tests with proper assertions - 32/32 assertions passing - 5 new fixtures for E2E test CVEs - 3 deployment fixtures (CVE-2021-31805, CVE-2016-1000031, CVE-2024-52577) - 2 cluster fixtures (CVE-2016-1000031, CVE-2021-31805) - Updated mappings with CVE-specific routing Modified: - .gitignore - Added wiremock/certs/ exclusion - e2e-tests/README.md - Mock/real mode documentation - e2e-tests/mcpchecker/eval.yaml - Added 3 new tests - e2e-tests/scripts/run-tests.sh - Mock/real mode switching - scripts/start-mock-central.sh - TLS configuration - wiremock/README.md - Updated fixture documentation - wiremock/mappings/clusters.json - CVE-specific mappings - wiremock/mappings/deployments.json - CVE-specific mappings Created: - e2e-tests/mcpchecker/tasks/cve-log4shell.yaml - e2e-tests/mcpchecker/tasks/cve-multiple.yaml - e2e-tests/mcpchecker/tasks/rhsa-not-supported.yaml - e2e-tests/scripts/smoke-test-mock.sh - wiremock/fixtures/deployments/cve_2021_31805.json - wiremock/fixtures/deployments/cve_2016_1000031.json - wiremock/fixtures/deployments/cve_2024_52577.json - wiremock/fixtures/clusters/cve_2016_1000031.json - wiremock/fixtures/clusters/cve_2021_31805.json - wiremock/generate-cert.sh - IMPLEMENTATION_SUMMARY.md - All shellcheck issues resolved - Proper error handling and dependency checks - Idempotent operations throughout - Clean TLS approach (no client code modifications) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> Signed-off-by: Tomasz Janiszewski <tomek@redhat.com>
4b7b1e4 to
cf2af0c
Compare
This commit implements proper configuration for E2E tests to run against the WireMock mock service instead of requiring a real StackRox instance. Key Changes: - Created mcp-config-mock.yaml with explicit environment variables (fixes mcpchecker's inability to inherit env vars properly) - Created eval-mock.yaml that references the mock config - Updated run-tests.sh to select correct eval file based on mode - Added HTTP port 8080 to WireMock startup for debugging - Updated cluster mappings to include CVE-2099-00001 and CVE-2024-52577 - Fixed cluster fixture data to match test expectations WireMock gRPC Configuration: - Proto descriptors must use .dsc extension (handled by setup scripts) - JSON fixtures are automatically converted to protobuf by gRPC extension - Removed explicit Content-Type headers to let extension handle encoding Test Results: - 10 out of 11 tests passing (91% pass rate) - All tool invocation assertions passing (29/32) - Tests no longer hang - proper connection to mock service - Remaining failures are LLM behavioral (tool call counts), not mock issues Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit fixes the remaining 2 E2E test failures by correcting WireMock request matching for gRPC requests. Root Causes Fixed: 1. **JSONPath pattern mismatch**: The mappings used $.query[?(@.query...)] which looked for a nested array structure, but gRPC protobuf-to-JSON conversion creates a simple object with a "query" field (lowercase). 2. **Cluster name inconsistency**: Test asked for "staging-central-cluster" but it wasn't in the general cluster list, only in CVE-specific files. Changes: - Updated all CVE mappings from $.query[?(@.query =~ ...)] to $[?(@.query =~ ...)] to match actual protobuf JSON structure - Added "staging-central-cluster" to all_clusters.json for consistency with cve_2016_1000031.json Key Insight: Protobuf field names use lowercase (as defined in .proto files), while Go field names use PascalCase. When gRPC requests are converted to JSON by WireMock's gRPC extension, they use the protobuf field name "query", not the Go field name "Query". Test Results: - All 11/11 tests passing (100% pass rate) ✅ - All 32/32 assertions passing ✅ - cve-nonexistent: Now correctly returns empty cluster list - cve-cluster-does-exist: Now finds cluster and checks CVE Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Fix protocol mismatch: Update curl commands from HTTP to HTTPS to match WireMock's TLS configuration - Fix test data: Change CVE-2021-44228 test to check for 'dep-004' instead of non-existent 'dep-123-log4j' - Add grpcurl as tool dependency for Dependabot tracking in e2e-tests/tools - Fix grpcurl usage in smoke-test-mock.sh to use -insecure flag and correct query format All smoke tests now pass (7/7). Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
mtodor
reviewed
Feb 10, 2026
mtodor
reviewed
Feb 11, 2026
mtodor
reviewed
Feb 11, 2026
Co-authored-by: Mladen Todorovic <mtodor@gmail.com>
Co-authored-by: Mladen Todorovic <mtodor@gmail.com>
Co-authored-by: Mladen Todorovic <mtodor@gmail.com>
Implements all 14 code review comments on PR #32: **Script Improvements:** - Use mktemp -d instead of hardcoded /tmp paths (prevents collisions) - Add SCRIPT_DIR pattern to scripts (can run from any directory) - Replace sleep with curl health check for WireMock startup - Unify nc/curl usage (consistently use curl) - Move trap to top level in run-tests.sh - Simplify smoke test results output **WireMock Infrastructure:** - Change proto descriptor extension from .pb to .dsc - Move __files symlink creation to start-mock-central.sh - Commit pre-generated 100-year TLS certificate (valid until 2126) - Eliminates keytool/openssl dependency - Simpler user experience - works immediately after clone - Update README to distinguish committed vs generated directories - Remove chmod from setup-proto-files.sh (not needed) **Test Configuration:** - Consolidate eval-mock.yaml into eval.yaml (single config) - Make CVE verification stricter for mock mode (expect specific deployment names) - Delete unused all_deployments.json fixture All changes verified with: - make mock-test (7/7 smoke tests passing) - e2e-tests (7/11 tasks passing, 32/32 assertions passing) Co-authored-by: Mladen Todorovic <mtodor@gmail.com>
- Remove unused fixtures: orchestrator_cve.json, rhsa_2024_5137.json - Remove unused scripts: proto-version.sh, generate-cert.sh - Remove empty extensions/ directory - Compact wiremock/README.md and link to upstream docs Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Changed all deployment CVE mappings from: $.query[?(@.query =~ /.*CVE-XXX.*/)] to: $[?(@.query =~ /.*CVE-XXX.*/)] The original mappings used $.query which looked for a nested array structure, but gRPC protobuf-to-JSON conversion creates a simple object with a 'query' field (lowercase). This fix ensures WireMock can properly match gRPC requests for CVE queries. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Implements automatic protoc download and installation similar to the main stackrox repo, eliminating the need for manual protoc installation. Changes: - Add protoc auto-download logic to Makefile with OS/arch detection - Downloads protoc 32.1 from GitHub releases to .proto/ directory - Update proto-generate target to depend on local protoc installation - Update generate-proto-descriptors.sh to use PROTOC_BIN env var - Add .proto/ to .gitignore - Add .proto/ cleanup to clean target - Remove manual protoc installation from wiremock-test.yml workflow Benefits: - Developers no longer need to manually install protoc - Consistent protoc version across all developers and CI - Works offline after first download - Simplified CI workflows Usage: make proto-install # Install protoc (automatic on proto-generate) make proto-generate # Generate descriptors (auto-installs protoc) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
acbec80 to
4e23fe9
Compare
Removed support for --real mode since we only use WireMock for e2e tests. Changes: - Simplified run-tests.sh by removing --mock/--real flag parsing - Removed conditional logic for real mode configuration - Always use WireMock on localhost:8081 - Updated e2e-tests/README.md to remove real mode documentation - Removed StackRox API token from prerequisites - Updated Makefile e2e-test target to remove --mock flag Benefits: - Simpler script with less code to maintain - Clearer documentation focused on WireMock - No confusion about which mode to use - Faster and more reliable tests Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
janisz
commented
Feb 18, 2026
The smoke test was failing because protoc wasn't in PATH when the script tried to generate proto descriptors. Updated the workflow to use make mock-test instead of calling the script directly, and made mock-test depend on proto-generate and mock-download to ensure all dependencies are properly handled. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The smoke test was sending an incorrect nested JSON structure:
{"query":{"query":"CVE:\"CVE-2021-44228\""}}
The correct structure per the RawQuery protobuf message is:
{"query":"CVE:\"CVE-2021-44228\""}
This matches what the actual MCP gRPC client sends and fixes the
failing CVE-2021-44228 test.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
mtodor
approved these changes
Feb 27, 2026
Collaborator
mtodor
left a comment
There was a problem hiding this comment.
Awesome work! This is a big step for this project!
I have executed and tested it locally. It works. I would prefer that we merge this PR and then improve things in a follow-up(s). We have several things that are waiting on this functionality.
Signed-off-by: Tomasz Janiszewski <tomek@redhat.com>
janisz
added a commit
that referenced
this pull request
Mar 6, 2026
Signed-off-by: Tomasz Janiszewski <tomek@redhat.com> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com> Co-authored-by: Mladen Todorovic <mtodor@gmail.com> Add Go integration tests for MCP server with WireMock Implements integration tests that verify MCP server functionality using stdio transport and WireMock as a mock StackRox Central backend. **Key Changes:** - Created integration test suite in `integration/` with build tag - Implemented stdio-based MCP client in `internal/testutil/mcp.go` - Added WireMock readiness check in `internal/testutil/wiremock.go` - Added test fixtures for expected WireMock response data - Updated Makefile with integration test targets - Updated GitHub Actions workflow to run integration tests in CI **Test Coverage:** - MCP protocol (initialize, list tools) - Tool invocations (list_clusters, get_deployments_for_cve, etc.) - Error handling (missing parameters) - Success and error scenarios Tests use stdio transport for simplicity and better control over the MCP server lifecycle. Each test starts a fresh MCP server subprocess and communicates via JSON-RPC over stdin/stdout. TODO: Fix WireMock request matching for CVE-2021-44228 deployment query Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> fix: Fix WireMock JSONPath patterns for deployment CVE queries Apply the same JSONPath fix from commit 01f58ab to deployments.json. The original mappings used $.query[?(@.query =~ ...)] which looked for a nested array structure, but gRPC protobuf-to-JSON conversion creates a simple object with a 'query' field (lowercase). Changed all deployment CVE mappings from: $.query[?(@.query =~ /.*CVE-XXX.*/)] to: $[?(@.query =~ /.*CVE-XXX.*/)] This fixes the TestIntegration_GetDeploymentsForCVE_Log4Shell test which was failing because WireMock couldn't match the gRPC requests. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> test: Unskip Log4Shell integration test The WireMock JSONPath fix for deployments.json resolves the issue that was causing this test to fail. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> refactor: Simplify integration tests and remove manual protoc installation This commit implements two major simplifications to the test infrastructure: 1. **Eliminate TestMain Pre-compilation Pattern**: - Extract main() body into new internal/app package with Run() function - Tests now call app.Run() in-process via io.Pipe() instead of subprocess - Removes 60+ lines of build/setup code from integration_test.go - Enables full code coverage (previously main.go had 0% coverage) - Faster test execution (no binary compilation overhead) - Better debugging (direct function calls vs exec) 2. **Remove Manual Protoc Installation from GitHub Actions**: - Delete manual protoc 3.20.1 download from workflow - Rely on Makefile's automatic protoc 32.1 installation - Single source of truth for protoc version - Eliminates version mismatch between CI and local dev Changes: - Create internal/app/app.go with Run() function extracted from main() - Update server.Start() to accept optional stdin/stdout parameters - Refactor testutil.NewMCPClient() to use ServerRunFunc callback - Remove TestMain, buildMCPBinary, global vars from integration tests - Update all integration test functions to use createMCPClient() helper - Remove "Install protoc" step from .github/workflows/test.yml Benefits: - 43 net lines removed (-161 +118) - Better code coverage - Simpler test maintenance - Aligned with Go testing best practices Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> fix: Add missing retry/timeout config to integration test setup The test config was missing RequestTimeout, MaxRetries, InitialBackoff, and MaxBackoff fields, causing the gRPC client to use zero values instead of the defaults (30s timeout, 3 retries). With MaxRetries=0, the retry loop never executed: `for attempt := range 0` This caused "Request failed after all retries ... attempts=0" warnings and empty responses from WireMock. Solution: Explicitly set the retry/timeout fields to match the defaults defined in internal/config/config.go. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> Signed-off-by: Tomasz Janiszewski <tomek@redhat.com> Add Go integration tests for MCP server with WireMock Implements integration tests that verify MCP server functionality using stdio transport and WireMock as a mock StackRox Central backend. **Key Changes:** - Created integration test suite in `integration/` with build tag - Implemented stdio-based MCP client in `internal/testutil/mcp.go` - Added WireMock readiness check in `internal/testutil/wiremock.go` - Added test fixtures for expected WireMock response data - Updated Makefile with integration test targets - Updated GitHub Actions workflow to run integration tests in CI **Test Coverage:** - MCP protocol (initialize, list tools) - Tool invocations (list_clusters, get_deployments_for_cve, etc.) - Error handling (missing parameters) - Success and error scenarios Tests use stdio transport for simplicity and better control over the MCP server lifecycle. Each test starts a fresh MCP server subprocess and communicates via JSON-RPC over stdin/stdout. TODO: Fix WireMock request matching for CVE-2021-44228 deployment query Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> fix: Fix WireMock JSONPath patterns for deployment CVE queries Apply the same JSONPath fix from commit 01f58ab to deployments.json. The original mappings used $.query[?(@.query =~ ...)] which looked for a nested array structure, but gRPC protobuf-to-JSON conversion creates a simple object with a 'query' field (lowercase). Changed all deployment CVE mappings from: $.query[?(@.query =~ /.*CVE-XXX.*/)] to: $[?(@.query =~ /.*CVE-XXX.*/)] This fixes the TestIntegration_GetDeploymentsForCVE_Log4Shell test which was failing because WireMock couldn't match the gRPC requests. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> test: Unskip Log4Shell integration test The WireMock JSONPath fix for deployments.json resolves the issue that was causing this test to fail. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> refactor: Simplify integration tests and remove manual protoc installation This commit implements two major simplifications to the test infrastructure: 1. **Eliminate TestMain Pre-compilation Pattern**: - Extract main() body into new internal/app package with Run() function - Tests now call app.Run() in-process via io.Pipe() instead of subprocess - Removes 60+ lines of build/setup code from integration_test.go - Enables full code coverage (previously main.go had 0% coverage) - Faster test execution (no binary compilation overhead) - Better debugging (direct function calls vs exec) 2. **Remove Manual Protoc Installation from GitHub Actions**: - Delete manual protoc 3.20.1 download from workflow - Rely on Makefile's automatic protoc 32.1 installation - Single source of truth for protoc version - Eliminates version mismatch between CI and local dev Changes: - Create internal/app/app.go with Run() function extracted from main() - Update server.Start() to accept optional stdin/stdout parameters - Refactor testutil.NewMCPClient() to use ServerRunFunc callback - Remove TestMain, buildMCPBinary, global vars from integration tests - Update all integration test functions to use createMCPClient() helper - Remove "Install protoc" step from .github/workflows/test.yml Benefits: - 43 net lines removed (-161 +118) - Better code coverage - Simpler test maintenance - Aligned with Go testing best practices Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> fix: Add missing retry/timeout config to integration test setup The test config was missing RequestTimeout, MaxRetries, InitialBackoff, and MaxBackoff fields, causing the gRPC client to use zero values instead of the defaults (30s timeout, 3 retries). With MaxRetries=0, the retry loop never executed: `for attempt := range 0` This caused "Request failed after all retries ... attempts=0" warnings and empty responses from WireMock. Solution: Explicitly set the retry/timeout fields to match the defaults defined in internal/config/config.go. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> Signed-off-by: Tomasz Janiszewski <tomek@redhat.com> cleanup Signed-off-by: Tomasz Janiszewski <tomek@redhat.com> Refactor integration tests and migrate to official MCP SDK This commit refactors the integration test suite and replaces the custom MCP client implementation with the official MCP Go SDK. Changes: 1. Table-Driven Tests Refactoring: - Consolidated 5 individual test functions into 2 table-driven tests - TestIntegration_ToolCalls: 4 successful tool call scenarios - TestIntegration_ToolCallErrors: error handling scenarios - Reduced code duplication by ~50 lines - Added helper functions: setupInitializedClient, callToolAndGetResult 2. Removed TestMain: - Eliminated WireMock readiness check from TestMain - Removed unused imports (fmt, os) - Simplified test setup (13 lines removed) 3. Migrated to Official MCP Go SDK: - Replaced custom internal/testutil/mcp.go (202 lines) - Created internal/testutil/mcp_client.go (141 lines) using SDK - Uses official mcp.Client and mcp.ClientSession - Proper type-safe content handling with *mcp.TextContent - Better error handling (protocol vs tool errors) Benefits: - Total code reduction: 99 lines removed - Better maintainability with table-driven tests - Future-proof with official SDK - Consistent with server-side SDK usage - All tests pass (3 test functions, 5 subtests total) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> fmt Signed-off-by: Tomasz Janiszewski <tomek@redhat.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Mock central with WireMock
Validation
CI