Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[WiP] Add pester test for UnusedConnectionTimeout #663

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

Open
vthiebaut10 wants to merge 3 commits into PowerShell:latestw_all
base: latestw_all
Choose a base branch
Loading
from vthiebaut10:unused_connection_timeout_test
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions regress/pesterTests/SSHDConfig.tests.ps1
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Describe "Tests of sshd_config" -Tags "CI" {

Add-Content $sshdconfig_custom @"

UnusedConnectionTimeout 2
DenyUsers denyuser1 deny*2 denyuse?3,
AllowUsers allowuser1 allowu*r2 allow?se?3 allowuser4 localuser1 localu*r2 loc?lu?er3 localadmin matchuser
DenyGroups denygroup1 denygr*p2 deny?rou?3
Expand Down Expand Up @@ -211,6 +212,27 @@ Match User matchuser
$tC++
}

It "$tC.$tI-Test UnusedConnectionTimeout" -skip:$skip {
#Run
Start-SSHDTestDaemon -WorkDir $opensshbinpath -Arguments "-d -f $sshdConfigPath -E $sshdlog" -Port $port
Add-UserToLocalGroup -UserName $localuser1 -Password $password -GroupName $allowGroup1

# Start SSH process with Remote Forwarding Option to create a connection that doesn't prevent "Unused Connection Timeout"
$p = Start-Process -FilePath ssh -ArgumentList "-p $port -N -T -R 35000 $localuser1@$server" -PassThru
Wait-Process $p.Id -Timeout 10 -ErrorAction SilentlyContinue -ErrorVariable timeouted
Copy link

@PaulHigin PaulHigin Feb 10, 2023

Choose a reason for hiding this comment

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

We usually put a wait action in a retry loop, so that the test will finish quicker if the timeout is around the expected 2 minutes (seconds?). The retry loop will retry to up to a maximum time to wait. Also we should try to let the test finish as soon as possible, is the 2 2 minutes or seconds?

vthiebaut10 reacted with thumbs up emoji
Copy link
Collaborator Author

@vthiebaut10 vthiebaut10 Feb 10, 2023

Choose a reason for hiding this comment

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

It's 2 seconds

PaulHigin reacted with thumbs up emoji
if (-not $p.HasExited)
{
Stop-Process $p.Id -Force
}

$timeouted | Should Be $null
$p.ExitCode | Should Be 255

Stop-SSHDTestDaemon -Port $port
sleep $sshdDelay
Remove-UserFromLocalGroup -UserName $localuser1 -GroupName $allowGroup1
}

It "$tC.$tI-User with full name in the list of AllowUsers" -skip:$skip {
#Run
Start-SSHDTestDaemon -WorkDir $opensshbinpath -Arguments "-d -f $sshdConfigPath -E $sshdlog" -Port $port
Expand Down

AltStyle によって変換されたページ (->オリジナル) /