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

Side by Side Diff: net/http/url_security_manager_unittest.cc

Issue 1545233002: Convert Pass()→std::move() in //net (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 | « net/http/url_security_manager.cc ('k') | net/log/net_log.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "net/http/url_security_manager.h" 5 #include "net/http/url_security_manager.h"
6 6
7 #include <utility>
8
7 #include "net/base/net_errors.h" 9 #include "net/base/net_errors.h"
8 #include "net/http/http_auth_filter.h" 10 #include "net/http/http_auth_filter.h"
9 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
10 #include "url/gurl.h" 12 #include "url/gurl.h"
11 13
12 namespace net { 14 namespace net {
13 15
14 namespace { 16 namespace {
15 17
16 struct TestData { 18 struct TestData {
(...skipping 25 matching lines...) Expand all
42 44
43 } // namespace 45 } // namespace
44 46
45 TEST(URLSecurityManager, UseDefaultCredentials) { 47 TEST(URLSecurityManager, UseDefaultCredentials) {
46 scoped_ptr<HttpAuthFilter> auth_filter( 48 scoped_ptr<HttpAuthFilter> auth_filter(
47 new HttpAuthFilterWhitelist(kTestAuthWhitelist)); 49 new HttpAuthFilterWhitelist(kTestAuthWhitelist));
48 ASSERT_TRUE(auth_filter); 50 ASSERT_TRUE(auth_filter);
49 // The URL security manager takes ownership of |auth_filter|. 51 // The URL security manager takes ownership of |auth_filter|.
50 scoped_ptr<URLSecurityManager> url_security_manager( 52 scoped_ptr<URLSecurityManager> url_security_manager(
51 URLSecurityManager::Create()); 53 URLSecurityManager::Create());
52 url_security_manager->SetDefaultWhitelist(auth_filter.Pass()); 54 url_security_manager->SetDefaultWhitelist(std::move(auth_filter));
53 ASSERT_TRUE(url_security_manager.get()); 55 ASSERT_TRUE(url_security_manager.get());
54 56
55 for (size_t i = 0; i < arraysize(kTestDataList); ++i) { 57 for (size_t i = 0; i < arraysize(kTestDataList); ++i) {
56 GURL gurl(kTestDataList[i].url); 58 GURL gurl(kTestDataList[i].url);
57 bool can_use_default = 59 bool can_use_default =
58 url_security_manager->CanUseDefaultCredentials(gurl); 60 url_security_manager->CanUseDefaultCredentials(gurl);
59 61
60 EXPECT_EQ(kTestDataList[i].succeeds_in_whitelist, can_use_default) 62 EXPECT_EQ(kTestDataList[i].succeeds_in_whitelist, can_use_default)
61 << " Run: " << i << " URL: '" << gurl << "'"; 63 << " Run: " << i << " URL: '" << gurl << "'";
62 } 64 }
63 } 65 }
64 66
65 TEST(URLSecurityManager, CanDelegate) { 67 TEST(URLSecurityManager, CanDelegate) {
66 scoped_ptr<HttpAuthFilter> auth_filter( 68 scoped_ptr<HttpAuthFilter> auth_filter(
67 new HttpAuthFilterWhitelist(kTestAuthWhitelist)); 69 new HttpAuthFilterWhitelist(kTestAuthWhitelist));
68 ASSERT_TRUE(auth_filter); 70 ASSERT_TRUE(auth_filter);
69 // The URL security manager takes ownership of |auth_filter|. 71 // The URL security manager takes ownership of |auth_filter|.
70 scoped_ptr<URLSecurityManager> url_security_manager( 72 scoped_ptr<URLSecurityManager> url_security_manager(
71 URLSecurityManager::Create()); 73 URLSecurityManager::Create());
72 url_security_manager->SetDelegateWhitelist(auth_filter.Pass()); 74 url_security_manager->SetDelegateWhitelist(std::move(auth_filter));
73 ASSERT_TRUE(url_security_manager.get()); 75 ASSERT_TRUE(url_security_manager.get());
74 76
75 for (size_t i = 0; i < arraysize(kTestDataList); ++i) { 77 for (size_t i = 0; i < arraysize(kTestDataList); ++i) {
76 GURL gurl(kTestDataList[i].url); 78 GURL gurl(kTestDataList[i].url);
77 bool can_delegate = url_security_manager->CanDelegate(gurl); 79 bool can_delegate = url_security_manager->CanDelegate(gurl);
78 EXPECT_EQ(kTestDataList[i].succeeds_in_whitelist, can_delegate) 80 EXPECT_EQ(kTestDataList[i].succeeds_in_whitelist, can_delegate)
79 << " Run: " << i << " URL: '" << gurl << "'"; 81 << " Run: " << i << " URL: '" << gurl << "'";
80 } 82 }
81 } 83 }
82 84
83 TEST(URLSecurityManager, CanDelegate_NoWhitelist) { 85 TEST(URLSecurityManager, CanDelegate_NoWhitelist) {
84 // Nothing can delegate in this case. 86 // Nothing can delegate in this case.
85 scoped_ptr<URLSecurityManager> url_security_manager( 87 scoped_ptr<URLSecurityManager> url_security_manager(
86 URLSecurityManager::Create()); 88 URLSecurityManager::Create());
87 ASSERT_TRUE(url_security_manager.get()); 89 ASSERT_TRUE(url_security_manager.get());
88 90
89 for (size_t i = 0; i < arraysize(kTestDataList); ++i) { 91 for (size_t i = 0; i < arraysize(kTestDataList); ++i) {
90 GURL gurl(kTestDataList[i].url); 92 GURL gurl(kTestDataList[i].url);
91 bool can_delegate = url_security_manager->CanDelegate(gurl); 93 bool can_delegate = url_security_manager->CanDelegate(gurl);
92 EXPECT_FALSE(can_delegate); 94 EXPECT_FALSE(can_delegate);
93 } 95 }
94 } 96 }
95 97
96 98
97 } // namespace net 99 } // namespace net
OLDNEW
« no previous file with comments | « net/http/url_security_manager.cc ('k') | net/log/net_log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698