(t *testing.T)
| 248 | } |
| 249 | |
| 250 | func TestJSONWithCredentialHelpers(t *testing.T) { |
| 251 | tmpHome := t.TempDir() |
| 252 | |
| 253 | fn := filepath.Join(tmpHome, ConfigFileName) |
| 254 | js := `{ |
| 255 | "auths": { "https://index.docker.io/v1/": { "auth": "am9lam9lOmhlbGxv", "email": "user@example.com" } }, |
| 256 | "credHelpers": { "images.io": "images-io", "containers.com": "crazy-secure-storage" } |
| 257 | }` |
| 258 | if err := os.WriteFile(fn, []byte(js), 0o600); err != nil { |
| 259 | t.Fatal(err) |
| 260 | } |
| 261 | |
| 262 | config, err := Load(tmpHome) |
| 263 | assert.NilError(t, err) |
| 264 | |
| 265 | if config.CredentialHelpers == nil { |
| 266 | t.Fatal("config.CredentialHelpers was nil") |
| 267 | } else if config.CredentialHelpers["images.io"] != "images-io" || |
| 268 | config.CredentialHelpers["containers.com"] != "crazy-secure-storage" { |
| 269 | t.Fatalf("Credential helpers not deserialized properly: %v\n", config.CredentialHelpers) |
| 270 | } |
| 271 | |
| 272 | // Now save it and make sure it shows up in new form |
| 273 | configStr := saveConfigAndValidateNewFormat(t, config, tmpHome) |
| 274 | if !strings.Contains(configStr, `"credHelpers":`) || |
| 275 | !strings.Contains(configStr, "images.io") || |
| 276 | !strings.Contains(configStr, "images-io") || |
| 277 | !strings.Contains(configStr, "containers.com") || |
| 278 | !strings.Contains(configStr, "crazy-secure-storage") { |
| 279 | t.Fatalf("Should have save in new form: %s", configStr) |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | // Save it and make sure it shows up in new form |
| 284 | func saveConfigAndValidateNewFormat(t *testing.T, config *configfile.ConfigFile, configDir string) string { |
nothing calls this directly
no test coverage detected
searching dependent graphs…