implement proper ruleset json serializer

This commit is contained in:
Kevin Pham
2023-12-04 22:53:38 -06:00
parent 6157d6543f
commit f8621e72ee
2 changed files with 55 additions and 153 deletions

View File

@@ -3,7 +3,7 @@ package ruleset_v2
import (
"encoding/json"
"fmt"
yaml "gopkg.in/yaml.v3"
//yaml "gopkg.in/yaml.v3"
"testing"
)
@@ -13,13 +13,25 @@ func TestRuleUnmarshalJSON(t *testing.T) {
"example.com",
"www.example.com"
],
"request_modifications": [
"SpoofUserAgent(\"googlebot\")"
],
"response_modifications": [
"APIContent()",
"SetContentSecurityPolicy(\"foobar\")",
"SetIncomingCookie(\"authorization-bearer\", \"hunter2\")"
{
"name": "APIContent",
"params": []
},
{
"name": "SetContentSecurityPolicy",
"params": ["foobar"]
},
{
"name": "SetIncomingCookie",
"params": ["authorization-bearer", "hunter2"]
}
],
"request_modifications": [
{
"name": "ForwardRequestHeaders",
"params": []
}
]
}`
@@ -54,6 +66,7 @@ func TestRuleUnmarshalJSON(t *testing.T) {
fmt.Println(string(jsonRule))
}
/*
func TestRuleUnmarshalYAML(t *testing.T) {
ruleYAML := `
domains:
@@ -95,3 +108,4 @@ response_modifications:
}
fmt.Println(string(yamlRule))
}
*/