OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // This test uses the safebrowsing test server published at | 5 // This test uses the safebrowsing test server published at |
6 // http://code.google.com/p/google-safe-browsing/ to test the safebrowsing | 6 // http://code.google.com/p/google-safe-browsing/ to test the safebrowsing |
7 // protocol implemetation. Details of the safebrowsing testing flow is | 7 // protocol implemetation. Details of the safebrowsing testing flow is |
8 // documented at | 8 // documented at |
9 // http://code.google.com/p/google-safe-browsing/wiki/ProtocolTesting | 9 // http://code.google.com/p/google-safe-browsing/wiki/ProtocolTesting |
10 // | 10 // |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 bool InitSafeBrowsingService() { | 282 bool InitSafeBrowsingService() { |
283 safe_browsing_service_ = | 283 safe_browsing_service_ = |
284 g_browser_process->resource_dispatcher_host()->safe_browsing_service(); | 284 g_browser_process->resource_dispatcher_host()->safe_browsing_service(); |
285 return safe_browsing_service_ != NULL; | 285 return safe_browsing_service_ != NULL; |
286 } | 286 } |
287 | 287 |
288 virtual void SetUpCommandLine(CommandLine* command_line) { | 288 virtual void SetUpCommandLine(CommandLine* command_line) { |
289 // Makes sure the auto update is not triggered. This test will force the | 289 // Makes sure the auto update is not triggered. This test will force the |
290 // update when needed. | 290 // update when needed. |
291 command_line->AppendSwitch(switches::kSbDisableAutoUpdate); | 291 command_line->AppendSwitch(switches::kSbDisableAutoUpdate); |
| 292 // This test uses loopback. No need to use IPv6 especially it makes |
| 293 // local requests slow on Windows trybot when ipv6 local address [::1] |
| 294 // is not setup. |
| 295 command_line->AppendSwitch(switches::kDisableIPv6); |
292 | 296 |
293 // In this test, we fetch SafeBrowsing data and Mac key from the same | 297 // In this test, we fetch SafeBrowsing data and Mac key from the same |
294 // server. Although in real production, they are served from different | 298 // server. Although in real production, they are served from different |
295 // servers. | 299 // servers. |
296 std::string url_prefix = | 300 std::string url_prefix = |
297 StringPrintf("http://%s:%d/safebrowsing", | 301 StringPrintf("http://%s:%d/safebrowsing", |
298 SafeBrowsingTestServer::Host(), | 302 SafeBrowsingTestServer::Host(), |
299 SafeBrowsingTestServer::Port()); | 303 SafeBrowsingTestServer::Port()); |
300 command_line->AppendSwitchASCII(switches::kSbInfoURLPrefix, url_prefix); | 304 command_line->AppendSwitchASCII(switches::kSbInfoURLPrefix, url_prefix); |
301 command_line->AppendSwitchASCII(switches::kSbMacKeyURLPrefix, url_prefix); | 305 command_line->AppendSwitchASCII(switches::kSbMacKeyURLPrefix, url_prefix); |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 // Starts updates. After each update, the test will fetch a list of URLs with | 551 // Starts updates. After each update, the test will fetch a list of URLs with |
548 // expected results to verify with safebrowsing service. If there is no error, | 552 // expected results to verify with safebrowsing service. If there is no error, |
549 // the test moves on to the next step to get more update chunks. | 553 // the test moves on to the next step to get more update chunks. |
550 // This repeats till there is no update data. | 554 // This repeats till there is no update data. |
551 for (int step = 1;; step++) { | 555 for (int step = 1;; step++) { |
552 // Every step should be a fresh start. | 556 // Every step should be a fresh start. |
553 SCOPED_TRACE(StringPrintf("step=%d", step)); | 557 SCOPED_TRACE(StringPrintf("step=%d", step)); |
554 EXPECT_TRUE(is_database_ready()); | 558 EXPECT_TRUE(is_database_ready()); |
555 EXPECT_FALSE(is_update_scheduled()); | 559 EXPECT_FALSE(is_update_scheduled()); |
556 | 560 |
557 // TODO(lzheng): Remove the following #if and #elif to enable the rest of | |
558 // the test once bot is restarted with change | |
559 // http://codereview.chromium.org/3750002. | |
560 #if defined(OS_WIN) | |
561 break; | |
562 #elif defined(OS_POSIX) | |
563 if (step > 2 ) break; | |
564 #endif | |
565 | |
566 // Starts safebrowsing update on IO thread. Waits till scheduled | 561 // Starts safebrowsing update on IO thread. Waits till scheduled |
567 // update finishes. Stops waiting after kMaxWaitSecPerStep if the update | 562 // update finishes. Stops waiting after kMaxWaitSecPerStep if the update |
568 // could not finish. | 563 // could not finish. |
569 base::Time now = base::Time::Now(); | 564 base::Time now = base::Time::Now(); |
570 SetTestStep(step); | 565 SetTestStep(step); |
571 safe_browsing_helper->ForceUpdate(); | 566 safe_browsing_helper->ForceUpdate(); |
572 | 567 |
573 do { | 568 do { |
574 // Periodically pull the status. | 569 // Periodically pull the status. |
575 safe_browsing_helper->WaitForStatusUpdate( | 570 safe_browsing_helper->WaitForStatusUpdate( |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 // TODO(lzheng): We should verify the fetched database with local | 611 // TODO(lzheng): We should verify the fetched database with local |
617 // database to make sure they match. | 612 // database to make sure they match. |
618 EXPECT_EQ(URLRequestStatus::SUCCESS, | 613 EXPECT_EQ(URLRequestStatus::SUCCESS, |
619 safe_browsing_helper->FetchDBToVerify(server_host, | 614 safe_browsing_helper->FetchDBToVerify(server_host, |
620 server_port, | 615 server_port, |
621 step)); | 616 step)); |
622 EXPECT_GT(safe_browsing_helper->response_data().size(), 0U); | 617 EXPECT_GT(safe_browsing_helper->response_data().size(), 0U); |
623 last_step = step; | 618 last_step = step; |
624 } | 619 } |
625 | 620 |
626 // TODO(lzheng): Enable this check after safebrowsing server updated with | |
627 // the latest data in the next revision. | |
628 | |
629 // Verifies with server if test is done and waits till server responses. | 621 // Verifies with server if test is done and waits till server responses. |
630 // EXPECT_EQ(URLRequestStatus::SUCCESS, | 622 EXPECT_EQ(URLRequestStatus::SUCCESS, |
631 // safe_browsing_helper->VerifyTestComplete(server_host, | 623 safe_browsing_helper->VerifyTestComplete(server_host, |
632 // server_port, | 624 server_port, |
633 // last_step)); | 625 last_step)); |
634 // EXPECT_EQ("yes", safe_browsing_helper->response_data()); | 626 EXPECT_EQ("yes", safe_browsing_helper->response_data()); |
635 test_server.Stop(); | 627 test_server.Stop(); |
636 } | 628 } |
OLD | NEW |