OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "chrome/browser/safe_browsing/certificate_reporting_service_test_utils.
h" | 5 #include "chrome/browser/safe_browsing/certificate_reporting_service_test_utils.
h" |
6 | 6 |
7 #include "base/threading/thread_task_runner_handle.h" | 7 #include "base/threading/thread_task_runner_handle.h" |
8 #include "components/certificate_reporting/encrypted_cert_logger.pb.h" | 8 #include "components/certificate_reporting/encrypted_cert_logger.pb.h" |
9 #include "components/certificate_reporting/error_report.h" | 9 #include "components/certificate_reporting/error_report.h" |
10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
11 #include "content/public/test/test_utils.h" | 11 #include "content/public/test/test_utils.h" |
12 #include "crypto/curve25519.h" | |
13 #include "net/base/upload_bytes_element_reader.h" | 12 #include "net/base/upload_bytes_element_reader.h" |
14 #include "net/base/upload_data_stream.h" | 13 #include "net/base/upload_data_stream.h" |
15 #include "net/url_request/url_request_filter.h" | 14 #include "net/url_request/url_request_filter.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "third_party/boringssl/src/include/openssl/curve25519.h" |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 const uint32_t kServerPublicKeyTestVersion = 16; | 20 const uint32_t kServerPublicKeyTestVersion = 16; |
21 | 21 |
22 void SetUpURLHandlersOnIOThread( | 22 void SetUpURLHandlersOnIOThread( |
23 std::unique_ptr<net::URLRequestInterceptor> url_request_interceptor) { | 23 std::unique_ptr<net::URLRequestInterceptor> url_request_interceptor) { |
24 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 24 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
25 net::URLRequestFilter* filter = net::URLRequestFilter::GetInstance(); | 25 net::URLRequestFilter* filter = net::URLRequestFilter::GetInstance(); |
26 filter->AddUrlInterceptor( | 26 filter->AddUrlInterceptor( |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 } | 369 } |
370 | 370 |
371 void CertificateReportingServiceObserver::OnServiceReset() { | 371 void CertificateReportingServiceObserver::OnServiceReset() { |
372 did_reset_ = true; | 372 did_reset_ = true; |
373 if (run_loop_) | 373 if (run_loop_) |
374 run_loop_->Quit(); | 374 run_loop_->Quit(); |
375 } | 375 } |
376 | 376 |
377 CertificateReportingServiceTestHelper::CertificateReportingServiceTestHelper() { | 377 CertificateReportingServiceTestHelper::CertificateReportingServiceTestHelper() { |
378 memset(server_private_key_, 1, sizeof(server_private_key_)); | 378 memset(server_private_key_, 1, sizeof(server_private_key_)); |
379 crypto::curve25519::ScalarBaseMult(server_private_key_, server_public_key_); | 379 X25519_public_from_private(server_public_key_, server_private_key_); |
380 } | 380 } |
381 | 381 |
382 CertificateReportingServiceTestHelper:: | 382 CertificateReportingServiceTestHelper:: |
383 ~CertificateReportingServiceTestHelper() {} | 383 ~CertificateReportingServiceTestHelper() {} |
384 | 384 |
385 void CertificateReportingServiceTestHelper::SetUpInterceptor() { | 385 void CertificateReportingServiceTestHelper::SetUpInterceptor() { |
386 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 386 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
387 url_request_interceptor_ = | 387 url_request_interceptor_ = |
388 new CertReportJobInterceptor(REPORTS_FAIL, server_private_key_); | 388 new CertReportJobInterceptor(REPORTS_FAIL, server_private_key_); |
389 content::BrowserThread::PostTask( | 389 content::BrowserThread::PostTask( |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 | 438 |
439 if (service->GetReporterForTesting()) { | 439 if (service->GetReporterForTesting()) { |
440 // Reporter can be null if reporting is disabled. | 440 // Reporter can be null if reporting is disabled. |
441 EXPECT_EQ( | 441 EXPECT_EQ( |
442 0u, | 442 0u, |
443 service->GetReporterForTesting()->inflight_report_count_for_testing()); | 443 service->GetReporterForTesting()->inflight_report_count_for_testing()); |
444 } | 444 } |
445 } | 445 } |
446 | 446 |
447 } // namespace certificate_reporting_test_utils | 447 } // namespace certificate_reporting_test_utils |
OLD | NEW |