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

Side by Side Diff: chrome/browser/net/certificate_error_reporter_unittest.cc

Issue 979893003: Refactor ChromeFraudulentCertReporter for code reuse by SSL reporting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rsleevi's comments + fix CreateURLRequest confusion Created 5 years, 9 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/net/certificate_error_reporter.h"
6
7 #include "base/files/file_util.h"
8 #include "chrome/browser/net/cert_logger.pb.h"
9 #include "content/public/test/test_browser_thread.h"
10 #include "net/base/test_data_directory.h"
11 #include "net/test/cert_test_util.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13
14 using content::BrowserThread;
15 using net::SSLInfo;
16
17 namespace chrome_browser_net {
18
19 const std::string kHostname = "test.mail.google.com";
Ryan Sleevi 2015/03/06 19:23:13 You should put all of these (including the test) i
estark 2015/03/06 19:52:06 If I put the test in an unnamed namespace, I can't
estark 2015/03/06 20:10:02 Done, except for the test for above reason.
Ryan Sleevi 2015/03/06 21:32:46 Ah, right, because the test is friended you can't.
20
21 static SSLInfo GetSSLInfo() {
Ryan Sleevi 2015/03/06 19:23:13 /static/ is not needed here (and perversely, undes
estark 2015/03/06 20:10:02 Done.
22 SSLInfo info;
23 info.cert = net::ImportCertFromFile(net::GetTestCertsDirectory(),
24 "test_mail_google_com.pem");
25 info.is_issued_by_known_root = true;
26 info.pinning_failure_log = "dummy failure log";
27 return info;
28 }
29
30 static std::string GetPEMEncodedChain() {
31 base::FilePath cert_path =
32 net::GetTestCertsDirectory().AppendASCII("test_mail_google_com.pem");
33 std::string cert_data;
34 EXPECT_TRUE(base::ReadFileToString(cert_path, &cert_data));
35 return cert_data;
36 }
37
38 // Test that a built report has the correct data.
39 TEST(CertificateErrorReporterTest, ReportIsBuiltCorrectly) {
Ryan Sleevi 2015/03/06 19:23:13 This test is mostly testing the implementation det
estark 2015/03/06 19:28:18 I had a question about writing those kinds of test
40 SSLInfo info = GetSSLInfo();
41 CertLoggerRequest request;
42 CertificateErrorReporter::BuildReport(kHostname, info, request);
43
44 EXPECT_EQ(request.hostname(), kHostname);
45 EXPECT_EQ(request.cert_chain(), GetPEMEncodedChain());
46 EXPECT_EQ(request.pin().size(), 1);
47 EXPECT_EQ(request.pin().Get(0), "dummy failure log");
48 }
49
50 } // namespace chrome_browser_net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698