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

Side by Side Diff: ios/web/net/crw_ssl_status_updater_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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/net/crw_ssl_status_updater.h" 5 #import "ios/web/net/crw_ssl_status_updater.h"
6 6
7 #include "base/mac/scoped_block.h" 7 #include "base/mac/scoped_block.h"
8 #include "base/strings/sys_string_conversions.h" 8 #include "base/strings/sys_string_conversions.h"
9 #import "ios/web/navigation/crw_session_controller+private_constructors.h" 9 #import "ios/web/navigation/crw_session_controller+private_constructors.h"
10 #import "ios/web/navigation/crw_session_controller.h" 10 #import "ios/web/navigation/crw_session_controller.h"
11 #import "ios/web/navigation/navigation_manager_impl.h" 11 #import "ios/web/navigation/navigation_manager_impl.h"
12 #import "ios/web/public/navigation_item.h" 12 #import "ios/web/public/navigation_item.h"
13 #include "ios/web/public/ssl_status.h" 13 #include "ios/web/public/ssl_status.h"
14 #include "ios/web/public/test/web_test.h" 14 #include "ios/web/public/test/web_test.h"
15 #import "ios/web/web_state/wk_web_view_security_util.h" 15 #import "ios/web/web_state/wk_web_view_security_util.h"
16 #include "net/cert/x509_util_ios_and_mac.h"
16 #include "net/test/cert_test_util.h" 17 #include "net/test/cert_test_util.h"
17 #include "net/test/test_data_directory.h" 18 #include "net/test/test_data_directory.h"
18 #include "third_party/ocmock/OCMock/OCMock.h" 19 #include "third_party/ocmock/OCMock/OCMock.h"
19 #include "third_party/ocmock/gtest_support.h" 20 #include "third_party/ocmock/gtest_support.h"
20 21
21 // Mocks CRWSSLStatusUpdaterTestDataSource. 22 // Mocks CRWSSLStatusUpdaterTestDataSource.
22 @interface CRWSSLStatusUpdaterTestDataSource 23 @interface CRWSSLStatusUpdaterTestDataSource
23 : NSObject<CRWSSLStatusUpdaterDataSource> { 24 : NSObject<CRWSSLStatusUpdaterDataSource> {
24 base::mac::ScopedBlock<StatusQueryHandler> _verificationCompletionHandler; 25 base::mac::ScopedBlock<StatusQueryHandler> _verificationCompletionHandler;
25 } 26 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 86
86 ssl_status_updater_.reset([[CRWSSLStatusUpdater alloc] 87 ssl_status_updater_.reset([[CRWSSLStatusUpdater alloc]
87 initWithDataSource:data_source_ 88 initWithDataSource:data_source_
88 navigationManager:nav_manager_.get()]); 89 navigationManager:nav_manager_.get()]);
89 [ssl_status_updater_ setDelegate:delegate_]; 90 [ssl_status_updater_ setDelegate:delegate_];
90 91
91 // Create test cert chain. 92 // Create test cert chain.
92 scoped_refptr<net::X509Certificate> cert = 93 scoped_refptr<net::X509Certificate> cert =
93 net::ImportCertFromFile(net::GetTestCertsDirectory(), kCertFileName); 94 net::ImportCertFromFile(net::GetTestCertsDirectory(), kCertFileName);
94 ASSERT_TRUE(cert); 95 ASSERT_TRUE(cert);
95 NSArray* chain = @[ static_cast<id>(cert->os_cert_handle()) ]; 96 base::ScopedCFTypeRef<CFMutableArrayRef> chain(
96 trust_ = CreateServerTrustFromChain(chain, kHostName); 97 net::x509_util::CreateSecCertificateArrayForX509Certificate(
98 cert.get()));
99 ASSERT_TRUE(chain);
100 trust_ = CreateServerTrustFromChain(static_cast<NSArray*>(chain.get()),
101 kHostName);
97 } 102 }
98 103
99 void TearDown() override { 104 void TearDown() override {
100 EXPECT_OCMOCK_VERIFY(delegate_); 105 EXPECT_OCMOCK_VERIFY(delegate_);
101 web::WebTest::TearDown(); 106 web::WebTest::TearDown();
102 } 107 }
103 108
104 // Returns autoreleased session controller with a single committed entry. 109 // Returns autoreleased session controller with a single committed entry.
105 CRWSessionController* SessionControllerWithEntry(std::string item_url_spec) { 110 CRWSessionController* SessionControllerWithEntry(std::string item_url_spec) {
106 std::vector<std::unique_ptr<web::NavigationItem>> nav_items; 111 std::vector<std::unique_ptr<web::NavigationItem>> nav_items;
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 [data_source_ 364 [data_source_
360 finishVerificationWithCertStatus:0 365 finishVerificationWithCertStatus:0
361 securityStyle:web::SECURITY_STYLE_AUTHENTICATED]; 366 securityStyle:web::SECURITY_STYLE_AUTHENTICATED];
362 367
363 // Make sure that security style and content status did change. 368 // Make sure that security style and content status did change.
364 EXPECT_EQ(web::SECURITY_STYLE_UNKNOWN, item->GetSSL().security_style); 369 EXPECT_EQ(web::SECURITY_STYLE_UNKNOWN, item->GetSSL().security_style);
365 EXPECT_EQ(web::SSLStatus::NORMAL_CONTENT, item->GetSSL().content_status); 370 EXPECT_EQ(web::SSLStatus::NORMAL_CONTENT, item->GetSSL().content_status);
366 } 371 }
367 372
368 } // namespace web 373 } // namespace web
OLDNEW
« no previous file with comments | « ios/web/net/crw_cert_verification_controller_unittest.mm ('k') | ios/web/web_state/ui/crw_web_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698