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

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 Joel's review comments Created 5 years, 2 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 "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 // Test cert filenames.
15 const char kCertFileName1[] = "ok_cert.pem";
16 const char kCertFileName2[] = "expired_cert.pem";
17 // Test hostnames.
18 const char kHostName1[] = "www.example.com";
19 const char kHostName2[] = "www.chromium.org";
Ryan Sleevi 2015/10/19 23:56:21 www.example.com is specially reserved for testing,
Eugene But (OOO till 7-30) 2015/10/21 04:01:02 Done.
20 } // namespace
21
22 // Test fixture to test CertHostPair struct.
23 class CertHostPairTest : public PlatformTest {
24 protected:
25 // Loads cert with the given |file_name|.
26 scoped_refptr<net::X509Certificate> GetCert(
27 const std::string& file_name) const {
28 return net::ImportCertFromFile(net::GetTestCertsDirectory(), file_name);
29 }
30 };
31
32 // Tests constructions.
33 TEST_F(CertHostPairTest, Construction) {
34 scoped_refptr<net::X509Certificate> cert = GetCert(kCertFileName1);
35 CertHostPair pair(cert, kHostName1);
36 EXPECT_EQ(cert, pair.cert);
37 EXPECT_EQ(std::string(kHostName1), pair.host);
38 }
39
40 // Tests comparision with different certs and hosts.
41 TEST_F(CertHostPairTest, ComparisonWithDifferentCertsAndHosts) {
42 CertHostPair pair1(GetCert(kCertFileName1), kHostName1);
43 CertHostPair pair2(GetCert(kCertFileName2), kHostName2);
44
45 EXPECT_TRUE(pair2 < pair1);
46 EXPECT_FALSE(pair1 < pair2);
47 }
48
49 // Tests comparision with same cert.
50 TEST_F(CertHostPairTest, ComparisonWithSameCert) {
51 CertHostPair pair1(GetCert(kCertFileName1), kHostName1);
52 CertHostPair pair2(GetCert(kCertFileName1), kHostName2);
53
54 EXPECT_TRUE(pair2 < pair1);
55 EXPECT_FALSE(pair1 < pair2);
56 }
57
58 // Tests comparision with same host.
59 TEST_F(CertHostPairTest, ComparisonWithSameHost) {
60 CertHostPair pair1(GetCert(kCertFileName1), kHostName1);
61 CertHostPair pair2(GetCert(kCertFileName2), kHostName1);
62
63 EXPECT_TRUE(pair1 < pair2);
64 EXPECT_FALSE(pair2 < pair1);
65 }
66
67 // Tests comparision with same cert and host.
68 TEST_F(CertHostPairTest, ComparisonWithSameCertAndHost) {
69 CertHostPair pair1(GetCert(kCertFileName1), kHostName1);
70 CertHostPair pair2(GetCert(kCertFileName1), kHostName1);
71
72 EXPECT_FALSE(pair1 < pair2);
73 EXPECT_FALSE(pair2 < pair1);
74 }
75
76 } // namespace web
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698