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

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

Issue 1231783003: WKWebView: Do not DCHECK on invalid CertVerifierBlockAdapter::Params. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 | « ios/web/net/cert_verifier_block_adapter.cc ('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 "ios/web/net/cert_verifier_block_adapter.h" 5 #include "ios/web/net/cert_verifier_block_adapter.h"
6 6
7 #include "base/test/ios/wait_util.h" 7 #include "base/test/ios/wait_util.h"
8 #include "net/base/net_errors.h" 8 #include "net/base/net_errors.h"
9 #include "net/cert/cert_verify_result.h" 9 #include "net/cert/cert_verify_result.h"
10 #include "net/cert/crl_set.h" 10 #include "net/cert/crl_set.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 int actualStatus = -1; 128 int actualStatus = -1;
129 CertVerifierBlockAdapter::Params params(cert_.get(), kHostName); 129 CertVerifierBlockAdapter::Params params(cert_.get(), kHostName);
130 Verify(params, &actualResult, &actualStatus); 130 Verify(params, &actualResult, &actualStatus);
131 131
132 // Ensure that Verification results are correct. 132 // Ensure that Verification results are correct.
133 EXPECT_EQ(kExpectedStatus, actualStatus); 133 EXPECT_EQ(kExpectedStatus, actualStatus);
134 EXPECT_EQ(expectedResult.is_issued_by_known_root, 134 EXPECT_EQ(expectedResult.is_issued_by_known_root,
135 actualResult->is_issued_by_known_root); 135 actualResult->is_issued_by_known_root);
136 } 136 }
137 137
138 // Tests |Verify| with invalid arguments.
139 TEST_F(CertVerifierBlockAdapterTest, InvalidParamsAndError) {
140 // Set up expectation.
141 const int kExpectedStatus = ERR_INVALID_ARGUMENT;
142 EXPECT_CALL(*cert_verifier_mock_,
143 Verify(nullptr, "", "", 0, nullptr, _, _, _, _))
144 .Times(1)
145 .WillOnce(testing::Return(kExpectedStatus));
146
147 // Call |Verify|.
148 scoped_ptr<CertVerifyResult> actualResult;
149 int actualStatus = -1;
150 CertVerifierBlockAdapter::Params params(nullptr, "");
151 Verify(params, &actualResult, &actualStatus);
152
153 // Ensure that Verification results are correct.
154 EXPECT_EQ(kExpectedStatus, actualStatus);
155 EXPECT_FALSE(actualResult);
156 }
157
138 // Tests |Verify| with error. 158 // Tests |Verify| with error.
139 TEST_F(CertVerifierBlockAdapterTest, DefaultParamsAndError) { 159 TEST_F(CertVerifierBlockAdapterTest, DefaultParamsAndError) {
140 // Set up expectation. 160 // Set up expectation.
141 const int kExpectedStatus = ERR_INSUFFICIENT_RESOURCES; 161 const int kExpectedStatus = ERR_INSUFFICIENT_RESOURCES;
142 EXPECT_CALL(*cert_verifier_mock_, 162 EXPECT_CALL(*cert_verifier_mock_,
143 Verify(cert_.get(), kHostName, "", 0, nullptr, _, _, _, _)) 163 Verify(cert_.get(), kHostName, "", 0, nullptr, _, _, _, _))
144 .Times(1) 164 .Times(1)
145 .WillOnce(testing::Return(kExpectedStatus)); 165 .WillOnce(testing::Return(kExpectedStatus));
146 166
147 // Call |Verify|. 167 // Call |Verify|.
(...skipping 29 matching lines...) Expand all
177 params.flags = CertVerifier::VERIFY_EV_CERT; 197 params.flags = CertVerifier::VERIFY_EV_CERT;
178 params.crl_set = crl_set; 198 params.crl_set = crl_set;
179 Verify(params, &actualResult, &actualStatus); 199 Verify(params, &actualResult, &actualStatus);
180 200
181 // Ensure that Verification results are correct. 201 // Ensure that Verification results are correct.
182 EXPECT_EQ(kExpectedStatus, actualStatus); 202 EXPECT_EQ(kExpectedStatus, actualStatus);
183 EXPECT_EQ(expectedResult.verified_cert, actualResult->verified_cert); 203 EXPECT_EQ(expectedResult.verified_cert, actualResult->verified_cert);
184 } 204 }
185 205
186 } // namespace 206 } // namespace
OLDNEW
« no previous file with comments | « ios/web/net/cert_verifier_block_adapter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698