2 # Copyright 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
6 """Wraps the upstream safebrowsing_test_server.py to run in Chrome tests."""
11 BASE_DIR
= os
.path
.dirname(os
.path
.abspath(__file__
))
13 sys
.path
.append(os
.path
.join(BASE_DIR
, '..', '..', '..', 'net',
14 'tools', 'testserver'))
15 import testserver_base
18 class ServerRunner(testserver_base
.TestServerRunner
):
19 """TestServerRunner for safebrowsing_test_server.py."""
21 def create_server(self
, server_data
):
22 sys
.path
.append(os
.path
.join(BASE_DIR
, '..', '..', '..', 'third_party',
23 'safe_browsing', 'testing'))
24 import safebrowsing_test_server
25 server
= safebrowsing_test_server
.SetupServer(
26 self
.options
.data_file
, self
.options
.host
, self
.options
.port
,
27 opt_enforce_caching
=False, opt_validate_database
=True)
28 print 'Safebrowsing HTTP server started on port %d...' % server
.server_port
29 server_data
['port'] = server
.server_port
33 def add_options(self
):
34 testserver_base
.TestServerRunner
.add_options(self
)
35 self
.option_parser
.add_option('--data-file', dest
='data_file',
36 help='File containing safebrowsing test '
37 'data and expectations')
40 if __name__
== '__main__':
41 sys
.exit(ServerRunner().main())