-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PMM-11714 Don't return an error if API key can't be created. #2469
Changes from 13 commits
ba37ba0
e01e88c
65f665e
b4952dd
c5516fc
3942319
ae1f6b3
2d9d335
49a023d
c3d528d
2736632
ba15a55
a0f479d
d5f290d
be67775
d994342
0c5521c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright (C) 2023 Percona LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package management | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/percona/pmm/api/managementpb/json/client/node" | ||
) | ||
|
||
func TestRegisterResult(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
result registerResult | ||
want string | ||
}{ | ||
{ | ||
name: "Success", | ||
result: registerResult{ | ||
PMMAgent: &node.RegisterNodeOKBodyPMMAgent{ | ||
AgentID: "/agent_id/new_id", | ||
RunsOnNodeID: "/node_id/second_id", | ||
}, | ||
Warning: "", | ||
}, | ||
want: `pmm-agent registered. | ||
pmm-agent ID: /agent_id/new_id | ||
Node ID : /node_id/second_id | ||
`, | ||
}, | ||
{ | ||
name: "With warning", | ||
result: registerResult{ | ||
PMMAgent: &node.RegisterNodeOKBodyPMMAgent{ | ||
AgentID: "/agent_id/warning", | ||
RunsOnNodeID: "/node_id/warning_node", | ||
}, | ||
Warning: "Couldn't create Admin API Key", | ||
}, | ||
want: `pmm-agent registered. | ||
pmm-agent ID: /agent_id/warning | ||
Node ID : /node_id/warning_node | ||
|
||
Warning: Couldn't create Admin API Key | ||
`, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
assert.Equalf(t, tt.want, tt.result.String(), "String()") | ||
}) | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was curious - is there anything fatal that can happen if we can't generate the admin role api key? and is there anything the user can do in such a case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we discussed with GAS team and made decission that register shouldn't fail in case it's not possible to create an API key. So pmm-agent will keep using user credentials instead of API key.