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

Side by Side Diff: ios/web/net/cert_host_pair_unittest.cc

Issue 1357773002: WKWebView: Implemented recoverable SSL interstitials. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lock_coloring
Patch Set: Addressed unit tests review comments Created 5 years, 1 month 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 | « ios/web/net/cert_host_pair.cc ('k') | ios/web/net/crw_cert_policy_cache.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ios/web/net/cert_host_pair.h"
6
7 #include "net/base/test_data_directory.h"
8 #include "net/test/cert_test_util.h"
9 #include "testing/platform_test.h"
10
11 namespace web {
12
13 namespace {
14
15 // Test cert filenames.
16 const char kCertFileName1[] = "ok_cert.pem";
17 const char kCertFileName2[] = "expired_cert.pem";
18
19 // Test hostnames.
20 const char kHostName1[] = "www.example.com";
21 const char kHostName2[] = "www.chromium.test";
22
23 // Loads cert with the given |file_name|.
24 scoped_refptr<net::X509Certificate> GetCert(const std::string& file_name) {
25 return net::ImportCertFromFile(net::GetTestCertsDirectory(), file_name);
26 }
27
28 } // namespace
29
30 // Test fixture to test CertHostPair struct.
31 typedef PlatformTest CertHostPairTest;
32
33 // Tests constructions.
34 TEST_F(CertHostPairTest, Construction) {
35 scoped_refptr<net::X509Certificate> cert = GetCert(kCertFileName1);
36 ASSERT_TRUE(cert);
37 CertHostPair pair(cert, kHostName1);
38 EXPECT_EQ(cert, pair.cert);
39 EXPECT_EQ(std::string(kHostName1), pair.host);
40 }
41
42 // Tests comparision with different certs and hosts.
43 TEST_F(CertHostPairTest, ComparisonWithDifferentCertsAndHosts) {
44 scoped_refptr<net::X509Certificate> cert1 = GetCert(kCertFileName1);
45 ASSERT_TRUE(cert1);
46 scoped_refptr<net::X509Certificate> cert2 = GetCert(kCertFileName2);
47 ASSERT_TRUE(cert2);
48 CertHostPair pair1(cert1, kHostName1);
49 CertHostPair pair2(cert2, kHostName2);
50
51 EXPECT_TRUE(pair2 < pair1);
52 EXPECT_FALSE(pair1 < pair2);
53 }
54
55 // Tests comparision with same cert.
56 TEST_F(CertHostPairTest, ComparisonWithSameCert) {
57 scoped_refptr<net::X509Certificate> cert1 = GetCert(kCertFileName1);
58 ASSERT_TRUE(cert1);
59 scoped_refptr<net::X509Certificate> cert2 = GetCert(kCertFileName1);
60 ASSERT_TRUE(cert2);
61 CertHostPair pair1(cert1, kHostName1);
62 CertHostPair pair2(cert2, kHostName2);
63
64 EXPECT_TRUE(pair2 < pair1);
65 EXPECT_FALSE(pair1 < pair2);
66 }
67
68 // Tests comparision with same host.
69 TEST_F(CertHostPairTest, ComparisonWithSameHost) {
70 scoped_refptr<net::X509Certificate> cert1 = GetCert(kCertFileName1);
71 ASSERT_TRUE(cert1);
72 scoped_refptr<net::X509Certificate> cert2 = GetCert(kCertFileName2);
73 ASSERT_TRUE(cert2);
74 CertHostPair pair1(cert1, kHostName1);
75 CertHostPair pair2(cert2, kHostName1);
76
77 EXPECT_TRUE(pair1 < pair2);
78 EXPECT_FALSE(pair2 < pair1);
79 }
80
81 // Tests comparision with same cert and host.
82 TEST_F(CertHostPairTest, ComparisonWithSameCertAndHost) {
83 scoped_refptr<net::X509Certificate> cert1 = GetCert(kCertFileName1);
84 ASSERT_TRUE(cert1);
85 scoped_refptr<net::X509Certificate> cert2 = GetCert(kCertFileName1);
86 ASSERT_TRUE(cert2);
87 CertHostPair pair1(cert1, kHostName1);
88 CertHostPair pair2(cert2, kHostName1);
89
90 EXPECT_FALSE(pair1 < pair2);
91 EXPECT_FALSE(pair2 < pair1);
92 }
93
94 } // namespace web
OLDNEW
« no previous file with comments | « ios/web/net/cert_host_pair.cc ('k') | ios/web/net/crw_cert_policy_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698