Download this file
| 1 | package runner |
| 2 | |
| 3 | import ( |
| 4 | "slices" |
| 5 | "testing" |
| 6 | ) |
| 7 | |
| 8 | // TestPreviewCredentialProtected: the preview credential is one of the |
| 9 | // protected paths when it is set (never mounted into, or read from, a |
| 10 | // sandbox), and adds nothing when previews are off. |
| 11 | func TestPreviewCredentialProtected(t *testing.T) { |
| 12 | c := Config{StateDir: "/state", AccountBindingsPath: "/state/bindings.json", AmadanCredentialPath: "/state/amadan.json", PreviewCredentialPath: "/state/preview.json"} |
| 13 | if !slices.Contains(c.securityPaths(nil).Credentials(), "/state/preview.json") { |
| 14 | t.Fatal("the preview credential is not protected") |
| 15 | } |
| 16 | c.PreviewCredentialPath = "" |
| 17 | for _, p := range c.securityPaths(nil).Credentials() { |
| 18 | if p == "" { |
| 19 | t.Fatal("an empty protected path") |
| 20 | } |
| 21 | } |
| 22 | } |
| 23 | |