-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsecurity_test.go
More file actions
74 lines (66 loc) · 2.1 KB
/
Copy pathsecurity_test.go
File metadata and controls
74 lines (66 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package tests
import (
"testing"
"time"
"github.com/ResistanceIsUseless/ProxyHawk/internal/proxy"
)
// TestAdvancedChecks tests the advanced security check functionality
func TestAdvancedChecks(t *testing.T) {
t.Run("Advanced Checks Configuration", func(t *testing.T) {
// Test that advanced checks can be configured
config := proxy.AdvancedChecks{
TestProtocolSmuggling: true,
TestDNSRebinding: true,
TestCachePoisoning: true,
TestHostHeaderInjection: true,
TestIPv6: true,
TestHTTPMethods: []string{"GET", "POST", "PUT"},
}
if !config.TestProtocolSmuggling {
t.Error("Protocol smuggling check should be enabled")
}
if !config.TestDNSRebinding {
t.Error("DNS rebinding check should be enabled")
}
if !config.TestCachePoisoning {
t.Error("Cache poisoning check should be enabled")
}
if !config.TestHostHeaderInjection {
t.Error("Host header injection check should be enabled")
}
if !config.TestIPv6 {
t.Error("IPv6 check should be enabled")
}
if len(config.TestHTTPMethods) != 3 {
t.Errorf("Expected 3 HTTP methods, got %d", len(config.TestHTTPMethods))
}
})
t.Run("Checker Creation with Advanced Checks", func(t *testing.T) {
// Test that proxy checker can be created with advanced checks
checkerConfig := proxy.Config{
Timeout: 10 * time.Second,
ValidationURL: "http://example.com",
AdvancedChecks: proxy.AdvancedChecks{
TestProtocolSmuggling: true,
TestDNSRebinding: true,
},
}
checker := proxy.NewChecker(checkerConfig, true, nil)
if checker == nil {
t.Error("Should be able to create checker with advanced checks")
}
})
t.Run("Disabled Advanced Checks", func(t *testing.T) {
// Test default configuration (all checks disabled)
config := proxy.AdvancedChecks{}
if config.TestProtocolSmuggling {
t.Error("Protocol smuggling check should be disabled by default")
}
if config.TestDNSRebinding {
t.Error("DNS rebinding check should be disabled by default")
}
if config.TestCachePoisoning {
t.Error("Cache poisoning check should be disabled by default")
}
})
}