| OLD | NEW |
| 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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "googleurl/src/gurl.h" | 8 #include "googleurl/src/gurl.h" |
| 9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
| 10 #include "net/http/http_auth_filter.h" | 10 #include "net/http/http_auth_filter.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 { "http://baz", true, true }, | 37 { "http://baz", true, true }, |
| 38 { "http://www.exampl.com", false, false }, | 38 { "http://www.exampl.com", false, false }, |
| 39 { "http://example.org", false, false }, | 39 { "http://example.org", false, false }, |
| 40 { "http://foobar.net", false, false }, | 40 { "http://foobar.net", false, false }, |
| 41 { "http://boo.fubar.com", false, false }, | 41 { "http://boo.fubar.com", false, false }, |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 } // namespace | 44 } // namespace |
| 45 | 45 |
| 46 TEST(URLSecurityManager, CreateWhitelist) { | 46 TEST(URLSecurityManager, CreateWhitelist) { |
| 47 HttpAuthFilterWhitelist* auth_filter = new HttpAuthFilterWhitelist(); | 47 HttpAuthFilterWhitelist* auth_filter = new HttpAuthFilterWhitelist( |
| 48 kTestAuthWhitelist); |
| 48 ASSERT_TRUE(auth_filter); | 49 ASSERT_TRUE(auth_filter); |
| 49 auth_filter->SetWhitelist(kTestAuthWhitelist); | |
| 50 // The URL security manager takes ownership of |auth_filter|. | 50 // The URL security manager takes ownership of |auth_filter|. |
| 51 scoped_ptr<URLSecurityManager> url_security_manager( | 51 scoped_ptr<URLSecurityManager> url_security_manager( |
| 52 URLSecurityManager::Create(auth_filter)); | 52 URLSecurityManager::Create(auth_filter, NULL)); |
| 53 ASSERT_TRUE(url_security_manager.get()); | 53 ASSERT_TRUE(url_security_manager.get()); |
| 54 | 54 |
| 55 for (size_t i = 0; i < arraysize(kTestDataList); ++i) { | 55 for (size_t i = 0; i < arraysize(kTestDataList); ++i) { |
| 56 GURL gurl(kTestDataList[i].url); | 56 GURL gurl(kTestDataList[i].url); |
| 57 bool can_use_default = | 57 bool can_use_default = |
| 58 url_security_manager->CanUseDefaultCredentials(gurl); | 58 url_security_manager->CanUseDefaultCredentials(gurl); |
| 59 | 59 |
| 60 EXPECT_EQ(kTestDataList[i].succeeds_in_whitelist, can_use_default) | 60 EXPECT_EQ(kTestDataList[i].succeeds_in_whitelist, can_use_default) |
| 61 << " Run: " << i << " URL: '" << gurl << "'"; | 61 << " Run: " << i << " URL: '" << gurl << "'"; |
| 62 } | 62 } |
| 63 } | 63 } |
| 64 | 64 |
| 65 } // namespace net | 65 } // namespace net |
| OLD | NEW |