Testing Guide¶
Directory Inventory
See the Testing Directory Inventory for a complete listing of files and resources in this directory.
This document provides a comprehensive guide to testing the Secure CINC Auditor Kubernetes Container Scanning solution, covering test methodology, test environments, and recommended testing practices.
Testing Overview¶
The testing strategy for this container scanning solution covers several key aspects:
- Functional Testing: Validating that the scanning tools correctly identify security issues
- Integration Testing: Ensuring the scanning tools work with various Kubernetes environments
- Security Testing: Verifying that the scanning implementation itself doesn't introduce security risks
- Performance Testing: Measuring scan times and resource utilization
- Compliance Testing: Validating that scanning results meet compliance requirements
Testing Environments¶
We recommend testing in the following environments:
- Local Minikube: For initial functional testing and development
- GitLab CI/GitHub Actions: For CI/CD pipeline integration testing
- Production-like Kubernetes: For final validation before production deployment
Testing Prerequisites¶
Before running tests, ensure you have:
- A Kubernetes Cluster:
- For local testing: minikube with at least 2 nodes
-
For production testing: A Kubernetes cluster with appropriate access
-
Required Tools:
- kubectl
- CINC Auditor/InSpec
- SAF CLI for results processing
-
Appropriate container images for testing (standard and distroless)
-
Access Credentials:
- RBAC permissions to create service accounts, roles, and pods
- Ability to create tokens for testing
Test Categories¶
1. Functional Testing¶
Tests that validate the core scanning functionality works correctly.
Verify that:
- Scan executes without errors
- Results are properly formatted
- Issues are correctly identified
2. Integration Testing¶
Tests that validate integration with various Kubernetes environments and CI/CD systems.
CI/CD Integration Tests¶
For each CI/CD system (GitHub Actions, GitLab CI):
- Verify automated scanning works in pipelines
- Validate pipeline success/failure based on scan results
- Check threshold validation works correctly
Environment Integration Tests¶
For different Kubernetes distributions:
- Standard Kubernetes (various versions)
- AKS, EKS, GKE
- OpenShift
3. Security Testing¶
Tests that validate the security of the scanning implementation.
RBAC Testing¶
Verify:
- Scanner operates with minimal permissions
- Timeouts work correctly for tokens
- Resources are properly cleaned up after scan
Container Security Testing¶
For each scanning approach:
- Validate that scanning doesn't introduce vulnerabilities
- Verify isolation between scanner and target containers
- Test scanner with various security contexts
4. Performance Testing¶
Tests that measure scanning performance.
Measurements:
- Scan initialization time
- Scan execution time
- Resource utilization (CPU, memory)
- Scaling tests (scanning multiple containers)
5. Compliance Testing¶
Tests that validate compliance requirements are met.
Verify:
- Compliance checks match required standards
- Threshold validation works correctly
- Reports include necessary compliance data
Test Matrix for Container Types¶
Container Type | Standard Scanning | Distroless Scanning | Sidecar Scanning |
---|---|---|---|
Base Images | Required | Required | Required |
Java Applications | Required | Required | Required |
Node.js Applications | Required | Required | Required |
Python Applications | Required | Required | Required |
Go Applications | Required | Required | Required |
Multi-stage Builds | Required | Required | Required |
Custom Distroless | Required | Required | Required |
Automated Test Suite¶
We provide automated tests to validate core functionality:
The automated test suite includes:
- Unit tests for helper scripts
- Integration tests for scanning functionality
- Regression tests for known issues
Test Environments Setup¶
Local Minikube Setup for Testing¶
CI/CD Environment Setup¶
For GitHub Actions:
- Use the provided GitHub Actions workflows in
github-workflow-examples/
- Configure with appropriate secrets and environment variables
For GitLab CI:
- Use the provided GitLab CI pipelines in
gitlab-pipeline-examples/
- Configure with appropriate variables and runners
Troubleshooting Tests¶
Common issues and resolutions:
- Scanner can't access containers:
- Verify RBAC permissions are correct
- Check service account configuration
-
Ensure token is valid and not expired
-
Distroless scanning fails:
- Verify Kubernetes version supports ephemeral containers
- Check debug container configuration
-
Confirm sidecar container has shared process namespace
-
Threshold validation fails:
- Check threshold file syntax
- Verify SAF CLI is correctly configured
- Review scan results for unexpected failures
Reference Test Cases¶
Standard Container Test Case¶
Distroless Container Test Case¶
Sidecar Container Test Case¶
Next Steps¶
After completing testing, refer to:
- Deployment Scenarios for production deployment
- Threshold Configuration for compliance settings
- CI/CD Integration for pipeline setup