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

Function TestJSONWithCredentialStore

cli/config/config_test.go:223–248  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

221}
222
223func TestJSONWithCredentialStore(t *testing.T) {
224 tmpHome := t.TempDir()
225
226 fn := filepath.Join(tmpHome, ConfigFileName)
227 js := `{
228 "auths": { "https://index.docker.io/v1/": { "auth": "am9lam9lOmhlbGxv", "email": "user@example.com" } },
229 "credsStore": "crazy-secure-storage"
230}`
231 if err := os.WriteFile(fn, []byte(js), 0o600); err != nil {
232 t.Fatal(err)
233 }
234
235 config, err := Load(tmpHome)
236 assert.NilError(t, err)
237
238 if config.CredentialsStore != "crazy-secure-storage" {
239 t.Fatalf("Unknown credential store: %s\n", config.CredentialsStore)
240 }
241
242 // Now save it and make sure it shows up in new form
243 configStr := saveConfigAndValidateNewFormat(t, config, tmpHome)
244 if !strings.Contains(configStr, `"credsStore":`) ||
245 !strings.Contains(configStr, "crazy-secure-storage") {
246 t.Fatalf("Should have save in new form: %s", configStr)
247 }
248}
249
250func TestJSONWithCredentialHelpers(t *testing.T) {
251 tmpHome := t.TempDir()

Callers

nothing calls this directly

Calls 3

ContainsMethod · 0.80
LoadFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…