Test Unit - AyhamAsfoor/StegX GitHub Wiki
StegX Testing Suite
This document provides comprehensive documentation for the StegX testing suite, including setup instructions, test categories, and guidelines for running and extending tests.
Table of Contents
- Overview
- Test Directory Structure
- Setup and Installation
- Running Tests
- Test Categories
- Extending the Test Suite
- CI/CD Integration
- Kali Linux Considerations
- Troubleshooting
- Contributing
Overview
The StegX testing suite is designed to ensure the reliability, security, and performance of the StegX steganography tool. It includes:
- Unit tests for individual components
- Integration tests for component interactions
- System tests for end-to-end functionality
- Performance tests for resource usage and scalability
- Security tests for cryptographic robustness and vulnerability assessment
Test Directory Structure
tests/
├── __init__.py
├── conftest.py
├── requirements.txt
├── resources/
│ ├── images/
│ │ ├── valid/
│ │ └── invalid/
│ └── files/
├── unit/
│ ├── __init__.py
│ ├── test_steganography.py
│ ├── test_crypto.py
│ └── test_utils.py
├── integration/
│ ├── __init__.py
│ └── test_encode_flow.py
├── system/
│ ├── __init__.py
│ └── test_cli.py
├── performance/
│ ├── __init__.py
│ └── test_performance.py
└── security/
├── __init__.py
└── test_security.py
Setup and Installation
Prerequisites
- Python 3.8 or higher
- pip package manager
- Kali Linux (recommended for security tests)
Installation
-
Clone the StegX repository:
git clone https://github.com/Delta-Sec/StegX.git cd StegX
-
Install StegX and test dependencies:
pip install -e . pip install -r tests/requirements.txt
Test Dependencies
The following packages are required for testing:
- pytest
- pytest-cov
- pillow
- numpy
- matplotlib
- memory_profiler (optional, for memory tests)
- hypothesis (optional, for property-based tests)
Running Tests
Running All Tests
pytest tests/
Running Specific Test Categories
pytest tests/unit/
pytest tests/integration/
pytest tests/system/
pytest tests/performance/
pytest tests/security/
Running Specific Test Files
pytest tests/unit/test_steganography.py
pytest tests/system/test_cli.py
Running Tests with Coverage
pytest --cov=stegx_core tests/
pytest --cov=stegx_core --cov-report=html tests/
Test Categories
Unit Tests
Unit tests verify the correctness of individual functions and classes in isolation. They focus on:
- Input validation
- Expected outputs
- Error handling
- Edge cases
See Test Case Explanations for detailed explanations of each unit test.
Integration Tests
Integration tests verify that different components work correctly together. They test:
- Data flow between components
- Component interactions
- End-to-end workflows
System Tests
System tests verify the behavior of the complete application from a user's perspective. They test:
- CLI functionality
- Command-line arguments
- Exit codes and error messages
- End-to-end workflows
Performance Tests
Performance tests measure the efficiency and resource usage of the application. They test:
- Execution time with different file sizes
- Memory usage
- Compression effectiveness
- Scalability with large inputs
Security Tests
Security tests verify the cryptographic robustness and vulnerability resistance of the application. They test:
- Password strength impact
- Cryptographic implementation
- Tamper resistance
- Steganalysis resistance
- Input validation and sanitization
Extending the Test Suite
Adding New Test Cases
- Identify the appropriate test category and file
- Follow the existing test patterns
- Use pytest fixtures for setup and teardown
- Document the purpose of the test
- Update test_case_explanations.md with details
Creating New Test Resources
- Add images to
tests/resources/images/
- Add files to hide in
tests/resources/files/
- Document any special properties of the resources
Adding New Test Categories
- Create a new directory under
tests/
- Add an
__init__.py
file - Create test files following the naming convention
test_*.py
- Update this README with the new category
CI/CD Integration
GitHub Actions
A sample GitHub Actions workflow is provided in .github/workflows/tests.yml
. It:
- Runs on Kali Linux
- Executes all test categories
- Generates coverage reports
- Performs security scans
Jenkins
For Jenkins integration, use the provided Jenkinsfile
which:
- Builds a Kali Linux Docker container
- Runs the test suite
- Archives test results and coverage reports
Kali Linux Considerations
StegX is designed for use in Kali Linux environments, which introduces specific testing considerations:
- Security Focus: Tests must verify resistance to common attack vectors
- Tool Integration: Tests should verify compatibility with other Kali tools
- Privilege Handling: Tests must verify behavior with different privilege levels
- Forensic Artifacts: Tests should verify minimal forensic footprint
See Coverage And Kali Considerations for detailed guidance.
Troubleshooting
Common Issues
-
Image libraries not found: Install Pillow dependencies
apt-get install libjpeg-dev zlib1g-dev
-
Permission errors in Kali: Run with appropriate privileges
sudo -E pytest tests/security/
-
Memory errors with large files: Increase available memory or use smaller test files
Getting Help
If you encounter issues not covered here:
- Check the StegX documentation
- Open an issue on the GitHub repository
- Contact to us
Contributing
Contributions to the test suite are welcome! Please:
- Follow the existing code style
- Add appropriate documentation
- Ensure all tests pass
- Submit a pull request
For major changes, please open an issue first to discuss your proposed changes.
This testing suite documentation was last updated on June 12, 2025.