0
Fork 0
mirror of https://github.com/caddyserver/caddy.git synced 2024-12-23 22:27:38 -05:00
caddy/modules/caddyhttp/templates
Kevin Daudt 44e5e9e43f
caddyhttp: Fix test when /tmp/etc already exists (#4544)
The TestFileListing test in tplcontext_test has one test that verifies
if directory traversal is not happening. The context root is set to
'/tmp' and then it tries to open '../../../../../etc', which gets
normalized to '/tmp/etc'.

The test then expects an error to be returned, assuming that '/tmp/etc'
does not exist on the system. When it does exist, it results in a test
failure:

```
--- FAIL: TestFileListing (0.00s)
    tplcontext_test.go:422: Test 4: Expected error but had none
    FAIL
    FAIL
    github.com/caddyserver/caddy/v2/modules/caddyhttp/templates	0.042s
```

Instead of using '/tmp' as root, use a dedicated directory created with
`os.MkdirTemp()` instead. That way, we know that the directory is empty.
2022-01-24 14:41:08 -07:00
..
caddyfile.go Improve godocs all around 2019-12-23 12:45:35 -07:00
frontmatter.go templates: Fix front matter closing fence search 2020-07-08 16:46:56 -06:00
frontmatter_fuzz.go templates: fix inconsistent nested includes (#4452) 2021-11-29 12:29:40 -05:00
templates.go templates: Document .OriginalReq 2022-01-05 13:59:59 -07:00
tplcontext.go templates: fix inconsistent nested includes (#4452) 2021-11-29 12:29:40 -05:00
tplcontext_test.go caddyhttp: Fix test when /tmp/etc already exists (#4544) 2022-01-24 14:41:08 -07:00