Skip to content

Conversation

tgauth
Copy link
Collaborator

@tgauth tgauth commented Jun 3, 2025

PR Summary

  • add sshd pester tests

PR Context

  • expand automated test suite

@tgauth
Copy link
Collaborator Author

tgauth commented Jun 3, 2025

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@tgauth
Copy link
Collaborator Author

tgauth commented Jun 4, 2025

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@tgauth tgauth requested review from vthiebaut10 and Copilot June 4, 2025 20:10
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds end-to-end Pester tests for the SSH server (sshd) and a cleanup test for the SSH client, and exposes the sshd service name in the test helper.

  • Introduces SSHD.Tests.ps1 with two SSHD-focused tests (LoginGraceTime expiry and virtual account spawning)
  • Extends SSH.Tests.ps1 to verify that closing an SSH session cleans up child processes
  • Updates OpenSSHTestHelper.psm1 to include SshdServiceName in the test environment

Reviewed Changes

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

File Description
regress/pesterTests/SSHD.Tests.ps1 New end-to-end tests for sshd child processes and accounts
regress/pesterTests/SSH.Tests.ps1 Added test verifying SSH session exit cleans up sshd PIDs
contrib/win32/openssh/OpenSSHTestHelper.psm1 Added SshdServiceName entry to $OpenSSHTestInfo

@tgauth
Copy link
Collaborator Author

tgauth commented Jun 4, 2025

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

$sshdPidsCountAfter = (Get-Process -Name sshd* | Select-Object -ExpandProperty Id).Count

if ($sshProc -and !$sshProc.HasExited) {
$sshProc | Stop-Process -Force
Copy link
Collaborator

Choose a reason for hiding this comment

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

If ssh process hasn't exited, should you also fail the test? Because that means that the time out failed, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This cleans up the ssh client process which will still be waiting on user input, even if the server side time out is successful.

@tgauth tgauth merged commit c1a8d54 into PowerShell:latestw_all Jul 21, 2025
4 checks passed
@tgauth tgauth deleted the add-sshd-tests branch July 21, 2025 19:47
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.

2 participants