| 1 | package store |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "testing" |
| 6 | ) |
| 7 | |
| 8 | func TestSecretExpandFlag(t *testing.T) { |
| 9 | s := openStore(t) |
| 10 | ctx := context.Background() |
| 11 | if err := s.PutSecret(ctx, "repo", 1, "URL", "x$HOST", false); err != nil { |
| 12 | t.Fatal(err) |
| 13 | } |
| 14 | if f, _ := s.SecretExpandFlags(ctx, "repo", 1); f["URL"] { |
| 15 | t.Fatal("standaard moet uit zijn") |
| 16 | } |
| 17 | if err := s.SetSecretExpand(ctx, "repo", 1, "URL", true); err != nil { |
| 18 | t.Fatal(err) |
| 19 | } |
| 20 | // waarde bijwerken houdt de vlag |
| 21 | if err := s.PutSecret(ctx, "repo", 1, "URL", "y$HOST", false); err != nil { |
| 22 | t.Fatal(err) |
| 23 | } |
| 24 | if f, _ := s.SecretExpandFlags(ctx, "repo", 1); !f["URL"] { |
| 25 | t.Fatal("vlag kwijt na update") |
| 26 | } |
| 27 | list, _ := s.ListSecrets(ctx, "repo", 1) |
| 28 | if len(list) != 1 || !list[0].Expand { |
| 29 | t.Fatalf("%+v", list) |
| 30 | } |
| 31 | } |