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

Side by Side Diff: ios/web/web_state/ui/crw_web_controller_unittest.mm

Issue 2864133002: Convert iOS to use X509CertificateBytes. (Closed)
Patch Set: static_cast, more unittest Created 3 years, 7 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
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 #import "ios/web/web_state/ui/crw_web_controller.h" 5 #import "ios/web/web_state/ui/crw_web_controller.h"
6 6
7 #import <WebKit/WebKit.h> 7 #import <WebKit/WebKit.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 20 matching lines...) Expand all
31 #import "ios/web/public/web_state/ui/crw_web_view_content_view.h" 31 #import "ios/web/public/web_state/ui/crw_web_view_content_view.h"
32 #include "ios/web/public/web_state/url_verification_constants.h" 32 #include "ios/web/public/web_state/url_verification_constants.h"
33 #include "ios/web/public/web_state/web_state_observer.h" 33 #include "ios/web/public/web_state/web_state_observer.h"
34 #import "ios/web/test/web_test_with_web_controller.h" 34 #import "ios/web/test/web_test_with_web_controller.h"
35 #import "ios/web/test/wk_web_view_crash_utils.h" 35 #import "ios/web/test/wk_web_view_crash_utils.h"
36 #import "ios/web/web_state/ui/crw_web_controller_container_view.h" 36 #import "ios/web/web_state/ui/crw_web_controller_container_view.h"
37 #import "ios/web/web_state/ui/web_view_js_utils.h" 37 #import "ios/web/web_state/ui/web_view_js_utils.h"
38 #import "ios/web/web_state/web_state_impl.h" 38 #import "ios/web/web_state/web_state_impl.h"
39 #import "ios/web/web_state/wk_web_view_security_util.h" 39 #import "ios/web/web_state/wk_web_view_security_util.h"
40 #import "net/base/mac/url_conversions.h" 40 #import "net/base/mac/url_conversions.h"
41 #include "net/cert/x509_util_ios_and_mac.h"
41 #include "net/ssl/ssl_info.h" 42 #include "net/ssl/ssl_info.h"
42 #include "net/test/cert_test_util.h" 43 #include "net/test/cert_test_util.h"
43 #include "net/test/test_data_directory.h" 44 #include "net/test/test_data_directory.h"
44 #include "testing/gtest/include/gtest/gtest.h" 45 #include "testing/gtest/include/gtest/gtest.h"
45 #import "testing/gtest_mac.h" 46 #import "testing/gtest_mac.h"
46 #include "third_party/ocmock/OCMock/OCMock.h" 47 #include "third_party/ocmock/OCMock/OCMock.h"
47 #include "third_party/ocmock/gtest_support.h" 48 #include "third_party/ocmock/gtest_support.h"
48 #include "third_party/ocmock/ocmock_extensions.h" 49 #include "third_party/ocmock/ocmock_extensions.h"
49 #import "ui/base/test/ios/ui_view_test_utils.h" 50 #import "ui/base/test/ios/ui_view_test_utils.h"
50 51
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 183
183 // Last arguments passed to AllowCertificateError must be in default state. 184 // Last arguments passed to AllowCertificateError must be in default state.
184 ASSERT_FALSE(GetWebClient()->last_cert_error_code()); 185 ASSERT_FALSE(GetWebClient()->last_cert_error_code());
185 ASSERT_FALSE(GetWebClient()->last_cert_error_ssl_info().is_valid()); 186 ASSERT_FALSE(GetWebClient()->last_cert_error_ssl_info().is_valid());
186 ASSERT_FALSE(GetWebClient()->last_cert_error_ssl_info().cert_status); 187 ASSERT_FALSE(GetWebClient()->last_cert_error_ssl_info().cert_status);
187 ASSERT_FALSE(GetWebClient()->last_cert_error_request_url().is_valid()); 188 ASSERT_FALSE(GetWebClient()->last_cert_error_request_url().is_valid());
188 ASSERT_TRUE(GetWebClient()->last_cert_error_overridable()); 189 ASSERT_TRUE(GetWebClient()->last_cert_error_overridable());
189 190
190 scoped_refptr<net::X509Certificate> cert = 191 scoped_refptr<net::X509Certificate> cert =
191 net::ImportCertFromFile(net::GetTestCertsDirectory(), "ok_cert.pem"); 192 net::ImportCertFromFile(net::GetTestCertsDirectory(), "ok_cert.pem");
193 ASSERT_TRUE(cert);
194 base::ScopedCFTypeRef<CFMutableArrayRef> chain(
195 net::x509_util::CreateSecCertificateArrayForX509Certificate(cert.get()));
196 ASSERT_TRUE(chain);
192 197
193 NSArray* chain = @[ static_cast<id>(cert->os_cert_handle()) ];
194 GURL url("https://chromium.test"); 198 GURL url("https://chromium.test");
195 NSError* error = 199 NSError* error =
196 [NSError errorWithDomain:NSURLErrorDomain 200 [NSError errorWithDomain:NSURLErrorDomain
197 code:NSURLErrorServerCertificateHasUnknownRoot 201 code:NSURLErrorServerCertificateHasUnknownRoot
198 userInfo:@{ 202 userInfo:@{
199 web::kNSErrorPeerCertificateChainKey : chain, 203 web::kNSErrorPeerCertificateChainKey :
204 static_cast<NSArray*>(chain.get()),
200 web::kNSErrorFailingURLKey : net::NSURLWithGURL(url), 205 web::kNSErrorFailingURLKey : net::NSURLWithGURL(url),
201 }]; 206 }];
202 base::scoped_nsobject<NSObject> navigation([[NSObject alloc] init]); 207 base::scoped_nsobject<NSObject> navigation([[NSObject alloc] init]);
203 [navigation_delegate_ webView:mock_web_view_ 208 [navigation_delegate_ webView:mock_web_view_
204 didStartProvisionalNavigation:static_cast<WKNavigation*>(navigation)]; 209 didStartProvisionalNavigation:static_cast<WKNavigation*>(navigation)];
205 [navigation_delegate_ webView:mock_web_view_ 210 [navigation_delegate_ webView:mock_web_view_
206 didFailProvisionalNavigation:static_cast<WKNavigation*>(navigation) 211 didFailProvisionalNavigation:static_cast<WKNavigation*>(navigation)
207 withError:error]; 212 withError:error];
208 213
209 // Verify correctness of AllowCertificateError method call. 214 // Verify correctness of AllowCertificateError method call.
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 web::TestWebStateObserver* observer_ptr = &observer; 952 web::TestWebStateObserver* observer_ptr = &observer;
948 web::SimulateWKWebViewCrash(webView_); 953 web::SimulateWKWebViewCrash(webView_);
949 base::test::ios::WaitUntilCondition(^bool() { 954 base::test::ios::WaitUntilCondition(^bool() {
950 return observer_ptr->render_process_gone_info(); 955 return observer_ptr->render_process_gone_info();
951 }); 956 });
952 EXPECT_EQ(web_state(), observer.render_process_gone_info()->web_state); 957 EXPECT_EQ(web_state(), observer.render_process_gone_info()->web_state);
953 EXPECT_FALSE([web_controller() isViewAlive]); 958 EXPECT_FALSE([web_controller() isViewAlive]);
954 }; 959 };
955 960
956 } // namespace 961 } // namespace
OLDNEW
« no previous file with comments | « ios/web/web_state/ui/crw_web_controller.mm ('k') | ios/web/web_state/wk_web_view_security_util.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698