Skip to content

Test infrastructure: add runtime behavioral tests (mocked Invoke-TssApi) — current tests are shape-only #479

Description

@jagger

Summary

Every headline fix in 0.62.1 rides on the same test template: parameter surface + OutputType.Name assertion. None of the fixes has a runtime test that would catch regression to the pre-fix behavior. Specifically:

A future refactor could revert ConvertFrom-Json to Substring, revert camelCase to PascalCase, or make -Type mandatory again, and CI would pass.

Proposed fix

Introduce a mocked-Invoke-TssApi test pattern using Pester 5's Mock + Assert-VerifiableMock. For each headline fix, add a test that:

  • Mocks Invoke-TssApi to return a fixture response.
  • Calls the cmdlet.
  • Asserts on the JSON body sent, the return type, and/or the return shape (rather than only the parameter surface).

Fixture data for each:

  • Search-TssSecret: mock a records array with 0, 1, and 3 entries. Assert return is [Summary[]] in all cases; assert .Count matches.
  • Get-TssSecretField: mock Content = '""', '"MyPassword"', '"Im\\\"P@ss\\\"word"', and empty Content. Assert decoded value matches expectation.
  • New-TssSecretPermission: capture \$invokeParams.Body via mock parameter filter; assert JSON keys are secretAccessRoleName, secretId, username, groupName.
  • Start-TssSecretChangePassword: call without -Type; assert the mocked body has PasswordType = 0 (Random).

This work would also standardize a pattern for future behavioral tests, which the module has largely avoided in favor of metadata-only checks.

Scope

This is a larger piece of work than a typical bug PR — likely worth a small sub-plan and its own release. Not a 0.62.1 blocker; the fixes are lab-verified end-to-end for the current release. But the next regression will be silent unless this coverage exists.

Discovery

Consolidated PR review of v0.62.0 → dev (0.62.1 candidate). Called out under FUNC-1 by the functionality attacker.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions