Skip to content

Added new vCenter Login Banner run command with test coverage#413

Open
Kavyareddyguntaka11 wants to merge 9 commits into
mainfrom
kguntaka/36631481
Open

Added new vCenter Login Banner run command with test coverage#413
Kavyareddyguntaka11 wants to merge 9 commits into
mainfrom
kguntaka/36631481

Conversation

@Kavyareddyguntaka11

Copy link
Copy Markdown
Contributor

This PR closes WI-36631481

The changes in this PR are as follows:

  • Added new vCenter Login Banner run commands:

    • Set-VCLoginBanner
    • Get-VCLoginBanner
    • Remove-VCLoginBanner
  • Implemented compatibility and fallback handling for VCSA variants, including:

    • Inline and file-based content configuration
    • Read fallback behavior
    • Toggle verification behavior
  • Added and updated Pester test coverage for the new login banner run commands, including:

    • Fallback path validation
    • Failure scenario validation
    • Cleanup guardrails

I have read the contributor guidelines and have completed the following:

  • Formatted the code using VS Code default formatter for PowerShell.
  • Tested the code end-to-end against an SDDC.
  • Documented the functions using standard PowerShell markup and applied AVSAttribute to newly exported functions.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds new AVS Run Command cmdlets to manage the vCenter (VCSA) login banner via the pre-established SSH session, including compatibility fallbacks across VCSA variants, plus accompanying Pester coverage and module manifest updates.

Changes:

  • Added Set-VCLoginBanner, Get-VCLoginBanner, and Remove-VCLoginBanner cmdlets (with inline/file content fallback, consent toggle fallback, and optional UI page-source verification).
  • Added Normalize-VCBannerText helper for banner text normalization/cleanup prior to issuing VCSA commands.
  • Updated module manifest exports/version and extended Pester tests for the new cmdlets and fallback paths.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
tests/Microsoft.AVS.Management.Tests.ps1 Adds Pester coverage for banner text normalization and the new login banner cmdlets (including multiple fallback scenarios).
Microsoft.AVS.Management/Microsoft.AVS.Management.psm1 Implements the new login banner cmdlets using sso-config.sh via Invoke-SSHCommand, with fallback handling and optional verification.
Microsoft.AVS.Management/Microsoft.AVS.Management.psd1 Bumps module version and exports the new cmdlets.
Microsoft.AVS.Management/AVSGenericUtils.ps1 Adds Normalize-VCBannerText helper used by the new cmdlets.

Comment on lines +184 to +188
# Remove emojis and unsupported symbols, while preserving letters, numbers,
# punctuation, spaces, and new lines.
$String = $String -replace '[^\p{L}\p{N}\p{P}\p{Zs}\r\n]', ''

# Collapse repeated spaces and tabs per line, preserving line breaks.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed banner test normalize to preserve tabs and collapse.

Comment on lines +2060 to +2062
Describe "Get-VCLoginBanner" {
Context "Fallback Path" {
It "Should fallback to print command and set NamedOutputs when get command fails" {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

Comment on lines +2116 to +2118
Describe "Remove-VCLoginBanner" {
Context "Fallback Path" {
It "Should retry with fallback disable command when primary disable command fails" {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

…test cases of missing SSH for get and remove
et1975
et1975 previously approved these changes Jul 14, 2026
Kavyareddyguntaka11 and others added 2 commits July 17, 2026 09:31
The fallback banner-file commands wrapped single-quote-escaped, user-controlled
text inside an outer /bin/sh -c "..." (double quotes) with a second shell parse.
The POSIX single-quote escape ('"'"') and any literal double quote broke out of
the outer double quotes, allowing arbitrary command execution as root on the VCSA.

Run mkdir/printf/rm directly through the remote login shell (single parse) so the
single-quote escaping the primary path already relies on is sufficient. Add
regression tests (structural + real-shell execution) under Set-VCLoginBanner.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e4e1a2df-e3b1-49f0-833c-04f0ffc8b7b2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants