begin work on refactor of ruleset and functional options serializer for proxychain response/request modifiers
This commit is contained in:
45
pkg/ruleset_v2/rule_test.go
Normal file
45
pkg/ruleset_v2/rule_test.go
Normal 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)
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user