Skip to content

Commit b344e46

Browse files
committed
Add a test for authenticate error
Signed-off-by: Richard Wall <[email protected]>
1 parent 42f5861 commit b344e46

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pkg/internal/cyberark/dataupload/dataupload_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package dataupload_test
33
import (
44
"crypto/x509"
55
"encoding/pem"
6+
"errors"
67
"fmt"
78
"net/http"
89
"os"
@@ -84,6 +85,17 @@ func TestCyberArkClient_PostDataReadingsWithOptions_MockAPI(t *testing.T) {
8485
require.ErrorContains(t, err, "while retrieving snapshot upload URL: received response with status code 500: should authenticate using the correct bearer token")
8586
},
8687
},
88+
{
89+
name: "error contains authenticate error",
90+
payload: defaultPayload,
91+
opts: defaultOpts,
92+
authenticate: func(_ *http.Request) error {
93+
return errors.New("simulated-authenticate-error")
94+
},
95+
requireFn: func(t *testing.T, err error) {
96+
require.ErrorContains(t, err, "while retrieving snapshot upload URL: failed to authenticate request: simulated-authenticate-error")
97+
},
98+
},
8799
{
88100
name: "invalid JSON from server (RetrievePresignedUploadURL step)",
89101
payload: defaultPayload,

0 commit comments

Comments
 (0)