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

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

Issue 1414313002: Allow dynamic updating of authentication policies (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to cbentzel@'s comments. Created 5 years 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/http_auth_preferences.cc ('k') | net/http/http_auth_scheme.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "net/http/http_auth_preferences.h"
6
7 #include <string>
8 #include <vector>
9
10 #include "base/callback.h"
11 #include "base/prefs/pref_registry_simple.h"
12 #include "base/prefs/testing_pref_service.h"
13 #include "base/run_loop.h"
14 #include "base/single_thread_task_runner.h"
15 #include "base/threading/thread.h"
16 #include "testing/gtest/include/gtest/gtest.h"
17
18 namespace net {
19
20 TEST(HttpAuthPreferencesTest, AuthSchemes) {
21 const char* const expected_schemes[] = {"scheme1", "scheme2"};
22 std::vector<std::string> expected_schemes_vector(
23 expected_schemes, expected_schemes + arraysize(expected_schemes));
24 HttpAuthPreferences http_auth_preferences(expected_schemes_vector
25 #if defined(OS_POSIX) && !defined(OS_ANDROID)
26 ,
27 ""
28 #endif
29 );
30 EXPECT_TRUE(http_auth_preferences.IsSupportedScheme("scheme1"));
31 EXPECT_TRUE(http_auth_preferences.IsSupportedScheme("scheme2"));
32 EXPECT_FALSE(http_auth_preferences.IsSupportedScheme("scheme3"));
33 }
34
35 TEST(HttpAuthPreferencesTest, DisableCnameLookup) {
36 std::vector<std::string> auth_schemes;
37 HttpAuthPreferences http_auth_preferences(auth_schemes
38 #if defined(OS_POSIX) && !defined(OS_ANDROID)
39 ,
40 ""
41 #endif
42 );
43 EXPECT_FALSE(http_auth_preferences.NegotiateDisableCnameLookup());
44 http_auth_preferences.set_negotiate_disable_cname_lookup(true);
45 EXPECT_TRUE(http_auth_preferences.NegotiateDisableCnameLookup());
46 }
47
48 TEST(HttpAuthPreferencesTest, NegotiateEnablePort) {
49 std::vector<std::string> auth_schemes;
50 HttpAuthPreferences http_auth_preferences(auth_schemes
51 #if defined(OS_POSIX) && !defined(OS_ANDROID)
52 ,
53 ""
54 #endif
55 );
56 EXPECT_FALSE(http_auth_preferences.NegotiateEnablePort());
57 http_auth_preferences.set_negotiate_enable_port(true);
58 EXPECT_TRUE(http_auth_preferences.NegotiateEnablePort());
59 }
60
61 #if defined(OS_ANDROID)
62 TEST(HttpAuthPreferencesTest, AuthAndroidhNegotiateAccountType) {
63 std::vector<std::string> auth_schemes;
64 HttpAuthPreferences http_auth_preferences(auth_schemes
65 #if defined(OS_POSIX) && !defined(OS_ANDROID)
66 ,
67 ""
68 #endif
69 );
70 EXPECT_EQ(std::string(),
71 http_auth_preferences.AuthAndroidNegotiateAccountType());
72 http_auth_preferences.set_auth_android_negotiate_account_type("foo");
73 EXPECT_EQ(std::string("foo"),
74 http_auth_preferences.AuthAndroidNegotiateAccountType());
75 }
76 #endif
77
78 #if defined(OS_POSIX) && !defined(OS_ANDROID)
79 TEST(HttpAuthPreferencesTest, GssApiLibraryName) {
80 std::vector<std::string> AuthSchemes;
81 HttpAuthPreferences http_auth_preferences(AuthSchemes, "bar");
82 EXPECT_EQ(std::string("bar"), http_auth_preferences.GssapiLibraryName());
83 }
84 #endif
85
86 TEST(HttpAuthPreferencesTest, AuthServerWhitelist) {
87 std::vector<std::string> auth_schemes;
88 HttpAuthPreferences http_auth_preferences(auth_schemes
89 #if defined(OS_POSIX) && !defined(OS_ANDROID)
90 ,
91 ""
92 #endif
93 );
94 // Check initial value
95 EXPECT_FALSE(http_auth_preferences.CanUseDefaultCredentials(GURL("abc")));
96 http_auth_preferences.set_server_whitelist("*");
97 EXPECT_TRUE(http_auth_preferences.CanUseDefaultCredentials(GURL("abc")));
98 }
99
100 TEST(HttpAuthPreferencesTest, AuthDelegateWhitelist) {
101 std::vector<std::string> auth_schemes;
102 HttpAuthPreferences http_auth_preferences(auth_schemes
103 #if defined(OS_POSIX) && !defined(OS_ANDROID)
104 ,
105 ""
106 #endif
107 );
108 // Check initial value
109 EXPECT_FALSE(http_auth_preferences.CanDelegate(GURL("abc")));
110 http_auth_preferences.set_delegate_whitelist("*");
111 EXPECT_TRUE(http_auth_preferences.CanDelegate(GURL("abc")));
112 }
113
114 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_auth_preferences.cc ('k') | net/http/http_auth_scheme.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698