begin work on refactor of ruleset and functional options serializer for proxychain response/request modifiers

This commit is contained in:
Kevin Pham
2023-12-03 21:32:03 -06:00
parent 1fc47c76b6
commit 547cf61a7d
7 changed files with 348 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
package ruleset_v2
import (
"encoding/json"
"fmt"
//"io"
"testing"
)
func TestRuleUnmarshalJSON(t *testing.T) {
ruleJSON := `{
"domains": [
"example.com",
"www.example.com"
],
"response_modifiers": [
"APIContent()",
"SetContentSecurityPolicy(\"foobar\")",
"SetIncomingCookie(\"authorization-bearer\", \"hunter2\")"
],
"response_modifiers": []
}`
//fmt.Println(ruleJSON)
rule := &Rule{}
err := json.Unmarshal([]byte(ruleJSON), rule)
if err != nil {
t.Errorf("expected no error in Unmarshal, got '%s'", err)
return
}
if len(rule.Domains) != 2 {
t.Errorf("expected number of domains to be 2")
return
}
if !(rule.Domains[0] == "example.com" || rule.Domains[1] == "example.com") {
t.Errorf("expected domain to be example.com")
return
}
if len(rule.ResponseModifications) == 3 {
t.Errorf("expected number of ResponseModifications to be 3")
}
fmt.Println(rule.ResponseModifications)
}