Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TR-1: Implement Unit Testing: Test-HawkInvestigationParameter.Tests.ps1 #253

Open
jonnybottles opened this issue Jan 26, 2025 · 0 comments
Assignees
Labels
status/backlog In backlog / validated type/feature New feature or request type/gaant Used for Gaant Visualization

Comments

@jonnybottles
Copy link
Collaborator

jonnybottles commented Jan 26, 2025

Test Plan: Test-HawkInvestigationParameter Function

The Test-HawkInvestigationParameter function is a critical internal helper function in the Hawk module that validates parameter combinations and constraints for investigation operations. It is used by both Start-HawkTenantInvestigation and Start-HawkUserInvestigation to ensure valid parameter combinations and values before proceeding with investigations.

Test Requirements Based on Provided Test Cases

FilePath Validation

  • Test Case 1: Missing FilePath in non-interactive mode should fail validation.
  • Test Case 2: Invalid FilePath should fail validation.
  • Test Case 3: Valid FilePath should pass validation.

Date Parameter Validation

  • Test Case 4: Valid StartDate/EndDate combination should pass validation.
  • Test Case 5: StartDate after EndDate should fail with appropriate error.
  • Test Case 6: Date range exceeding 365 days should fail validation.
  • Test Case 7: EndDate in future should fail validation.
  • Test Case 8: Valid DaysToLookBack (1-365) should pass validation.
  • Test Case 9: Invalid DaysToLookBack (0) should fail validation.
  • Test Case 10: Invalid DaysToLookBack (366) should fail validation.

Parameter Combination Validation

  • Test Case 11: Missing both StartDate/EndDate and DaysToLookBack in non-interactive mode should fail.
  • Test Case 12: DaysToLookBack with EndDate (no StartDate) should pass validation.
  • Test Case 13: DaysToLookBack with StartDate should fail validation with appropriate error.
  • Test Case 14: All valid parameters should pass validation.
  • Test Case 15: StartDate with EndDate (no DaysToLookBack) should pass validation.

Return Object Validation

  • Test Case 16: Verify error messages array for failed validations.
  • Test Case 17: Verify IsValid boolean property correctly reflects validation state.

Testing Instructions

  1. Create Test File: Create a new file named Test-HawkInvestigationParameter.Tests.ps1 in the Hawk/tests/functions/ directory.
  2. Setup Mocks: Use Pester's BeforeAll block to set up any required mocks.
  3. Group Tests:
    • Use Describe and Context blocks to organize tests logically.
    • Follow existing test patterns in the functions directory.
  4. Test Coverage:
    • Ensure tests cover both interactive and non-interactive validation modes.
    • Test both error message content and validation result properties.
    • Verify error messages match expected format and content.
  5. Validation:
    • Assert that failed validations produce the expected error messages.
    • Confirm that the IsValid property accurately reflects the validation state.

Objective

These tests will ensure the reliability of Test-HawkInvestigationParameter as a critical validation component in the Hawk module.


@jonnybottles jonnybottles added status/backlog In backlog / validated type/feature New feature or request type/gaant Used for Gaant Visualization labels Jan 26, 2025
@jonnybottles jonnybottles self-assigned this Jan 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/backlog In backlog / validated type/feature New feature or request type/gaant Used for Gaant Visualization
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant