Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: components/certificate_reporting/error_reporter_unittest.cc

Issue 2163223005: Remove //content dependency for tests in certificate_reporting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove #include Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/certificate_reporting/DEPS ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/certificate_reporting/error_reporter.h" 5 #include "components/certificate_reporting/error_reporter.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include <set> 10 #include <set>
11 #include <string> 11 #include <string>
12 12
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/bind_helpers.h" 14 #include "base/bind_helpers.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/ptr_util.h" 16 #include "base/memory/ptr_util.h"
17 #include "base/message_loop/message_loop.h"
17 #include "base/run_loop.h" 18 #include "base/run_loop.h"
18 #include "base/test/histogram_tester.h" 19 #include "base/test/histogram_tester.h"
19 #include "components/certificate_reporting/encrypted_cert_logger.pb.h" 20 #include "components/certificate_reporting/encrypted_cert_logger.pb.h"
20 #include "content/public/test/test_browser_thread_bundle.h"
21 #include "crypto/curve25519.h" 21 #include "crypto/curve25519.h"
22 #include "net/test/url_request/url_request_failed_job.h" 22 #include "net/test/url_request/url_request_failed_job.h"
23 #include "net/url_request/report_sender.h" 23 #include "net/url_request/report_sender.h"
24 #include "net/url_request/url_request_test_util.h" 24 #include "net/url_request/url_request_test_util.h"
25 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
26 26
27 namespace certificate_reporting { 27 namespace certificate_reporting {
28 28
29 namespace { 29 namespace {
30 30
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 } 75 }
76 76
77 private: 77 private:
78 base::Closure url_request_destroyed_callback_; 78 base::Closure url_request_destroyed_callback_;
79 79
80 DISALLOW_COPY_AND_ASSIGN(TestCertificateReporterNetworkDelegate); 80 DISALLOW_COPY_AND_ASSIGN(TestCertificateReporterNetworkDelegate);
81 }; 81 };
82 82
83 class ErrorReporterTest : public ::testing::Test { 83 class ErrorReporterTest : public ::testing::Test {
84 public: 84 public:
85 ErrorReporterTest() 85 ErrorReporterTest() {
86 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) {
87 memset(server_private_key_, 1, sizeof(server_private_key_)); 86 memset(server_private_key_, 1, sizeof(server_private_key_));
88 crypto::curve25519::ScalarBaseMult(server_private_key_, server_public_key_); 87 crypto::curve25519::ScalarBaseMult(server_private_key_, server_public_key_);
89 } 88 }
90 89
91 ~ErrorReporterTest() override {} 90 ~ErrorReporterTest() override {}
92 91
93 protected: 92 protected:
94 content::TestBrowserThreadBundle thread_bundle_; 93 base::MessageLoopForIO loop_;
95 uint8_t server_public_key_[32]; 94 uint8_t server_public_key_[32];
96 uint8_t server_private_key_[32]; 95 uint8_t server_private_key_[32];
97 96
98 DISALLOW_COPY_AND_ASSIGN(ErrorReporterTest); 97 DISALLOW_COPY_AND_ASSIGN(ErrorReporterTest);
99 }; 98 };
100 99
101 // Test that ErrorReporter::SendExtendedReportingReport sends 100 // Test that ErrorReporter::SendExtendedReportingReport sends
102 // an encrypted or plaintext extended reporting report as appropriate. 101 // an encrypted or plaintext extended reporting report as appropriate.
103 TEST_F(ErrorReporterTest, ExtendedReportingSendReport) { 102 TEST_F(ErrorReporterTest, ExtendedReportingSendReport) {
104 // Data should not be encrypted when sent to an HTTPS URL. 103 // Data should not be encrypted when sent to an HTTPS URL.
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 ASSERT_TRUE(encrypted_request.ParseFromString( 318 ASSERT_TRUE(encrypted_request.ParseFromString(
320 std::string(reinterpret_cast<const char*>(kSerializedEncryptedReport), 319 std::string(reinterpret_cast<const char*>(kSerializedEncryptedReport),
321 sizeof(kSerializedEncryptedReport)))); 320 sizeof(kSerializedEncryptedReport))));
322 ASSERT_TRUE(ErrorReporter::DecryptErrorReport( 321 ASSERT_TRUE(ErrorReporter::DecryptErrorReport(
323 server_private_key_, encrypted_request, &decrypted_serialized_report)); 322 server_private_key_, encrypted_request, &decrypted_serialized_report));
324 } 323 }
325 324
326 } // namespace 325 } // namespace
327 326
328 } // namespace certificate_reporting 327 } // namespace certificate_reporting
OLDNEW
« no previous file with comments | « components/certificate_reporting/DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698