fix(web): all web_search backends use SafeHTTPClient (N4)
This commit is contained in:
1 parent
d7777f7c89
commit
7d85074509
3 files changed
+42
-4
No files matched your search
@@ -0,0 +1,29 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func testCtx(t *testing.T) context.Context {
|
||||
t.Helper()
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
t.Cleanup(cancel)
|
||||
return ctx
|
||||
}
|
||||
|
||||
func TestSearchClient_IsSafe(t *testing.T) {
|
||||
require.NotNil(t, searchClient)
|
||||
require.NotNil(t, searchClient.Transport)
|
||||
require.NotNil(t, searchClient.CheckRedirect)
|
||||
require.Equal(t, searchTimeout, searchClient.Timeout)
|
||||
}
|
||||
|
||||
func TestSearxng_BlocksPrivateBaseURL(t *testing.T) {
|
||||
b := newSearxngBackend("http://127.0.0.1:8080")
|
||||
_, err := b.Search(testCtx(t), "hello", 3)
|
||||
require.Error(t, err)
|
||||
}
|
||||
Reference in new issue
Block a user