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

Side by Side Diff: ios/web/web_state/wk_web_view_security_util_unittest.mm

Issue 1861593005: Convert //ios from scoped_ptr to std::unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 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 #import "ios/web/web_state/wk_web_view_security_util.h" 5 #import "ios/web/web_state/wk_web_view_security_util.h"
6 6
7 #import <Foundation/Foundation.h> 7 #import <Foundation/Foundation.h>
8 #include <Security/Security.h> 8 #include <Security/Security.h>
9 9
10 #include <memory>
11
10 #include "base/mac/scoped_cftyperef.h" 12 #include "base/mac/scoped_cftyperef.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "crypto/rsa_private_key.h" 13 #include "crypto/rsa_private_key.h"
13 #include "net/cert/x509_cert_types.h" 14 #include "net/cert/x509_cert_types.h"
14 #include "net/cert/x509_certificate.h" 15 #include "net/cert/x509_certificate.h"
15 #include "net/cert/x509_util.h" 16 #include "net/cert/x509_util.h"
16 #include "net/ssl/ssl_info.h" 17 #include "net/ssl/ssl_info.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 #include "testing/gtest_mac.h" 19 #include "testing/gtest_mac.h"
19 #include "testing/platform_test.h" 20 #include "testing/platform_test.h"
20 21
21 namespace web { 22 namespace web {
22 namespace { 23 namespace {
23 // Subject for testing self-signed certificate. 24 // Subject for testing self-signed certificate.
24 const char kTestSubject[] = "self-signed"; 25 const char kTestSubject[] = "self-signed";
25 // Hostname for testing SecTrustRef objects. 26 // Hostname for testing SecTrustRef objects.
26 NSString* const kTestHost = @"www.example.com"; 27 NSString* const kTestHost = @"www.example.com";
27 28
28 // Returns an autoreleased certificate chain for testing. Chain will contain a 29 // Returns an autoreleased certificate chain for testing. Chain will contain a
29 // single self-signed cert with |subject| as a subject. 30 // single self-signed cert with |subject| as a subject.
30 NSArray* MakeTestCertChain(const std::string& subject) { 31 NSArray* MakeTestCertChain(const std::string& subject) {
31 scoped_ptr<crypto::RSAPrivateKey> private_key; 32 std::unique_ptr<crypto::RSAPrivateKey> private_key;
32 std::string der_cert; 33 std::string der_cert;
33 net::x509_util::CreateKeyAndSelfSignedCert( 34 net::x509_util::CreateKeyAndSelfSignedCert(
34 "CN=" + subject, 1, base::Time::Now(), 35 "CN=" + subject, 1, base::Time::Now(),
35 base::Time::Now() + base::TimeDelta::FromDays(1), &private_key, 36 base::Time::Now() + base::TimeDelta::FromDays(1), &private_key,
36 &der_cert); 37 &der_cert);
37 38
38 base::ScopedCFTypeRef<SecCertificateRef> cert( 39 base::ScopedCFTypeRef<SecCertificateRef> cert(
39 net::X509Certificate::CreateOSCertHandleFromBytes(der_cert.data(), 40 net::X509Certificate::CreateOSCertHandleFromBytes(der_cert.data(),
40 der_cert.size())); 41 der_cert.size()));
41 NSArray* result = @[ reinterpret_cast<id>(cert.get()) ]; 42 NSArray* result = @[ reinterpret_cast<id>(cert.get()) ];
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 GetSecurityStyleFromTrustResult(kSecTrustResultUnspecified)); 276 GetSecurityStyleFromTrustResult(kSecTrustResultUnspecified));
276 } 277 }
277 278
278 // Tests GetSecurityStyleFromTrustResult with invalid SecTrustResultType result. 279 // Tests GetSecurityStyleFromTrustResult with invalid SecTrustResultType result.
279 TEST_F(WKWebViewSecurityUtilTest, GetSecurityStyleFromInvalidResult) { 280 TEST_F(WKWebViewSecurityUtilTest, GetSecurityStyleFromInvalidResult) {
280 EXPECT_EQ(SECURITY_STYLE_UNKNOWN, 281 EXPECT_EQ(SECURITY_STYLE_UNKNOWN,
281 GetSecurityStyleFromTrustResult(kSecTrustResultInvalid)); 282 GetSecurityStyleFromTrustResult(kSecTrustResultInvalid));
282 } 283 }
283 284
284 } // namespace web 285 } // namespace web
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698