|
1 | 1 | package e2e |
2 | 2 |
|
3 | 3 | import ( |
| 4 | + "encoding/json" |
4 | 5 | "fmt" |
5 | 6 | "io/ioutil" |
6 | 7 | "path/filepath" |
@@ -449,30 +450,38 @@ STATUS |
449 | 450 | } |
450 | 451 |
|
451 | 452 | func TestCredentials(t *testing.T) { |
452 | | - cmd, cleanup := dockerCli.createTestCmd( |
453 | | - withCredentialSet(t, "default", &credentials.CredentialSet{ |
454 | | - Name: "test-creds", |
455 | | - Credentials: []credentials.CredentialStrategy{ |
456 | | - { |
457 | | - Name: "secret1", |
458 | | - Source: credentials.Source{ |
459 | | - Value: "secret1value", |
460 | | - }, |
| 453 | + credSet := &credentials.CredentialSet{ |
| 454 | + Name: "test-creds", |
| 455 | + Credentials: []credentials.CredentialStrategy{ |
| 456 | + { |
| 457 | + Name: "secret1", |
| 458 | + Source: credentials.Source{ |
| 459 | + Value: "secret1value", |
461 | 460 | }, |
462 | | - { |
463 | | - Name: "secret2", |
464 | | - Source: credentials.Source{ |
465 | | - Value: "secret2value", |
466 | | - }, |
| 461 | + }, |
| 462 | + { |
| 463 | + Name: "secret2", |
| 464 | + Source: credentials.Source{ |
| 465 | + Value: "secret2value", |
467 | 466 | }, |
468 | 467 | }, |
469 | | - }), |
| 468 | + }, |
| 469 | + } |
| 470 | + // Create a tmp dir with a credential store |
| 471 | + cmd, cleanup := dockerCli.createTestCmd( |
| 472 | + withCredentialSet(t, "default", credSet), |
470 | 473 | ) |
471 | 474 | defer cleanup() |
| 475 | + // Create a local credentialSet |
472 | 476 |
|
| 477 | + buf, err := json.Marshal(credSet) |
| 478 | + assert.NilError(t, err) |
473 | 479 | bundleJSON := golden.Get(t, "credential-install-bundle.json") |
474 | 480 | tmpDir := fs.NewDir(t, t.Name(), |
475 | 481 | fs.WithFile("bundle.json", "", fs.WithBytes(bundleJSON)), |
| 482 | + fs.WithDir("local", |
| 483 | + fs.WithFile("test-creds.yaml", "", fs.WithBytes(buf)), |
| 484 | + ), |
476 | 485 | ) |
477 | 486 | defer tmpDir.Remove() |
478 | 487 |
|
@@ -505,15 +514,26 @@ func TestCredentials(t *testing.T) { |
505 | 514 | golden.Assert(t, result.Stdout(), "credential-install-full.golden") |
506 | 515 | }) |
507 | 516 |
|
508 | | - t.Run("mixed", func(t *testing.T) { |
| 517 | + t.Run("mixed-credstore", func(t *testing.T) { |
509 | 518 | cmd.Command = dockerCli.Command( |
510 | 519 | "app", "install", |
511 | 520 | "--credential-set", "test-creds", |
512 | 521 | "--credential", "secret3=xyzzy", |
513 | | - "--name", "mixed", bundle, |
| 522 | + "--name", "mixed-credstore", bundle, |
| 523 | + ) |
| 524 | + result := icmd.RunCmd(cmd).Assert(t, icmd.Success) |
| 525 | + golden.Assert(t, result.Stdout(), "credential-install-mixed-credstore.golden") |
| 526 | + }) |
| 527 | + |
| 528 | + t.Run("mixed-local-cred", func(t *testing.T) { |
| 529 | + cmd.Command = dockerCli.Command( |
| 530 | + "app", "install", |
| 531 | + "--credential-set", tmpDir.Join("local", "test-creds.yaml"), |
| 532 | + "--credential", "secret3=xyzzy", |
| 533 | + "--name", "mixed-local-cred", bundle, |
514 | 534 | ) |
515 | 535 | result := icmd.RunCmd(cmd).Assert(t, icmd.Success) |
516 | | - golden.Assert(t, result.Stdout(), "credential-install-mixed.golden") |
| 536 | + golden.Assert(t, result.Stdout(), "credential-install-mixed-local-cred.golden") |
517 | 537 | }) |
518 | 538 |
|
519 | 539 | t.Run("overload", func(t *testing.T) { |
|
0 commit comments