MCPcopy
hub / github.com/kubernetes/client-go / TestBasicAuthData

Function TestBasicAuthData

tools/clientcmd/client_config_test.go:273–301  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

271}
272
273func TestBasicAuthData(t *testing.T) {
274 username := "myuser"
275 password := "mypass"
276
277 config := clientcmdapi.NewConfig()
278 config.Clusters["clean"] = &clientcmdapi.Cluster{
279 Server: "https://localhost:8443",
280 }
281 config.AuthInfos["clean"] = &clientcmdapi.AuthInfo{
282 Username: username,
283 Password: password,
284 }
285 config.Contexts["clean"] = &clientcmdapi.Context{
286 Cluster: "clean",
287 AuthInfo: "clean",
288 }
289 config.CurrentContext = "clean"
290
291 clientBuilder := NewNonInteractiveClientConfig(*config, "clean", &ConfigOverrides{}, nil)
292
293 clientConfig, err := clientBuilder.ClientConfig()
294 if err != nil {
295 t.Fatalf("Unexpected error: %v", err)
296 }
297
298 // Make sure basic auth data gets into config
299 matchStringArg(username, clientConfig.Username, t)
300 matchStringArg(password, clientConfig.Password, t)
301}
302
303func TestBasicTokenFile(t *testing.T) {
304 token := "exampletoken"

Callers

nothing calls this directly

Calls 3

matchStringArgFunction · 0.85
ClientConfigMethod · 0.65

Tested by

no test coverage detected