MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / TestInfoArg_Encode

Function TestInfoArg_Encode

internal/waf/info_arg_test.go:12–44  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestInfoArg_Encode(t *testing.T) {
13 var info = &waf.InfoArg{
14 ActionId: 1,
15 Timestamp: time.Now().Unix(),
16 URL: "https://example.com/hello",
17 PolicyId: 2,
18 GroupId: 3,
19 SetId: 4,
20 UseLocalFirewall: true,
21 Scope: "global",
22 }
23
24 encodedString, err := info.Encode()
25 if err != nil {
26 t.Fatal(err)
27 }
28 t.Log("["+types.String(len(encodedString))+"]", encodedString)
29
30 {
31 urlEncodedString, encodeErr := info.URLEncoded()
32 if encodeErr != nil {
33 t.Fatal(encodeErr)
34 }
35 t.Log("["+types.String(len(urlEncodedString))+"]", urlEncodedString)
36 }
37
38 var info2 = &waf.InfoArg{}
39 err = info2.Decode(encodedString)
40 if err != nil {
41 t.Fatal(err)
42 }
43 t.Logf("%+v", info2)
44}

Callers

nothing calls this directly

Calls 6

UnixMethod · 0.80
LogMethod · 0.80
URLEncodedMethod · 0.80
EncodeMethod · 0.65
DecodeMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected