MCPcopy Create free account
hub / github.com/docker/cli / TestLoadFromReaderWithUsernamePassword

Function TestLoadFromReaderWithUsernamePassword

cli/config/configfile/file_test.go:449–482  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

447}
448
449func TestLoadFromReaderWithUsernamePassword(t *testing.T) {
450 configFile := New("test-load")
451 defer os.Remove("test-load")
452
453 want := types.AuthConfig{
454 Username: "user",
455 Password: "pass",
456 }
457
458 for _, tc := range []types.AuthConfig{
459 want,
460 {
461 Auth: encodeAuth(&want),
462 },
463 } {
464 cf := ConfigFile{
465 AuthConfigs: map[string]types.AuthConfig{
466 "example.com/foo": tc,
467 },
468 }
469
470 b, err := json.Marshal(cf)
471 assert.NilError(t, err)
472
473 err = configFile.LoadFromReader(bytes.NewReader(b))
474 assert.NilError(t, err)
475
476 got, err := configFile.GetAuthConfig("example.com/foo")
477 assert.NilError(t, err)
478
479 assert.Check(t, is.DeepEqual(want.Username, got.Username))
480 assert.Check(t, is.DeepEqual(want.Password, got.Password))
481 }
482}
483
484const envTestUserPassConfig = `{
485 "auths": {

Callers

nothing calls this directly

Calls 5

encodeAuthFunction · 0.85
LoadFromReaderMethod · 0.80
GetAuthConfigMethod · 0.80
NewFunction · 0.70
RemoveMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…