mirror of
https://github.com/kubernetes/client-go.git
synced 2025-09-02 07:35:21 +00:00
client-go: fix panic in ConfirmUsable validation
Fixes https://github.com/kubernetes/client-go/issues/1108 Kubernetes-commit: 7d2c6096c212d9c31e7cd0bccb6dc2dec9a4ef6a
This commit is contained in:
committed by
Kubernetes Publisher
parent
830d4c4624
commit
5ce7078061
@@ -65,6 +65,42 @@ func TestConfirmUsableBadInfoButOkConfig(t *testing.T) {
|
||||
badValidation.testConfig(t)
|
||||
}
|
||||
|
||||
func TestConfirmUsableMissingObjects(t *testing.T) {
|
||||
config := clientcmdapi.NewConfig()
|
||||
config.Clusters["kind-cluster"] = &clientcmdapi.Cluster{
|
||||
Server: "anything",
|
||||
}
|
||||
config.AuthInfos["kind-user"] = &clientcmdapi.AuthInfo{
|
||||
Token: "any-value",
|
||||
}
|
||||
config.Contexts["missing-user"] = &clientcmdapi.Context{
|
||||
Cluster: "kind-cluster",
|
||||
AuthInfo: "garbage",
|
||||
}
|
||||
config.Contexts["missing-cluster"] = &clientcmdapi.Context{
|
||||
Cluster: "garbage",
|
||||
AuthInfo: "kind-user",
|
||||
}
|
||||
|
||||
missingUser := configValidationTest{
|
||||
config: config,
|
||||
expectedErrorSubstring: []string{
|
||||
`user "garbage" was not found for context "missing-user"`,
|
||||
},
|
||||
}
|
||||
missingUser.testConfirmUsable("missing-user", t)
|
||||
missingUser.testConfig(t)
|
||||
|
||||
missingCluster := configValidationTest{
|
||||
config: config,
|
||||
expectedErrorSubstring: []string{
|
||||
`cluster "garbage" was not found for context "missing-cluster"`,
|
||||
},
|
||||
}
|
||||
missingCluster.testConfirmUsable("missing-cluster", t)
|
||||
missingCluster.testConfig(t)
|
||||
}
|
||||
|
||||
func TestConfirmUsableBadInfoConfig(t *testing.T) {
|
||||
config := clientcmdapi.NewConfig()
|
||||
config.Clusters["missing ca"] = &clientcmdapi.Cluster{
|
||||
|
Reference in New Issue
Block a user