From bd48661a9531fb093731f2d0f3d9e2375574fd21 Mon Sep 17 00:00:00 2001 From: Florian Lang <144521337+FlorianLang06@users.noreply.github.com> Date: Mon, 6 Jan 2025 21:06:59 +0100 Subject: [PATCH] filtering/safesearch: added test for brave search engine --- .../filtering/safesearch/safesearch_test.go | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/internal/filtering/safesearch/safesearch_test.go b/internal/filtering/safesearch/safesearch_test.go index 77eca2f126c..29d8c3e12d1 100644 --- a/internal/filtering/safesearch/safesearch_test.go +++ b/internal/filtering/safesearch/safesearch_test.go @@ -33,6 +33,7 @@ var testConf = filtering.SafeSearchConfig{ Enabled: true, Bing: true, + Brave: true, DuckDuckGo: true, Ecosia: true, Google: true, @@ -220,3 +221,27 @@ func TestDefault_Update(t *testing.T) { assert.False(t, res.IsFiltered) } + +func TestDefault_CheckHost_brave(t *testing.T) { + ctx := testutil.ContextWithTimeout(t, testTimeout) + ss, err := safesearch.NewDefault(ctx, &safesearch.DefaultConfig{ + Logger: slogutil.NewDiscardLogger(), + ServicesConfig: testConf, + CacheSize: testCacheSize, + CacheTTL: testCacheTTL, + }) + require.NoError(t, err) + + host := "search.brave.com" + + t.Run(host, func(t *testing.T) { + var res filtering.Result + res, err = ss.CheckHost(ctx, host, testQType) + require.NoError(t, err) + + assert.True(t, res.IsFiltered) + assert.Equal(t, filtering.FilteredSafeSearch, res.Reason) + assert.Equal(t, "safesearch.brave.com", res.CanonName) + assert.Empty(t, res.Rules) + }) +}