From 245c7a699af243e4f707d136dd011151211004a7 Mon Sep 17 00:00:00 2001 From: ScottishDex <35346954+ScotDex@users.noreply.github.com> Date: Tue, 8 Jul 2025 22:58:17 +0100 Subject: [PATCH] Add Pester test for API auth header and update CI --- .github/workflows/powershell.yml | 5 +++++ tests/api-auth-script.Tests.ps1 | 9 +++++++++ 2 files changed, 14 insertions(+) create mode 100644 tests/api-auth-script.Tests.ps1 diff --git a/.github/workflows/powershell.yml b/.github/workflows/powershell.yml index 21cb3ad..a33f2a7 100644 --- a/.github/workflows/powershell.yml +++ b/.github/workflows/powershell.yml @@ -42,6 +42,11 @@ jobs: includeRule: '"PSAvoidGlobalAliases", "PSAvoidUsingConvertToSecureStringWithPlainText"' output: results.sarif + - name: Run Pester tests + shell: pwsh + run: | + Invoke-Pester -Path ./tests + # Upload the SARIF file generated in the previous step - name: Upload SARIF results file uses: github/codeql-action/upload-sarif@v3 diff --git a/tests/api-auth-script.Tests.ps1 b/tests/api-auth-script.Tests.ps1 new file mode 100644 index 0000000..de756a4 --- /dev/null +++ b/tests/api-auth-script.Tests.ps1 @@ -0,0 +1,9 @@ +Describe "api-auth-script" { + It "creates the expected Authorization header" { + Mock Invoke-RestMethod {} + . "$PSScriptRoot/../API/api-auth-script.ps1" + $expected = 'Basic MTIzIDk3IDEwMCAxMDkgMTA1IDExMCAxMjUgNTggMTIzIDExMiA5NyAxMTUgMTE1IDExOSAxMTEgMTE0IDEwMCAxMjU=' + $basicAuthHeader | Should -Be $expected + } +} +