Skip to content

Commit d06b4c0

Browse files
committed
Fix api key validation tests
1 parent 76b3a6e commit d06b4c0

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

internal/tiger/api/client_util_test.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ package api_test
22

33
import (
44
"context"
5+
"io"
56
"net/http"
7+
"strings"
68
"testing"
79

810
"go.uber.org/mock/gomock"
@@ -45,21 +47,24 @@ func TestValidateAPIKeyWithClient(t *testing.T) {
4547
m.EXPECT().
4648
GetProjectsProjectIdServicesWithResponse(gomock.Any(), "00000000-0000-0000-0000-000000000000").
4749
Return(&api.GetProjectsProjectIdServicesResponse{
48-
HTTPResponse: &http.Response{StatusCode: 401},
50+
HTTPResponse: &http.Response{StatusCode: 401,
51+
Body: io.NopCloser(strings.NewReader(`{"message":"Invalid or missing authentication credentials"}`))},
4952
}, nil)
5053
},
51-
expectedError: "invalid API key: authentication failed",
54+
expectedError: "Invalid or missing authentication credentials",
5255
},
5356
{
5457
name: "invalid API key - 403 response",
5558
setupMock: func(m *mocks.MockClientWithResponsesInterface) {
5659
m.EXPECT().
5760
GetProjectsProjectIdServicesWithResponse(gomock.Any(), "00000000-0000-0000-0000-000000000000").
5861
Return(&api.GetProjectsProjectIdServicesResponse{
59-
HTTPResponse: &http.Response{StatusCode: 403},
62+
HTTPResponse: &http.Response{StatusCode: 403,
63+
Body: io.NopCloser(strings.NewReader(`{"message":"Invalid or missing authentication credentials"}`)),
64+
},
6065
}, nil)
6166
},
62-
expectedError: "invalid API key: authentication failed",
67+
expectedError: "Invalid or missing authentication credentials",
6368
},
6469
{
6570
name: "unexpected response - 500",

0 commit comments

Comments
 (0)