| .. | ||
| alice.sh | ||
| alice2.sh | ||
| alice3.sh | ||
| edge_cases.sh | ||
| README.md | ||
| security_edge.sh | ||
Naj Integration & Scenario Tests
This directory contains the integration test suite and scenario simulations for naj. These scripts are designed to validate the core functionality, security isolation, and developer workflows in a controlled, sandbox environment.
Overview
The tests in this directory focus on end-to-end (E2E) validation, ensuring that naj correctly interacts with Git configurations, SSH keys, and system environments without contaminating the user's global settings.
Test Matrix
| Script | Focus Area | Description |
|---|---|---|
alice.sh |
Basic Workflow | Validates profile creation, cloning, and identity switching with SSH signing. |
alice2.sh |
Advanced Signing | Extends basic tests with complex signing scenarios and multi-profile setups. |
alice3.sh |
Full Lifecycle | Simulates a complex developer lifecycle involving multiple organizations. |
edge_cases.sh |
Robustness | Tests boundary conditions, invalid inputs, and error handling. |
security_edge.sh |
Security | Validates configuration isolation and prevents "leakage" between profiles. |
Prerequisites
To run these tests locally, ensure you have the following installed:
- Bash: Most scripts use standard Bash features.
- Git: Version 2.34+ is required for SSH signing tests.
- Naj: The
najbinary must be available in your PATH or accessible via theNAJ_CMDenvironment variable.
Running Tests
Preparation
Before running the tests, compile the project to ensure the latest binary is used:
cargo build --release
export PATH="$PWD/target/release:$PATH"
Execution
You can run individual test scripts directly:
bash scripts/tests/alice.sh
Each script initializes a sandbox in /tmp/naj_test_* or similar, ensuring that your ~/.gitconfig and ~/.ssh remain untouched.
Design Principles
- Isolation: All tests use a dedicated
NAJ_CONFIG_PATHand temporary directories to ensure side-effect-free execution. - Assertions: Scripts use exit codes and explicit checks to verify expected outcomes (e.g., checking
git cat-filefor signatures). - Readability: Log levels (STEP, INFO, ERROR) are used to provide clear feedback during execution.
Adding New Tests
When adding a new test script:
- Use
set -eto ensure the script fails on the first error. - Use a dedicated sandbox directory for all temporary files.
- Export
NAJ_CONFIG_PATHto point into your sandbox. - Document the scenario and expected results in the script header.