OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 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. |
| 5 |
| 6 """Wraps the upstream safebrowsing_test_server.py to run in Chrome tests.""" |
| 7 |
| 8 import os |
| 9 import sys |
| 10 |
| 11 BASE_DIR = os.path.dirname(os.path.abspath(__file__)) |
| 12 |
| 13 sys.path.append(os.path.join(BASE_DIR, '..', '..', '..', 'net', |
| 14 'tools', 'testserver')) |
| 15 import testserver_base |
| 16 |
| 17 |
| 18 class ServerRunner(testserver_base.TestServerRunner): |
| 19 """TestServerRunner for safebrowsing_test_server.py.""" |
| 20 |
| 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 |
| 30 |
| 31 return server |
| 32 |
| 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') |
| 38 # TODO(mattm): we define an unnecessary --data-dir option because |
| 39 # BaseTestServer unconditionally sets --data-dir. This should be removed |
| 40 # when BaseTestServer is refactored to not contain all the net/ |
| 41 # test_server.py specific stuff. |
| 42 self.option_parser.add_option('--data-dir', dest='data_dir', |
| 43 help='unused') |
| 44 |
| 45 |
| 46 if __name__ == '__main__': |
| 47 sys.exit(ServerRunner().main()) |
OLD | NEW |