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 e01e88c commit 65f665e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
6 changes: 4 additions & 2 deletions admin/commands/management/register_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package management

import (
"github.com/percona/pmm/api/managementpb/json/client/node"
"github.com/stretchr/testify/assert"
"testing"

"github.com/stretchr/testify/assert"

"github.com/percona/pmm/api/managementpb/json/client/node"
)

func TestRegisterResult(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion managed/services/management/mock_api_key_provider_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion managed/services/management/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,10 @@ func (s *NodeService) Register(ctx context.Context, req *managementpb.RegisterNo
// get authorization from headers.
md, ok := metadata.FromIncomingContext(ctx)
if !ok {
return nil, fmt.Errorf("cannot get headers from metadata")
msg := "Couldn't create Admin API Key: cannot get headers from metadata"
logrus.Errorln(msg)
res.Warning = msg
return res, nil
}
authorizationHeaders := md.Get("Authorization")
if len(authorizationHeaders) == 0 {
Expand Down
2 changes: 2 additions & 0 deletions managed/services/management/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package management

import (
"context"
"google.golang.org/grpc/metadata"
"testing"

"github.com/google/uuid"
Expand Down Expand Up @@ -53,6 +54,7 @@ func TestNodeService(t *testing.T) {

require.NoError(t, sqlDB.Close())
}
metadata.AppendToOutgoingContext(ctx, "Authorization", "Basic username:password")
var apiKeyProvider mockApiKeyProvider
apiKeyProvider.Test(t)
apiKeyProvider.On("CreateAdminAPIKey", ctx, mock.AnythingOfType("string")).Return(int64(0), "test-token", nil)
Expand Down

0 comments on commit 65f665e

Please sign in to comment.