OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 class SafeBrowsingServerTest : public InProcessBrowserTest { | 153 class SafeBrowsingServerTest : public InProcessBrowserTest { |
154 public: | 154 public: |
155 SafeBrowsingServerTest() | 155 SafeBrowsingServerTest() |
156 : safe_browsing_service_(NULL), | 156 : safe_browsing_service_(NULL), |
157 is_database_ready_(true), | 157 is_database_ready_(true), |
158 is_update_scheduled_(false), | 158 is_update_scheduled_(false), |
159 is_checked_url_in_db_(false), | 159 is_checked_url_in_db_(false), |
160 is_checked_url_safe_(false) { | 160 is_checked_url_safe_(false) { |
161 } | 161 } |
162 | 162 |
163 virtual ~SafeBrowsingServerTest() { | 163 ~SafeBrowsingServerTest() override {} |
164 } | |
165 | 164 |
166 void UpdateSafeBrowsingStatus() { | 165 void UpdateSafeBrowsingStatus() { |
167 ASSERT_TRUE(safe_browsing_service_); | 166 ASSERT_TRUE(safe_browsing_service_); |
168 base::AutoLock lock(update_status_mutex_); | 167 base::AutoLock lock(update_status_mutex_); |
169 last_update_ = safe_browsing_service_->protocol_manager_->last_update(); | 168 last_update_ = safe_browsing_service_->protocol_manager_->last_update(); |
170 is_update_scheduled_ = | 169 is_update_scheduled_ = |
171 safe_browsing_service_->protocol_manager_->update_timer_.IsRunning(); | 170 safe_browsing_service_->protocol_manager_->update_timer_.IsRunning(); |
172 } | 171 } |
173 | 172 |
174 void ForceUpdate() { | 173 void ForceUpdate() { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 const net::SpawnedTestServer& test_server() const { | 247 const net::SpawnedTestServer& test_server() const { |
249 return *test_server_; | 248 return *test_server_; |
250 } | 249 } |
251 | 250 |
252 protected: | 251 protected: |
253 bool InitSafeBrowsingService() { | 252 bool InitSafeBrowsingService() { |
254 safe_browsing_service_ = g_browser_process->safe_browsing_service(); | 253 safe_browsing_service_ = g_browser_process->safe_browsing_service(); |
255 return safe_browsing_service_ != NULL; | 254 return safe_browsing_service_ != NULL; |
256 } | 255 } |
257 | 256 |
258 virtual void SetUp() override { | 257 void SetUp() override { |
259 base::FilePath datafile_path; | 258 base::FilePath datafile_path; |
260 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &datafile_path)); | 259 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &datafile_path)); |
261 | 260 |
262 datafile_path = datafile_path.Append(FILE_PATH_LITERAL("third_party")) | 261 datafile_path = datafile_path.Append(FILE_PATH_LITERAL("third_party")) |
263 .Append(FILE_PATH_LITERAL("safe_browsing")) | 262 .Append(FILE_PATH_LITERAL("safe_browsing")) |
264 .Append(FILE_PATH_LITERAL("testing")) | 263 .Append(FILE_PATH_LITERAL("testing")) |
265 .Append(kDataFile); | 264 .Append(kDataFile); |
266 test_server_.reset(new LocalSafeBrowsingTestServer(datafile_path)); | 265 test_server_.reset(new LocalSafeBrowsingTestServer(datafile_path)); |
267 ASSERT_TRUE(test_server_->Start()); | 266 ASSERT_TRUE(test_server_->Start()); |
268 LOG(INFO) << "server is " << test_server_->host_port_pair().ToString(); | 267 LOG(INFO) << "server is " << test_server_->host_port_pair().ToString(); |
269 | 268 |
270 // Point to the testing server for all SafeBrowsing requests. | 269 // Point to the testing server for all SafeBrowsing requests. |
271 std::string url_prefix = test_server_->GetURL("safebrowsing").spec(); | 270 std::string url_prefix = test_server_->GetURL("safebrowsing").spec(); |
272 sb_factory_.reset(new TestSafeBrowsingServiceFactory(url_prefix)); | 271 sb_factory_.reset(new TestSafeBrowsingServiceFactory(url_prefix)); |
273 SafeBrowsingService::RegisterFactory(sb_factory_.get()); | 272 SafeBrowsingService::RegisterFactory(sb_factory_.get()); |
274 | 273 |
275 InProcessBrowserTest::SetUp(); | 274 InProcessBrowserTest::SetUp(); |
276 } | 275 } |
277 | 276 |
278 virtual void TearDown() override { | 277 void TearDown() override { |
279 InProcessBrowserTest::TearDown(); | 278 InProcessBrowserTest::TearDown(); |
280 | 279 |
281 SafeBrowsingService::RegisterFactory(NULL); | 280 SafeBrowsingService::RegisterFactory(NULL); |
282 } | 281 } |
283 | 282 |
284 void SetUpCommandLine(CommandLine* command_line) override { | 283 void SetUpCommandLine(CommandLine* command_line) override { |
285 // This test uses loopback. No need to use IPv6 especially it makes | 284 // This test uses loopback. No need to use IPv6 especially it makes |
286 // local requests slow on Windows trybot when ipv6 local address [::1] | 285 // local requests slow on Windows trybot when ipv6 local address [::1] |
287 // is not setup. | 286 // is not setup. |
288 command_line->AppendSwitch(switches::kDisableIPv6); | 287 command_line->AppendSwitch(switches::kDisableIPv6); |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 safe_browsing_helper->FetchDBToVerify(test_server(), step)); | 572 safe_browsing_helper->FetchDBToVerify(test_server(), step)); |
574 EXPECT_GT(safe_browsing_helper->response_data().size(), 0U); | 573 EXPECT_GT(safe_browsing_helper->response_data().size(), 0U); |
575 last_step = step; | 574 last_step = step; |
576 } | 575 } |
577 | 576 |
578 // Verifies with server if test is done and waits till server responses. | 577 // Verifies with server if test is done and waits till server responses. |
579 EXPECT_EQ(net::URLRequestStatus::SUCCESS, | 578 EXPECT_EQ(net::URLRequestStatus::SUCCESS, |
580 safe_browsing_helper->VerifyTestComplete(test_server(), last_step)); | 579 safe_browsing_helper->VerifyTestComplete(test_server(), last_step)); |
581 EXPECT_EQ("yes", safe_browsing_helper->response_data()); | 580 EXPECT_EQ("yes", safe_browsing_helper->response_data()); |
582 } | 581 } |
OLD | NEW |