cmd/{k8s-operator,k8s-proxy},kube: use consistent type for auth mode config (#16626)
Updates k8s-proxy's config so its auth mode config matches that we set in kube-apiserver ProxyGroups for consistency. Updates #13358 Change-Id: I95e29cec6ded2dc7c6d2d03f968a25c822bc0e01 Signed-off-by: Tom Proctor <tomhjp@users.noreply.github.com>main
parent
6f7e78b10f
commit
22a8e0ac50
@ -0,0 +1,42 @@ |
||||
// Copyright (c) Tailscale Inc & AUTHORS
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
package kubetypes |
||||
|
||||
import ( |
||||
"encoding/json" |
||||
"testing" |
||||
) |
||||
|
||||
func TestUnmarshalAPIServerProxyMode(t *testing.T) { |
||||
tests := []struct { |
||||
data string |
||||
expected APIServerProxyMode |
||||
}{ |
||||
{data: `{"mode":"auth"}`, expected: APIServerProxyModeAuth}, |
||||
{data: `{"mode":"noauth"}`, expected: APIServerProxyModeNoAuth}, |
||||
{data: `{"mode":""}`, expected: ""}, |
||||
{data: `{"mode":"Auth"}`, expected: ""}, |
||||
{data: `{"mode":"unknown"}`, expected: ""}, |
||||
} |
||||
|
||||
for _, tc := range tests { |
||||
var s struct { |
||||
Mode *APIServerProxyMode `json:",omitempty"` |
||||
} |
||||
err := json.Unmarshal([]byte(tc.data), &s) |
||||
if tc.expected == "" { |
||||
if err == nil { |
||||
t.Errorf("expected error for %q, got none", tc.data) |
||||
} |
||||
continue |
||||
} |
||||
if err != nil { |
||||
t.Errorf("unexpected error for %q: %v", tc.data, err) |
||||
continue |
||||
} |
||||
if *s.Mode != tc.expected { |
||||
t.Errorf("for %q expected %q, got %q", tc.data, tc.expected, *s.Mode) |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue