Compare commits
No commits in common. "0d4eb555bdbc2fd713c4ff5354d5cf89d5534d8f" and "9a6b91f3ed01d456ba09df96a0e4f469848adf22" have entirely different histories.
0d4eb555bd
...
9a6b91f3ed
@ -42,7 +42,8 @@ begin {
|
||||
$ServerServiceInstalled = $true
|
||||
Write-Host 'Server service already installed.'
|
||||
} else {
|
||||
if (-not (Get-Command 'nssm.exe') ) {
|
||||
if (-not (Test-Path 'C:\Program Files\nssm') ) {
|
||||
# if ('nssm' -notin $env:PATH) {
|
||||
throw 'NSSM is not installed. Please install NSSM before attempting to install the server service.'
|
||||
}
|
||||
}
|
||||
@ -74,7 +75,7 @@ process {
|
||||
Expand-Archive -Path $ArchivePath -DestinationPath $DestinationPath -Force
|
||||
|
||||
# Add the DestinationPath to Path system environment variable
|
||||
if ($DestinationPath -notin $env:PATH) { $env:PATH = $env:PATH + ";$DestinationPath\"; [Environment]::SetEnvironmentVariable("Path", $env:PATH, [System.EnvironmentVariableTarget]::Machine) }
|
||||
if ($DestinationPath -notin $env:PATH) { [Environment]::SetEnvironmentVariable("Path", $env:Path + ";$DestinationPath\", [System.EnvironmentVariableTarget]::Machine) }
|
||||
|
||||
# Add firewall rule allowing application executable
|
||||
if ('Allow iPerf3' -notin (Get-NetFirewallRule).DisplayName) { New-NetFirewallRule -DisplayName 'Allow iPerf3' -Direction Inbound -Program $ExecutablePath -RemoteAddress Any -Profile Any -Action Allow }
|
||||
|
||||
@ -1,51 +0,0 @@
|
||||
Describe 'Install-WinAcme' {
|
||||
BeforeAll {
|
||||
function Uninstall-WinAcme {
|
||||
param (
|
||||
[string]$DestinationPath
|
||||
)
|
||||
|
||||
# Remove the installation directory
|
||||
if (Test-Path -Path $DestinationPath) {
|
||||
Remove-Item -Path $DestinationPath -Recurse -Force
|
||||
}
|
||||
|
||||
# Remove from PATH
|
||||
$env:PATH = $env:PATH -replace [regex]::Escape("$DestinationPath\"), ''
|
||||
[Environment]::SetEnvironmentVariable("Path", $env:PATH, [System.EnvironmentVariableTarget]::Machine)
|
||||
}
|
||||
|
||||
# Clean up any existing win-acme installation
|
||||
Uninstall-WinAcme -DestinationPath 'C:\Program Files\win-acme'
|
||||
|
||||
# Load the Install-WinAcme function
|
||||
Set-Item function:Install-WinAcme ([ScriptBlock]::Create((Get-Content -Raw $PSCommandPath.Replace('.Tests.ps1', '.ps1'))))
|
||||
}
|
||||
|
||||
It 'Has the correct parameters' {
|
||||
$params = (Get-Command Install-WinAcme).Parameters
|
||||
|
||||
$params.ContainsKey('DestinationPath') | Should -Be $true
|
||||
$params['DestinationPath'].ParameterType.Name | Should -Be 'String'
|
||||
}
|
||||
|
||||
It 'Should download and install win-acme without errors' {
|
||||
{ Install-WinAcme -DestinationPath 'C:\Program Files\win-acme' } | Should -Not -Throw
|
||||
}
|
||||
|
||||
It 'Should add win-acme to the system PATH' {
|
||||
$env:PATH | Should -Match 'C:\\Program Files\\win-acme\\'
|
||||
}
|
||||
|
||||
It 'Should create the win-acme installation directory' {
|
||||
Test-Path -Path 'C:\Program Files\win-acme' | Should -Be $true
|
||||
}
|
||||
|
||||
It 'Should create the wacs executable in the installation directory' {
|
||||
Test-Path -Path 'C:\Program Files\win-acme\wacs.exe' | Should -Be $true
|
||||
}
|
||||
|
||||
AfterAll {
|
||||
Uninstall-WinAcme -DestinationPath 'C:\Program Files\win-acme'
|
||||
}
|
||||
}
|
||||
@ -18,7 +18,7 @@ param (
|
||||
|
||||
begin {
|
||||
# Prep
|
||||
$Releases = (Invoke-WebRequest 'https://api.github.com/repos/win-acme/win-acme/releases' -UseBasicParsing).Content | ConvertFrom-Json | Where-Object { $_.prerelease -eq $false -and $_.draft -eq $false }
|
||||
$Releases = (Invoke-WebRequest 'https://api.github.com/repos/win-acme/win-acme/releases').Content | ConvertFrom-Json | Where-Object { $_.prerelease -eq $false -and $_.draft -eq $false }
|
||||
$ReleaseTag = ($Releases | Select-Object -First 1).tag_name
|
||||
|
||||
# $InstallerUrl = 'https://github.com/win-acme/win-acme/releases/download/v2.2.9.1701/win-acme.v2.2.9.1701.x64.pluggable.zip'
|
||||
@ -50,7 +50,7 @@ process {
|
||||
Expand-Archive -Path $ArchivePath -DestinationPath $DestinationPath -Force
|
||||
|
||||
# Add the DestinationPath to Path system environment variable
|
||||
if ($DestinationPath -notin $env:PATH) { $env:PATH = $env:PATH + ";$DestinationPath\"; [Environment]::SetEnvironmentVariable("Path", $env:PATH, [System.EnvironmentVariableTarget]::Machine) }
|
||||
if ($DestinationPath -notin $env:PATH) { [Environment]::SetEnvironmentVariable("Path", $env:Path + ";$DestinationPath\", [System.EnvironmentVariableTarget]::Machine) }
|
||||
} catch {
|
||||
throw "Failed installing application. $_"
|
||||
}
|
||||
|
||||
@ -1,36 +1,6 @@
|
||||
Describe 'Install-IPerf3' {
|
||||
BeforeAll {
|
||||
function Uninstall-IPerf3 {
|
||||
param (
|
||||
[string]$DestinationPath = 'C:\Program Files\iPerf3'
|
||||
)
|
||||
|
||||
# Stop and remove the service if it exists
|
||||
if (Get-Service -Name iperf3server -ErrorAction SilentlyContinue) {
|
||||
Stop-Service -Name iperf3server -Force
|
||||
Remove-Service -Name iperf3server
|
||||
}
|
||||
|
||||
# Remove the installation directory
|
||||
if (Test-Path -Path $DestinationPath) {
|
||||
Remove-Item -Path $DestinationPath -Recurse -Force
|
||||
}
|
||||
|
||||
# Remove firewall rule
|
||||
if ('Allow iPerf3' -in (Get-NetFirewallRule).DisplayName) {
|
||||
Remove-NetFirewallRule -DisplayName 'Allow iPerf3'
|
||||
}
|
||||
|
||||
# Remove from PATH
|
||||
$env:PATH = $env:PATH -replace [regex]::Escape("$DestinationPath\"), ''
|
||||
[Environment]::SetEnvironmentVariable("Path", $env:PATH, [System.EnvironmentVariableTarget]::Machine)
|
||||
}
|
||||
|
||||
# Clean up any existing iPerf3 installation
|
||||
Uninstall-IPerf3 -DestinationPath 'C:\Program Files\iPerf3'
|
||||
|
||||
# Load the Install-iPerf3 function
|
||||
Set-Item function:Install-IPerf3 ([ScriptBlock]::Create((Get-Content -Raw $PSCommandPath.Replace('.Tests.ps1', '.ps1'))))
|
||||
Set-Item function:Install-IPerf3 ([ScriptBlock]::Create((Get-Content -Raw 'windows\Install-iPerf3.ps1')))
|
||||
}
|
||||
|
||||
It 'Has the correct parameters' {
|
||||
@ -64,6 +34,16 @@ Describe 'Install-IPerf3' {
|
||||
$firewallRule = Get-NetFirewallRule -DisplayName 'Allow iPerf3' -ErrorAction SilentlyContinue
|
||||
$firewallRule | Should -Not -Be $null
|
||||
}
|
||||
|
||||
AfterAll {
|
||||
# Clean up any existing iPerf3 installation
|
||||
if (Get-Service -Name iperf3server -ErrorAction SilentlyContinue) {
|
||||
Stop-Service -Name iperf3server -Force
|
||||
Remove-Service -Name iperf3server
|
||||
}
|
||||
Remove-Item -Path 'C:\Program Files\iPerf3' -Recurse -Force -ErrorAction SilentlyContinue
|
||||
Remove-NetFirewallRule -DisplayName 'Allow iPerf3' -ErrorAction SilentlyContinue
|
||||
}
|
||||
}
|
||||
|
||||
Context 'With ServerService parameter' {
|
||||
@ -73,9 +53,15 @@ Describe 'Install-IPerf3' {
|
||||
$service | Should -Not -Be $null
|
||||
$service.Status | Should -Be 'Running'
|
||||
}
|
||||
}
|
||||
|
||||
AfterAll {
|
||||
Uninstall-IPerf3 -DestinationPath 'C:\Program Files\iPerf3'
|
||||
# Clean up any existing iPerf3 installation
|
||||
if (Get-Service -Name iperf3server -ErrorAction SilentlyContinue) {
|
||||
Stop-Service -Name iperf3server -Force
|
||||
Remove-Service -Name iperf3server
|
||||
}
|
||||
Remove-Item -Path 'C:\Program Files\iPerf3' -Recurse -Force -ErrorAction SilentlyContinue
|
||||
Remove-NetFirewallRule -DisplayName 'Allow iPerf3' -ErrorAction SilentlyContinue
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user