diff --git a/.github/workflows/pullrequest.yml b/.github/workflows/pullrequest.yml index 64aba97..050dfb1 100644 --- a/.github/workflows/pullrequest.yml +++ b/.github/workflows/pullrequest.yml @@ -51,8 +51,7 @@ jobs: - name: Run Pester Tests shell: pwsh run: | - Invoke-Pester -Path @( - './ScheduledTasks/Tests' + Invoke-Pester -Path @( './ScheduledTasks/ReplayParkedQueue/Tests' './ScheduledTasks/SettlementProcessing/Tests' './ScheduledTasks/DailySupportCheck/Tests' diff --git a/ScheduledTasks/AutoScavenge/Scavenge.xml b/ScheduledTasks/AutoScavenge/Scavenge.xml deleted file mode 100644 index 71db543..0000000 Binary files a/ScheduledTasks/AutoScavenge/Scavenge.xml and /dev/null differ diff --git a/ScheduledTasks/AutoScavenge/scavenge.ps1 b/ScheduledTasks/AutoScavenge/scavenge.ps1 deleted file mode 100644 index a730b8b..0000000 --- a/ScheduledTasks/AutoScavenge/scavenge.ps1 +++ /dev/null @@ -1,36 +0,0 @@ -param( - [string]$BaseUrl = "http://localhost:2113", - [string]$Username, - [System.Security.SecureString]$Password, - [System.Management.Automation.PSCredential]$Credential -) - -$BaseUrl = $BaseUrl.TrimEnd('/') -$uri = "$BaseUrl/admin/scavenge" - -$headers = @{ - Accept = 'application/json' - 'Content-Type' = 'application/json' -} - -if ($Credential) { - $pair = "$($Credential.UserName)`:$($Credential.GetNetworkCredential().Password)" - $bytes = [System.Text.Encoding]::ASCII.GetBytes($pair) - $encoded = [Convert]::ToBase64String($bytes) - $headers['Authorization'] = "Basic $encoded" -} -elseif (-not [string]::IsNullOrWhiteSpace($Username) -and -not [string]::IsNullOrWhiteSpace($Password)) { - $usernameCredential = [System.Management.Automation.PSCredential]::new($Username, $Password) - $pair = "$($usernameCredential.UserName)`:$($usernameCredential.GetNetworkCredential().Password)" - $bytes = [System.Text.Encoding]::ASCII.GetBytes($pair) - $encoded = [Convert]::ToBase64String($bytes) - $headers['Authorization'] = "Basic $encoded" -} - -try { - Invoke-RestMethod -Method Post -Uri $uri -Headers $headers -} -catch { - Write-Error "POST to $uri failed: $($_.Exception.Message)" - exit 1 -} diff --git a/ScheduledTasks/DailySupportCheck/daily-support-check.json b/ScheduledTasks/DailySupportCheck/daily-support-check.json index 1f2989b..1984d75 100644 --- a/ScheduledTasks/DailySupportCheck/daily-support-check.json +++ b/ScheduledTasks/DailySupportCheck/daily-support-check.json @@ -39,11 +39,6 @@ "Name": "Replay Parked Queues", "Path": "\\", "ExpectedRunIntervalMinutes": 1440 - }, - { - "Name": "Scavenge", - "Path": "\\", - "ExpectedRunIntervalMinutes": 10080 } ] }, diff --git a/ScheduledTasks/Tests/Scavenge.Tests.ps1 b/ScheduledTasks/Tests/Scavenge.Tests.ps1 deleted file mode 100644 index c023ac5..0000000 --- a/ScheduledTasks/Tests/Scavenge.Tests.ps1 +++ /dev/null @@ -1,102 +0,0 @@ -BeforeAll { - $script:scriptUnderTest = (Resolve-Path (Join-Path (Join-Path (Split-Path $PSScriptRoot -Parent) 'AutoScavenge') 'scavenge.ps1')).Path -} - -Describe 'AutoScavenge\scavenge.ps1' { - It 'posts to /admin/scavenge after trimming a trailing slash from BaseUrl' { - $expectedUri = 'http://localhost:2113/admin/scavenge' - $captured = [pscustomobject]@{ - Count = 0 - Uri = $null - Headers = $null - } - - Mock Invoke-RestMethod { - $captured.Count++ - $captured.Uri = $Uri - $captured.Headers = $Headers - @{ status = 'ok' } - } -ParameterFilter { - $Method -eq 'Post' - } - - & $script:scriptUnderTest -BaseUrl 'http://localhost:2113/' - - $captured.Count | Should -Be 1 - $captured.Uri | Should -Be $expectedUri - $captured.Headers.Accept | Should -Be 'application/json' - $captured.Headers.'Content-Type' | Should -Be 'application/json' - $captured.Headers.ContainsKey('Authorization') | Should -BeFalse - } - - It 'adds a Basic Authorization header when username and password are both provided' { - $expectedUri = 'http://localhost:2113/admin/scavenge' - $expectedAuth = 'Basic ' + [Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes('alice:secret')) - $captured = [pscustomobject]@{ - Count = 0 - Uri = $null - Headers = $null - } - - Mock Invoke-RestMethod { - $captured.Count++ - $captured.Uri = $Uri - $captured.Headers = $Headers - @{ status = 'ok' } - } -ParameterFilter { - $Method -eq 'Post' - } - - & $script:scriptUnderTest -BaseUrl 'http://localhost:2113' -Username 'alice' -Password (ConvertTo-SecureString 'secret' -AsPlainText -Force) - - $captured.Count | Should -Be 1 - $captured.Uri | Should -Be $expectedUri - $captured.Headers.Authorization | Should -Be $expectedAuth - } - - It 'does not add an Authorization header when only one credential is supplied' { - $captured = [pscustomobject]@{ - Count = 0 - Uri = $null - Headers = $null - } - - Mock Invoke-RestMethod { - $captured.Count++ - $captured.Uri = $Uri - $captured.Headers = $Headers - @{ status = 'ok' } - } -ParameterFilter { - $Method -eq 'Post' - } - - & $script:scriptUnderTest -BaseUrl 'http://localhost:2113' -Username 'alice' - - $captured.Count | Should -Be 1 - $captured.Uri | Should -Be 'http://localhost:2113/admin/scavenge' - $captured.Headers.ContainsKey('Authorization') | Should -BeFalse - } - - It 'does not add an Authorization header when only a password is supplied' { - $captured = [pscustomobject]@{ - Count = 0 - Uri = $null - Headers = $null - } - - Mock Invoke-RestMethod { - $captured.Count++ - $captured.Uri = $Uri - $captured.Headers = $Headers - @{ status = 'ok' } - } -ParameterFilter { - $Method -eq 'Post' - } - - & $script:scriptUnderTest -BaseUrl 'http://localhost:2113' -Password (ConvertTo-SecureString 'secret' -AsPlainText -Force) - - $captured.Count | Should -Be 1 - $captured.Uri | Should -Be 'http://localhost:2113/admin/scavenge' - $captured.Headers.ContainsKey('Authorization') | Should -BeFalse - } -}