mirror of
https://github.com/RuoJi6/ARTEX.git
synced 2026-12-06 21:11:50 +08:00
fix: select random browser user agents for outbound HTTP
This commit is contained in:
1 parent
17c2fc5e08
commit
171db405dd
18 files changed
+205
-71
No files matched your search
@@ -5,6 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/Autumn-27/norma/agentcore"
|
||||
@@ -42,7 +43,9 @@ func TestAgentSessionUsesConfiguredWebFetch(t *testing.T) {
|
||||
calls := 0
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
calls++
|
||||
if r.UserAgent() != ua {
|
||||
if ua == "" && !strings.HasPrefix(r.UserAgent(), "Mozilla/5.0 ") {
|
||||
t.Errorf("random UA missing: %q", r.UserAgent())
|
||||
} else if ua != "" && r.UserAgent() != ua {
|
||||
t.Errorf("session sent User-Agent %q, want %q", r.UserAgent(), ua)
|
||||
}
|
||||
w.Write([]byte("fixture"))
|
||||
|
||||
Reference in new issue
Block a user