OLD | NEW |
---|---|
(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 { | |
18 | |
19 const std::string kHostname = "test.mail.google.com"; | |
Ryan Sleevi
2015/03/06 21:32:47
s/std::string kHostname/const char kHostname[]/
(
estark
2015/03/07 00:38:50
Done.
| |
20 | |
21 SSLInfo GetSSLInfo() { | |
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"; | |
Ryan Sleevi
2015/03/06 21:32:47
Should this be a constant (line 26 vs 51)
estark
2015/03/07 00:38:50
Done.
| |
27 return info; | |
28 } | |
29 | |
30 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 } // namespace | |
39 | |
40 namespace chrome_browser_net { | |
41 | |
42 // Test that a built report has the correct data. | |
43 TEST(CertificateErrorReporterTest, ReportIsBuiltCorrectly) { | |
44 SSLInfo info = GetSSLInfo(); | |
45 CertLoggerRequest request; | |
46 CertificateErrorReporter::BuildReport(kHostname, info, request); | |
47 | |
48 EXPECT_EQ(request.hostname(), kHostname); | |
Ryan Sleevi
2015/03/06 21:32:47
You only use this constant once. Were you intendin
estark
2015/03/07 00:38:50
Yes, and I am now.
| |
49 EXPECT_EQ(request.cert_chain(), GetPEMEncodedChain()); | |
50 EXPECT_EQ(request.pin().size(), 1); | |
51 EXPECT_EQ(request.pin().Get(0), "dummy failure log"); | |
52 } | |
53 | |
54 } // namespace chrome_browser_net | |
OLD | NEW |