From bbbc05fa464b9b58b7360e2637b38ef97325eccd Mon Sep 17 00:00:00 2001 From: salvacybersec Date: Mon, 6 Apr 2026 00:41:55 +0300 Subject: [PATCH] test(09-03): add failing test for stealth UA pool --- pkg/recon/stealth_test.go | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 pkg/recon/stealth_test.go diff --git a/pkg/recon/stealth_test.go b/pkg/recon/stealth_test.go new file mode 100644 index 0000000..b31884a --- /dev/null +++ b/pkg/recon/stealth_test.go @@ -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) +}