(t *testing.T)
| 624 | } |
| 625 | |
| 626 | func TestConfig_MergeWithEncryptedFile(t *testing.T) { |
| 627 | if _, err := exec.LookPath("sops"); err != nil { |
| 628 | t.Skip("sops binary not available") |
| 629 | } |
| 630 | |
| 631 | if os.Getenv("CI") != "" { |
| 632 | t.Skip("Skipping encrypted file test in CI environment") |
| 633 | } |
| 634 | |
| 635 | tempDir := t.TempDir() |
| 636 | |
| 637 | id, err := age.GenerateX25519Identity() |
| 638 | require.NoError(t, err) |
| 639 | |
| 640 | keyPath := filepath.Join(tempDir, "key.txt") |
| 641 | require.NoError(t, os.WriteFile(keyPath, []byte(id.String()), 0o600)) |
| 642 | |
| 643 | plainPath := filepath.Join(tempDir, "plain.yaml") |
| 644 | require.NoError(t, os.WriteFile(plainPath, []byte("addr: https://enc.example.com\nuser: encuser\n"), 0o600)) |
| 645 | |
| 646 | // nolint:gosec // This is test code with controlled input |
| 647 | cmd := exec.Command("sops", "--encrypt", "--input-type", "yaml", "--output-type", "yaml", "--age", id.Recipient().String(), plainPath) |
| 648 | |
| 649 | out, err := cmd.CombinedOutput() |
| 650 | if err != nil { |
| 651 | t.Skipf("sops encryption failed: %v\nstderr: %s", err, string(out)) |
| 652 | } |
| 653 | |
| 654 | encPath := filepath.Join(tempDir, "config.enc.yaml") |
| 655 | require.NoError(t, os.WriteFile(encPath, out, 0o600)) |
| 656 | |
| 657 | cfg := &Config{} |
| 658 | err = cfg.MergeWithFile(encPath) |
| 659 | require.NoError(t, err) |
| 660 | assert.Equal(t, "https://enc.example.com", cfg.Addr) |
| 661 | assert.Equal(t, "encuser", cfg.User) |
| 662 | } |
| 663 | |
| 664 | func TestConfig_SetDefaults(t *testing.T) { |
| 665 | config := &Config{} |
nothing calls this directly
no test coverage detected