mirror of
https://github.com/searxng/searxng.git
synced 2025-07-31 00:52:22 +02:00
Add a self user agent plugin
Just like with the "ip" query, duckduckgo gives the server's information with the "user agent" query. This corrects this behavior by adding a plugin based on self_ip.py plugin.
This commit is contained in:
parent
1b77befe1f
commit
538029dc14
3 changed files with 54 additions and 1 deletions
|
@ -39,9 +39,11 @@ class SelfIPTest(SearxTestCase):
|
|||
def test_PluginStore_init(self):
|
||||
store = plugins.PluginStore()
|
||||
store.register(plugins.self_ip)
|
||||
store.register(plugins.self_useragent)
|
||||
|
||||
self.assertTrue(len(store.plugins) == 1)
|
||||
self.assertTrue(len(store.plugins) == 2)
|
||||
|
||||
# IP test
|
||||
request = Mock(user_plugins=store.plugins,
|
||||
remote_addr='127.0.0.1')
|
||||
request.headers.getlist.return_value = []
|
||||
|
@ -49,3 +51,16 @@ class SelfIPTest(SearxTestCase):
|
|||
query='ip')}
|
||||
store.call('post_search', request, ctx)
|
||||
self.assertTrue('127.0.0.1' in ctx['search'].answers)
|
||||
|
||||
# User agent test
|
||||
request = Mock(user_plugins=store.plugins,
|
||||
user_agent='Mock')
|
||||
request.headers.getlist.return_value = []
|
||||
ctx = {'search': Mock(answers=set(),
|
||||
query='user-agent')}
|
||||
store.call('post_search', request, ctx)
|
||||
self.assertTrue('Mock' in ctx['search'].answers)
|
||||
ctx = {'search': Mock(answers=set(),
|
||||
query='user agent')}
|
||||
store.call('post_search', request, ctx)
|
||||
self.assertTrue('Mock' in ctx['search'].answers)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue