aboutsummaryrefslogtreecommitdiffhomepage
path: root/hugolib/securitypolicies_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2023-05-20 17:37:04 +0200
committerBjørn Erik Pedersen <[email protected]>2023-05-20 20:16:45 +0200
commit2637b4ef4dbb3f8d3e537f900bdd072b4078c87e (patch)
tree6b64225d157397befe5a7d0ab7925b8ad0e6ba94 /hugolib/securitypolicies_test.go
parent7c7baa618325cb3d2b1ef48bdc1f97aae25f62e9 (diff)
downloadhugo-2637b4ef4dbb3f8d3e537f900bdd072b4078c87e.tar.gz
hugo-2637b4ef4dbb3f8d3e537f900bdd072b4078c87e.zip
Allow whitelisting mediaTypes used in resources.GetRemote
Fixes #10286
Diffstat (limited to 'hugolib/securitypolicies_test.go')
-rw-r--r--hugolib/securitypolicies_test.go28
1 files changed, 25 insertions, 3 deletions
diff --git a/hugolib/securitypolicies_test.go b/hugolib/securitypolicies_test.go
index aa062bb1f..5b9267b59 100644
--- a/hugolib/securitypolicies_test.go
+++ b/hugolib/securitypolicies_test.go
@@ -138,9 +138,9 @@ func TestSecurityPolicies(t *testing.T) {
}
cb := func(b *sitesBuilder) {
b.WithConfigFile("toml", `
- [security]
- [security.exec]
- allow="none"
+[security]
+[security.exec]
+allow="none"
`)
b.WithTemplatesAdded("index.html", `{{ $scss := "body { color: #333; }" | resources.FromString "foo.scss" | resources.ToCSS (dict "transpiler" "dartsass") }}`)
@@ -170,6 +170,28 @@ urls="none"
})
})
+ c.Run("resources.GetRemote, fake JSON", func(c *qt.C) {
+ c.Parallel()
+ httpTestVariant(c, `{{ $json := resources.GetRemote "%[1]s/fakejson.json" }}{{ $json.Content }}`, `(?s).*failed to resolve media type.*`,
+ func(b *sitesBuilder) {
+ b.WithConfigFile("toml", `
+`)
+ })
+ })
+
+ c.Run("resources.GetRemote, fake JSON whitelisted", func(c *qt.C) {
+ c.Parallel()
+ httpTestVariant(c, `{{ $json := resources.GetRemote "%[1]s/fakejson.json" }}{{ $json.Content }}`, ``,
+ func(b *sitesBuilder) {
+ b.WithConfigFile("toml", `
+[security]
+[security.http]
+mediaTypes=["application/json"]
+
+`)
+ })
+ })
+
c.Run("getJSON, OK", func(c *qt.C) {
c.Parallel()
httpTestVariant(c, `{{ $json := getJSON "%[1]s/fruits.json" }}{{ $json.Content }}`, "", nil)