test: add comprehensive unit and integration tests for all modules#232
Merged
test: add comprehensive unit and integration tests for all modules#232
Conversation
…team, and tool modules **Added:** - Added extensive unit tests to `ares-cli/src/detection/techniques/tests.rs` for detection technique builders, fallback logic, and state-driven evidence/credential capping - Added new tests to `ares-core/src/eval/ground_truth/tests.rs` covering golden ticket logic, share writability, and deduplication of techniques across vulnerabilities - Introduced tests in `ares-core/src/state/blue_task_queue.rs` for `BlueTaskResult` constructors and timestamp logic - Added tests in `ares-core/src/state/operations.rs` to validate `pick_latest` behavior under various timestamp and lexicographic scenarios - Implemented tests in `ares-core/src/telemetry/propagation.rs` for OTel traceparent propagation and robustness to missing or malformed headers - Expanded `ares-llm/src/agent_loop/callbacks.rs` with tests for all builtin callback handlers, including edge cases and result types - Added tests in `ares-llm/src/prompt/state_context.rs` for context formatting, delegation markers, and pending vulnerabilities - Added tests to `ares-llm/src/provider/mod.rs` for LlmError retry logic and `retry_after_ms` handling - Implemented blue team tool registry tests in `ares-llm/src/tool_registry/mod.rs` (feature-gated), covering tool assignment, uniqueness, and schema structure for all blue roles - Added tests in `ares-tools/src/executor.rs` for output sanitization, command builder chaining, and argument/flag logic - Expanded `ares-tools/src/lib.rs` with tests for `ToolOutput` combination methods and error reporting in tool dispatch **Changed:** - Updated test modules to provide more coverage and validate edge cases for core logic and error handling across detection, state management, LLM, and tooling components
…ement, privesc, blue team, and parsing modules **Added:** - Extensive unit tests for config handling, string formatting, and argument parsing in `ares-cli` modules - Exhaustive tests for host formatting, service detection, and hostname resolution utilities - Unit tests for result processing logic, domain admin detection, and parent ID resolution - Tests for shell argument joining, JSON escaping, deployment detection, and CLI utilities - Blue team prompt generation and template selection tests in LLM module, including edge cases - Thorough test coverage for credential access tools: Kerberos, misc, secretsdump, and credential format helpers - Tests for all lateral movement utilities: execution, Kerberos, MSSQL, pass-the-hash, SSH, RDP, WinRM, and impacket auth logic - Unit tests for AD CS exploitation, GMSA, trust attacks, and CVE exploit modules, validating input handling and string assembly - Additional tests for modular credential access, verifying default values, required arguments, and string formats **Changed:** - Improved code robustness by validating argument requirements and default behaviors via added tests - Enhanced maintainability and reliability of credential access, lateral, privesc, and blue team logic through test-driven validation - Refactored some helper logic in tests to ensure coverage of edge cases and input permutations
…ules **Added:** - Added helper and utility functions for deduplication key construction, domain extraction, and domain relationship checks in orchestrator automation modules - Introduced extensive unit tests for: - ACL chain step extraction and deduplication logic (`automation/acl.rs`) - ADCS FQDN domain extraction (`automation/adcs.rs`) - Credential access deduplication, domain resolution, and relationship logic (`automation/credential_access.rs`) - Credential reuse candidate detection and cross-domain deduplication (`automation/credential_reuse.rs`) - Secretsdump deduplication and domain logic (`automation/secretsdump.rs`) - Trust escalation and deduplication helpers (`automation/trust.rs`) - Dispatcher inflight limiter behavior (`dispatcher/mod.rs`) - Admin checks: domain admin path resolution, golden ticket detection, Pwn3d! parsing, and IP extraction (`result_processing/admin_checks.rs`) - Timeline MITRE technique classification for credentials and hashes (`result_processing/timeline.rs`) - ACL tool domain DN conversion and GPO abuse flag formatting (`ares-tools/src/acl.rs`) - Blue team investigation statistics, query effectiveness, deduplication, similarity, and false positive pattern logic (`blue/persistence.rs`) **Changed:** - Refactored orchestrator automation and result processing modules to extract and reuse helper functions for deduplication, domain matching, and parsing, improving testability and maintainability - Updated main functional code to utilize new helper functions in place of repeated inline logic - Enhanced test coverage for core decision logic and edge cases across orchestrator and blue team modules
**Added:** - In-memory `MockRedisConnection` for simulating Redis operations in tests - Extensive async unit tests for blue_operations, blue_reader, blue_writer, operations, and reader modules to validate state management logic using the mock Redis backend **Changed:** - Enabled and integrated the `mock_redis` module for tests in `mod.rs` and other state modules - Added environment variable cleanup in orchestrator config test to ensure test isolation
…eue logic **Added:** - Added `ares-core` as a dev-dependency to `ares-cli` with test-utils, blue, and telemetry features enabled in `Cargo.toml` - Introduced extensive unit tests for orchestrator state modules (`dedup.rs`, `persistence.rs`, `publishing/credentials.rs`, `publishing/entities.rs`, `publishing/hosts.rs`, `publishing/milestones.rs`, `publishing/mod.rs`, and `result_processing/admin_checks.rs`) - Tests cover deduplication, Redis persistence, entity and credential publication, milestones, host/domain extraction, state loading/refreshing, and more - Added test helpers and mocks for simulating Redis and orchestrator queue interactions - Added comprehensive unit tests for `task_queue.rs`, covering task submission, queueing, heartbeat, locking, status tracking, and result retrieval - Added tests for credential sanitization and AWS hostname detection in state publishing logic - Added tests for the mock Redis implementation, including pipeline and clone semantics **Changed:** - Refactored orchestrator state and publishing module methods to accept a generic `TaskQueueCore<impl ConnectionLike + Clone + Send + Sync + 'static>` instead of the concrete `TaskQueue`, improving testability and flexibility - Updated imports and function signatures throughout orchestrator state and publishing modules to support the generic queue interface - Updated `ares-core` mock Redis implementation to be clonable with shared state using `Arc<Mutex<>>`, and to support all required Redis commands for tests (including ZADD, LSET, and pipelines) - Enabled the `test-utils` feature in `ares-core` and made the `mock_redis` module available under `#[cfg(any(test, feature = "test-utils"))]` - Improved documentation and comments in orchestrator and core modules for testability and test semantics **Removed:** - Removed all direct usage of the old `TaskQueue` type in orchestrator state and publishing logic in favor of the generic core type
…ue engines **Changed:** - Removed `attack_step` field from credential search queries and types to simplify search logic - Refactored `InvestigationOutcome` enum by removing unused `summary` and adding `#[allow(dead_code)]` only to fields needed in tests - Cleaned up `LlmTaskRunner` struct by removing the unused `model_name` field and updating construction logic - Updated `AgentState` struct and related methods to only suppress dead code warnings on fields used in tests - Restricted method visibility with `#[cfg(test)]` instead of `#[allow(dead_code)]` for test-only orchestrator functions - Simplified `Throttler` struct and methods, only annotating fields and methods used in tests as dead code - Removed public re-exports of types and helpers related to recovery analysis that are no longer used **Removed:** - Deleted the `resume_helper.rs` module and all related types (`OperationResumeHelper`, `InterruptedTask`, `RetryingTask`) as post-recovery analysis is no longer required - Removed `pyramid_elevation_score` and `confidence_impact_score` fields from investigative question structures in blue engines and all related code - Eliminated the unused `new` method from `TaskQueue` as Redis connection is always established via `connect`
**Added:** - Added extensive mock executor tests for all tool wrapper functions in the following modules: `acl.rs`, `coercion.rs`, `cracker.rs`, `credential_access/kerberos.rs`, `credential_access/misc.rs`, `credential_access/secretsdump.rs`, `lateral/execution.rs`, `lateral/kerberos.rs`, `lateral/mssql.rs`, `lateral/pth.rs`, and `recon.rs` - Implemented tests to verify correct command construction, handling of arguments, and correct invocation of tool wrapper functions, covering different combinations of authentication and argument scenarios - Added test cases for various output parsers in `parsers/mod.rs` to validate discovery extraction logic - Introduced a mock executor module in `executor.rs` to support pushing and consuming mock command outputs for reliable testing **Changed:** - Updated the `executor.rs` `CommandBuilder::execute` method to check for and use mock outputs in test mode, enabling controlled test execution - Made `DEFAULT_AD_USERNAMES` in `credential_access/kerberos.rs` `pub(crate)` to allow test access **Removed:** - Removed direct subprocess spawning in test mode in favor of using the mock executor for all relevant tool execution tests
**Added:** - Added async tests using the mock executor for ADCS, CVE exploits, delegation, GMSA, and trust modules to verify command execution logic with various argument combinations and options, increasing test coverage and ensuring correct integration with the executor mock
**Added:** - Added comprehensive unit tests for credential sanitization, deduplication, and label normalization in `ares-cli/src/dedup/credentials.rs`, `ares-cli/src/dedup/labels.rs`, and `ares-cli/src/dedup/users.rs` - Added tests for host extraction logic in `ares-cli/src/orchestrator/output_extraction/hosts.rs` - Introduced tests for pyramid level logic, mapping functions, YAML lazy caches, and output generation in `ares-tools/src/blue/engines/data.rs` - Added tests for MITRE question generation, ID creation, and sorting in `ares-tools/src/blue/engines/mitre.rs` - Added tests for evidence-based pyramid assessment and question generation in `ares-tools/src/blue/engines/pyramid.rs` - Added tests for MITRE DB lookup, suggestion logic, and static data integrity in `ares-tools/src/blue/learning/mitre_db.rs` - Added tests for Loki response formatting, retryable status logic, cache key determinism, output/error helpers, and query pattern combination in `ares-tools/src/blue/loki.rs` - Added tests for Prometheus response formatting and output/error helpers in `ares-tools/src/blue/prometheus.rs`
**Added:** - Unit tests covering table extraction, deduplication, empty input, missing table, and share comments for the extract_shares function in shares.rs
…n modules **Added:** - Added extensive unit tests for `RedBlueCorrelator` in `engine.rs` covering technique matching, gap reason determination, detection recommendations, technique coverage calculations, correlation scenarios, and constructor logic - Introduced unit tests for detection recommendation logic in `recommendations.rs`, verifying recommendations for various IOC types and MITRE techniques, as well as edge and fallback cases - Added tests to `transform.rs` for ground truth generation, including IOC and technique extraction, deduplication, share and credential handling, and domain admin/golden ticket logic - Implemented unit tests for scoring and evaluation in `evaluate.rs`, testing IOC/technique finding and missing logic, result structure, and score calculations - Provided tests for `AgentRole::parse` in `tool_registry/mod.rs` to ensure correct parsing of roles, aliases, case insensitivity, and round-trip conversions
**Changed:** - Updated test data throughout the codebase to consistently use the 192.168.58.x IP range instead of 10.0.0.x and 192.168.1.x - Standardized hostnames and domain names in tests to use "contoso.local" and "fabrikam.local" instead of "corp.local", "fabrikam.com", or "essos.local" - Adjusted sample outputs, assertions, and data in test modules to match the new IP and domain conventions for improved clarity and consistency - Modified documentation comments and example strings in test code to reflect new IP/domain standards
**Added:** - Unit tests for `format_duration` in `ares-cli/src/ops/loot/format/mod.rs`, covering zero, seconds, minutes, hours, and edge cases - Unit tests for `crack_dedup_key` in `ares-cli/src/orchestrator/automation/mod.rs`, including case normalization, hash truncation, and different hash lengths - Comprehensive tests for formatting functions in `ares-tools/src/blue/grafana/query.rs`, covering alerts, annotations, dashboard search, dashboard details, and pretty JSON output - Extensive tests in `ares-tools/src/parsers/delegation.rs` for the `extract_spn_from_parts` helper, validating SPN extraction logic and edge cases - Additional tests in `ares-tools/src/parsers/spider.rs` for domain/user splitting, FQDN resolution, password plausibility, and capture helpers - New tests in `ares-tools/src/parsers/users_shares.rs` to ensure robust parsing and deduplication of shares/users, header/edge case skipping, and correct field handling - Tests for `InvestigationSnapshot::from_blue_state` and related logic in `ares-core/src/eval/scorers/types.rs`, verifying correct mapping from blue team state to snapshot, field extraction, deduplication, and value clamping **Changed:** - Updated test constants and domain/IP values throughout the codebase to consistently use the `contoso.local`, `CONTOSO`, and `192.168.58.x` naming scheme instead of previous placeholder domains like `corp.local`, `CORP`, and `10.0.0.x` - Adjusted test expectations to match new default values and output formats where relevant (e.g., domain, IP, comments, summaries) - Improved test data to cover more edge cases, such as empty and minimal inputs, case normalization, and fallback logic in formatting and parsing functions **Removed:** - Eliminated legacy test domain and IP references to maintain consistency and realism in test scenarios
**Added:** - Added test coverage for loading listener IP and JSON strategy from environment variables within the main configuration test **Removed:** - Removed separate test functions for listener IP and JSON strategy environment variable handling, as their logic is now included in the consolidated test
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #232 +/- ##
===========================================
+ Coverage 58.91% 74.85% +15.93%
===========================================
Files 383 383
Lines 67884 80146 +12262
===========================================
+ Hits 39992 59990 +19998
+ Misses 27892 20156 -7736 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
**Added:** - Added tests covering string, hash, set, list, and sorted set commands to verify MockRedisConnection behavior (e.g., SETEX, SETNX, DEL, EXISTS, HSET, SADD, RPUSH, LPOP, BRPOP, ZADD, SCAN) - Included tests for command variants, error handling (such as unsupported commands), and edge cases (negative indices, out-of-range, missing keys) - Added tests for default initialization and get_db method to ensure correct default behavior
**Changed:** - Reordered "low-hanging fruit without credentials" logic to run before "no_cred" technique enforcement in credential access prompt generation to ensure spray tasks use the full common-password list - Updated password spray instructions in "no_cred" to clarify that each password spray call must be invoked separately and provided explicit example calls with multiple common passwords - Adjusted test for low-hanging fruit prompt to expect the correct prompt string after logic reordering and output changes
l50
added a commit
that referenced
this pull request
Apr 23, 2026
) **Key Changes:** - Added extensive unit and integration tests across all modules in ares-cli, ares-core, ares-llm, and ares-tools - Improved test coverage for pure functions, builder APIs, input validation, and end-to-end tool workflows - Introduced mock executor for ares-tools to enable isolated tool wrapper testing - Enhanced test assertions to cover edge cases, deduplication, and error handling **Added:** - Unit tests for config, deduplication, label normalization, user and credential processing, and MITRE technique detection in ares-cli - Direct tests for time window plumbing, builder logic, and detection query composition in detection/techniques - Test modules for orchestrator automation helpers, deduplication keys, domain/host logic, and parent/child domain matching - Test coverage for orchestrator state persistence, publishing, milestones, and redis-backed dedup sets - Tests for result processing, admin checks, parsing, timeline event classification, and critical hash detection - Mock Redis connection and in-memory state for ares-core, including scan, pipeline, and set/hash/list operations - End-to-end and unit tests for gap analysis, recommendations, ground truth transformation, and scoring in ares-core eval modules - Tests for telemetry propagation (traceparent injection/setting), state readers/writers, and blue operations in ares-core - Blue and red/blue correlation tests for technique matching, gap reason analysis, and coverage calculation - Default test features for blue team support in ares-core, ares-llm, and ares-tools - Unit and integration tests for tool registry logic, agent role parsing, and blue tool capability assignment in ares-llm - Test coverage for all tool wrapper functions in ares-tools, including argument validation, command builder APIs, and output sanitization - Tests for output parsers, including SMB, LDAP, BloodHound, delegation, and credential spider logic **Changed:** - Refactored code to allow easier dependency injection for testability (e.g., generic TaskQueueCore over connection type) - Adjusted some test-only code paths to use #[cfg(test)] or #[cfg(feature = "test-utils")] - Improved test assertions to cover corner cases, deduplication, ordering, and fallback logic - Updated test data to use consistent sample IPs, domains, and hostnames across modules - Enhanced test performance by using in-memory or tempfile-backed stores for persistence tests **Removed:** - Unused or dead test helper modules (e.g., resume_helper.rs in orchestrator recovery) - Redundant #[allow(dead_code)] attributes on enums and structs now covered by tests - Legacy or placeholder test code in favor of comprehensive, behavior-driven test suites
l50
added a commit
that referenced
this pull request
Apr 23, 2026
) **Key Changes:** - Added extensive unit and integration tests across all modules in ares-cli, ares-core, ares-llm, and ares-tools - Improved test coverage for pure functions, builder APIs, input validation, and end-to-end tool workflows - Introduced mock executor for ares-tools to enable isolated tool wrapper testing - Enhanced test assertions to cover edge cases, deduplication, and error handling **Added:** - Unit tests for config, deduplication, label normalization, user and credential processing, and MITRE technique detection in ares-cli - Direct tests for time window plumbing, builder logic, and detection query composition in detection/techniques - Test modules for orchestrator automation helpers, deduplication keys, domain/host logic, and parent/child domain matching - Test coverage for orchestrator state persistence, publishing, milestones, and redis-backed dedup sets - Tests for result processing, admin checks, parsing, timeline event classification, and critical hash detection - Mock Redis connection and in-memory state for ares-core, including scan, pipeline, and set/hash/list operations - End-to-end and unit tests for gap analysis, recommendations, ground truth transformation, and scoring in ares-core eval modules - Tests for telemetry propagation (traceparent injection/setting), state readers/writers, and blue operations in ares-core - Blue and red/blue correlation tests for technique matching, gap reason analysis, and coverage calculation - Default test features for blue team support in ares-core, ares-llm, and ares-tools - Unit and integration tests for tool registry logic, agent role parsing, and blue tool capability assignment in ares-llm - Test coverage for all tool wrapper functions in ares-tools, including argument validation, command builder APIs, and output sanitization - Tests for output parsers, including SMB, LDAP, BloodHound, delegation, and credential spider logic **Changed:** - Refactored code to allow easier dependency injection for testability (e.g., generic TaskQueueCore over connection type) - Adjusted some test-only code paths to use #[cfg(test)] or #[cfg(feature = "test-utils")] - Improved test assertions to cover corner cases, deduplication, ordering, and fallback logic - Updated test data to use consistent sample IPs, domains, and hostnames across modules - Enhanced test performance by using in-memory or tempfile-backed stores for persistence tests **Removed:** - Unused or dead test helper modules (e.g., resume_helper.rs in orchestrator recovery) - Redundant #[allow(dead_code)] attributes on enums and structs now covered by tests - Legacy or placeholder test code in favor of comprehensive, behavior-driven test suites
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.
Key Changes:
Added:
Changed:
Removed: