Skip to content

Commit 947d18c

Browse files
committed
feat: add unit tests for payload generation functions
1 parent 753e519 commit 947d18c

File tree

4 files changed

+176
-0
lines changed

4 files changed

+176
-0
lines changed

internal/payload/bav_test.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package payload
2+
3+
import (
4+
"testing"
5+
)
6+
7+
func TestGetOpenRedirectPayload(t *testing.T) {
8+
payloads := GetOpenRedirectPayload()
9+
if len(payloads) == 0 {
10+
t.Errorf("Expected non-empty payloads, got %d", len(payloads))
11+
}
12+
}
13+
14+
func TestGetCRLFPayload(t *testing.T) {
15+
payloads := GetCRLFPayload()
16+
if len(payloads) == 0 {
17+
t.Errorf("Expected non-empty payloads, got %d", len(payloads))
18+
}
19+
}
20+
21+
func TestGetESIIPayload(t *testing.T) {
22+
payloads := GetESIIPayload()
23+
if len(payloads) == 0 {
24+
t.Errorf("Expected non-empty payloads, got %d", len(payloads))
25+
}
26+
}
27+
28+
func TestGetSQLIPayload(t *testing.T) {
29+
payloads := GetSQLIPayload()
30+
if len(payloads) == 0 {
31+
t.Errorf("Expected non-empty payloads, got %d", len(payloads))
32+
}
33+
}
34+
35+
func TestGetSSTIPayload(t *testing.T) {
36+
payloads := GetSSTIPayload()
37+
if len(payloads) == 0 {
38+
t.Errorf("Expected non-empty payloads, got %d", len(payloads))
39+
}
40+
}

internal/payload/remote_test.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package payload
2+
3+
import (
4+
"testing"
5+
)
6+
7+
func TestRemoteGetOpenRedirectPayload(t *testing.T) {
8+
payloads := GetOpenRedirectPayload()
9+
if len(payloads) == 0 {
10+
t.Errorf("Expected non-empty payloads, got %d", len(payloads))
11+
}
12+
}
13+
14+
func TestRemoteGetCRLFPayload(t *testing.T) {
15+
payloads := GetCRLFPayload()
16+
if len(payloads) == 0 {
17+
t.Errorf("Expected non-empty payloads, got %d", len(payloads))
18+
}
19+
}
20+
21+
func TestRemoteGetESIIPayload(t *testing.T) {
22+
payloads := GetESIIPayload()
23+
if len(payloads) == 0 {
24+
t.Errorf("Expected non-empty payloads, got %d", len(payloads))
25+
}
26+
}
27+
28+
func TestRemoteGetSQLIPayload(t *testing.T) {
29+
payloads := GetSQLIPayload()
30+
if len(payloads) == 0 {
31+
t.Errorf("Expected non-empty payloads, got %d", len(payloads))
32+
}
33+
}
34+
35+
func TestRemoteGetSSTIPayload(t *testing.T) {
36+
payloads := GetSSTIPayload()
37+
if len(payloads) == 0 {
38+
t.Errorf("Expected non-empty payloads, got %d", len(payloads))
39+
}
40+
}
File renamed without changes.

internal/payload/xss_test.go

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
package payload
2+
3+
import (
4+
"testing"
5+
)
6+
7+
func TestGetCommonPayloadWithSize(t *testing.T) {
8+
payloads, size := GetCommonPayloadWithSize()
9+
if len(payloads) != size {
10+
t.Errorf("Expected size %d, but got %d", len(payloads), size)
11+
}
12+
}
13+
14+
func TestGetHTMLPayloadWithSize(t *testing.T) {
15+
payloads, size := GetHTMLPayloadWithSize()
16+
if len(payloads) != size {
17+
t.Errorf("Expected size %d, but got %d", len(payloads), size)
18+
}
19+
}
20+
21+
func TestGetAttrPayloadWithSize(t *testing.T) {
22+
payloads, size := GetAttrPayloadWithSize()
23+
if len(payloads) != size {
24+
t.Errorf("Expected size %d, but got %d", len(payloads), size)
25+
}
26+
}
27+
28+
func TestGetInJsPayloadWithSize(t *testing.T) {
29+
payloads, size := GetInJsPayloadWithSize()
30+
if len(payloads) != size {
31+
t.Errorf("Expected size %d, but got %d", len(payloads), size)
32+
}
33+
}
34+
35+
func TestGetInJsBreakScriptPayloadWithSize(t *testing.T) {
36+
payloads, size := GetInJsBreakScriptPayloadWithSize()
37+
if len(payloads) != size {
38+
t.Errorf("Expected size %d, but got %d", len(payloads), size)
39+
}
40+
}
41+
42+
func TestGetBlindPayload(t *testing.T) {
43+
payloads := GetBlindPayload()
44+
if len(payloads) == 0 {
45+
t.Error("Expected non-empty payloads")
46+
}
47+
}
48+
49+
func TestGetCommonPayload(t *testing.T) {
50+
payloads := GetCommonPayload()
51+
if len(payloads) == 0 {
52+
t.Error("Expected non-empty payloads")
53+
}
54+
}
55+
56+
func TestGetHTMLPayload(t *testing.T) {
57+
payloads := GetHTMLPayload("")
58+
if len(payloads) == 0 {
59+
t.Error("Expected non-empty payloads")
60+
}
61+
}
62+
63+
func TestGetAttrPayload(t *testing.T) {
64+
payloads := GetAttrPayload("")
65+
if len(payloads) == 0 {
66+
t.Error("Expected non-empty payloads")
67+
}
68+
}
69+
70+
func TestGetInJsBreakScriptPayload(t *testing.T) {
71+
payloads := GetInJsBreakScriptPayload("")
72+
if len(payloads) == 0 {
73+
t.Error("Expected non-empty payloads")
74+
}
75+
}
76+
77+
func TestGetInJsPayload(t *testing.T) {
78+
payloads := GetInJsPayload("")
79+
if len(payloads) == 0 {
80+
t.Error("Expected non-empty payloads")
81+
}
82+
}
83+
84+
func TestGetDOMXSSPayload(t *testing.T) {
85+
payloads := GetDOMXSSPayload()
86+
if len(payloads) == 0 {
87+
t.Error("Expected non-empty payloads")
88+
}
89+
}
90+
91+
func TestGetDeepDOMXSPayload(t *testing.T) {
92+
payloads := GetDeepDOMXSPayload()
93+
if len(payloads) == 0 {
94+
t.Error("Expected non-empty payloads")
95+
}
96+
}

0 commit comments

Comments
 (0)