test(09-03): add failing test for stealth UA pool
This commit is contained in:
38
pkg/recon/stealth_test.go
Normal file
38
pkg/recon/stealth_test.go
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
package recon
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestUAPoolSize(t *testing.T) {
|
||||||
|
require.Len(t, userAgents, 10, "UA pool must contain exactly 10 entries")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRandomUserAgentInPool(t *testing.T) {
|
||||||
|
pool := make(map[string]struct{}, len(userAgents))
|
||||||
|
for _, ua := range userAgents {
|
||||||
|
pool[ua] = struct{}{}
|
||||||
|
}
|
||||||
|
for i := 0; i < 100; i++ {
|
||||||
|
got := RandomUserAgent()
|
||||||
|
_, ok := pool[got]
|
||||||
|
require.True(t, ok, "RandomUserAgent returned value not in pool: %q", got)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestStealthHeadersHasUA(t *testing.T) {
|
||||||
|
h := StealthHeaders()
|
||||||
|
ua, ok := h["User-Agent"]
|
||||||
|
require.True(t, ok, "StealthHeaders missing User-Agent")
|
||||||
|
require.NotEmpty(t, ua)
|
||||||
|
require.Equal(t, "en-US,en;q=0.9", h["Accept-Language"])
|
||||||
|
|
||||||
|
pool := make(map[string]struct{}, len(userAgents))
|
||||||
|
for _, u := range userAgents {
|
||||||
|
pool[u] = struct{}{}
|
||||||
|
}
|
||||||
|
_, inPool := pool[ua]
|
||||||
|
require.True(t, inPool, "StealthHeaders User-Agent not in pool: %q", ua)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user