Skip to content
Merged
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
15 changes: 15 additions & 0 deletions tests/ClientManagement/Update-PiHoleClient.Integration.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ Describe 'Update-PiHoleClient (Integration)' -Tag 'Integration' {
It 'updates only the comment, preserving Group' -Skip:(-not $script:ConfigAvailable) {
New-PiHoleClient -PiHoleServer $script:PiHoleServer -Password $script:PiHoleToken -IgnoreSsl $script:PiHoleIgnoreSsl -Client $script:TestClient -Comment 'original comment' | Out-Null

# The test server takes a moment to make a just-added client queryable/updatable again -
# a real hardware limitation of this Pi Zero W, not a module bug (same settle-time
# reasoning as tools/Update-ExampleOutput.ps1 uses for Lists/Domains/Groups).
Start-Sleep -Seconds 2

$result = Update-PiHoleClient -PiHoleServer $script:PiHoleServer -Password $script:PiHoleToken -IgnoreSsl $script:PiHoleIgnoreSsl -Client $script:TestClient -Comment 'updated comment'
$result | Format-List | Out-String | Write-Host

Expand All @@ -51,6 +56,8 @@ Describe 'Update-PiHoleClient (Integration)' -Tag 'Integration' {
It 'updates only Group, preserving the current comment' -Skip:(-not $script:ConfigAvailable) {
New-PiHoleClient -PiHoleServer $script:PiHoleServer -Password $script:PiHoleToken -IgnoreSsl $script:PiHoleIgnoreSsl -Client $script:TestClient -Comment 'keep this comment' | Out-Null

Start-Sleep -Seconds 2

$result = Update-PiHoleClient -PiHoleServer $script:PiHoleServer -Password $script:PiHoleToken -IgnoreSsl $script:PiHoleIgnoreSsl -Client $script:TestClient -Group $script:TestGroupName
$result | Format-List | Out-String | Write-Host

Expand All @@ -64,6 +71,8 @@ Describe 'Update-PiHoleClient (Integration)' -Tag 'Integration' {
It 'errors when -Group names a group that does not exist' -Skip:(-not $script:ConfigAvailable) {
New-PiHoleClient -PiHoleServer $script:PiHoleServer -Password $script:PiHoleToken -IgnoreSsl $script:PiHoleIgnoreSsl -Client $script:TestClient | Out-Null

Start-Sleep -Seconds 2

$result = Update-PiHoleClient -PiHoleServer $script:PiHoleServer -Password $script:PiHoleToken -IgnoreSsl $script:PiHoleIgnoreSsl -Client $script:TestClient -Group 'DefinitelyNotARealGroup' -ErrorVariable errOut -ErrorAction SilentlyContinue
Write-Host "Error ($($errOut.Count) entries, showing last): [$($errOut[-1])]"

Expand All @@ -75,6 +84,8 @@ Describe 'Update-PiHoleClient (Integration)' -Tag 'Integration' {
It 'returns the raw API response when RawOutput is set' -Skip:(-not $script:ConfigAvailable) {
New-PiHoleClient -PiHoleServer $script:PiHoleServer -Password $script:PiHoleToken -IgnoreSsl $script:PiHoleIgnoreSsl -Client $script:TestClient | Out-Null

Start-Sleep -Seconds 2

$result = Update-PiHoleClient -PiHoleServer $script:PiHoleServer -Password $script:PiHoleToken -IgnoreSsl $script:PiHoleIgnoreSsl -Client $script:TestClient -Comment 'raw output test' -RawOutput $true
$result | Format-List | Out-String | Write-Host

Expand All @@ -86,6 +97,8 @@ Describe 'Update-PiHoleClient (Integration)' -Tag 'Integration' {
It 'errors when neither Comment nor Group is specified' -Skip:(-not $script:ConfigAvailable) {
New-PiHoleClient -PiHoleServer $script:PiHoleServer -Password $script:PiHoleToken -IgnoreSsl $script:PiHoleIgnoreSsl -Client $script:TestClient | Out-Null

Start-Sleep -Seconds 2

$result = Update-PiHoleClient -PiHoleServer $script:PiHoleServer -Password $script:PiHoleToken -IgnoreSsl $script:PiHoleIgnoreSsl -Client $script:TestClient -ErrorVariable errOut -ErrorAction SilentlyContinue

$errOut | Should -Not -BeNullOrEmpty
Expand All @@ -102,6 +115,8 @@ Describe 'Update-PiHoleClient (Integration)' -Tag 'Integration' {
It 'errors when given a bad password' -Skip:(-not $script:ConfigAvailable) {
New-PiHoleClient -PiHoleServer $script:PiHoleServer -Password $script:PiHoleToken -IgnoreSsl $script:PiHoleIgnoreSsl -Client $script:TestClient | Out-Null

Start-Sleep -Seconds 2

$result = Update-PiHoleClient -PiHoleServer $script:PiHoleServer -Password 'definitely-not-the-real-token' -IgnoreSsl $script:PiHoleIgnoreSsl -Client $script:TestClient -Comment 'irrelevant' -ErrorVariable errOut -ErrorAction SilentlyContinue

$errOut | Should -Not -BeNullOrEmpty
Expand Down
Loading