Skip to content

Commit

Permalink
PMM-11714 Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
BupycHuk committed Sep 7, 2023
1 parent 65f665e commit b4952dd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ services:
# For headless delve
- ${PMM_PORT_DELVE:-2345}:2345
# PG
- ${PMM_PORT_PG:-15432}:5432
- ${PMM_PORT_PG:-5432}:5432
# VM
- ${PMM_PORT_VM:-9090}:9090
# CH
Expand Down
2 changes: 1 addition & 1 deletion managed/services/management/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func (s *NodeService) Register(ctx context.Context, req *managementpb.RegisterNo
if len(authorizationHeaders) == 0 {
return nil, status.Error(codes.Unauthenticated, "Authorization error.")
}
var headers http.Header
headers := http.Header{}
headers.Set("Authorization", authorizationHeaders[0])
if !s.akp.IsAPIKeyAuth(headers) {
apiKeyName := fmt.Sprintf("pmm-agent-%s-%d", req.NodeName, rand.Int63()) //nolint:gosec
Expand Down
6 changes: 5 additions & 1 deletion managed/services/management/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,13 @@ func TestNodeService(t *testing.T) {

require.NoError(t, sqlDB.Close())
}
metadata.AppendToOutgoingContext(ctx, "Authorization", "Basic username:password")
md := metadata.New(map[string]string{
"Authorization": "Basic username:password",
})
ctx = metadata.NewIncomingContext(ctx, md)
var apiKeyProvider mockApiKeyProvider
apiKeyProvider.Test(t)
apiKeyProvider.On("IsAPIKeyAuth", mock.Anything).Return(false)
apiKeyProvider.On("CreateAdminAPIKey", ctx, mock.AnythingOfType("string")).Return(int64(0), "test-token", nil)
s = NewNodeService(db, &apiKeyProvider)

Expand Down

0 comments on commit b4952dd

Please sign in to comment.