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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_auth_preferences_unittest.cc
diff --git a/net/http/http_auth_preferences_unittest.cc b/net/http/http_auth_preferences_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..479b0d52b6d92baf9fecdc3060a96a7ffc8491ee
--- /dev/null
+++ b/net/http/http_auth_preferences_unittest.cc
@@ -0,0 +1,114 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/http/http_auth_preferences.h"
+
+#include <string>
+#include <vector>
+
+#include "base/callback.h"
+#include "base/prefs/pref_registry_simple.h"
+#include "base/prefs/testing_pref_service.h"
+#include "base/run_loop.h"
+#include "base/single_thread_task_runner.h"
+#include "base/threading/thread.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace net {
+
+TEST(HttpAuthPreferencesTest, AuthSchemes) {
+ const char* const expected_schemes[] = {"scheme1", "scheme2"};
+ std::vector<std::string> expected_schemes_vector(
+ expected_schemes, expected_schemes + arraysize(expected_schemes));
+ HttpAuthPreferences http_auth_preferences(expected_schemes_vector
+#if defined(OS_POSIX) && !defined(OS_ANDROID)
+ ,
+ ""
+#endif
+ );
+ EXPECT_TRUE(http_auth_preferences.IsSupportedScheme("scheme1"));
+ EXPECT_TRUE(http_auth_preferences.IsSupportedScheme("scheme2"));
+ EXPECT_FALSE(http_auth_preferences.IsSupportedScheme("scheme3"));
+}
+
+TEST(HttpAuthPreferencesTest, DisableCnameLookup) {
+ std::vector<std::string> auth_schemes;
+ HttpAuthPreferences http_auth_preferences(auth_schemes
+#if defined(OS_POSIX) && !defined(OS_ANDROID)
+ ,
+ ""
+#endif
+ );
+ EXPECT_FALSE(http_auth_preferences.NegotiateDisableCnameLookup());
+ http_auth_preferences.set_negotiate_disable_cname_lookup(true);
+ EXPECT_TRUE(http_auth_preferences.NegotiateDisableCnameLookup());
+}
+
+TEST(HttpAuthPreferencesTest, NegotiateEnablePort) {
+ std::vector<std::string> auth_schemes;
+ HttpAuthPreferences http_auth_preferences(auth_schemes
+#if defined(OS_POSIX) && !defined(OS_ANDROID)
+ ,
+ ""
+#endif
+ );
+ EXPECT_FALSE(http_auth_preferences.NegotiateEnablePort());
+ http_auth_preferences.set_negotiate_enable_port(true);
+ EXPECT_TRUE(http_auth_preferences.NegotiateEnablePort());
+}
+
+#if defined(OS_ANDROID)
+TEST(HttpAuthPreferencesTest, AuthAndroidhNegotiateAccountType) {
+ std::vector<std::string> auth_schemes;
+ HttpAuthPreferences http_auth_preferences(auth_schemes
+#if defined(OS_POSIX) && !defined(OS_ANDROID)
+ ,
+ ""
+#endif
+ );
+ EXPECT_EQ(std::string(),
+ http_auth_preferences.AuthAndroidNegotiateAccountType());
+ http_auth_preferences.set_auth_android_negotiate_account_type("foo");
+ EXPECT_EQ(std::string("foo"),
+ http_auth_preferences.AuthAndroidNegotiateAccountType());
+}
+#endif
+
+#if defined(OS_POSIX) && !defined(OS_ANDROID)
+TEST(HttpAuthPreferencesTest, GssApiLibraryName) {
+ std::vector<std::string> AuthSchemes;
+ HttpAuthPreferences http_auth_preferences(AuthSchemes, "bar");
+ EXPECT_EQ(std::string("bar"), http_auth_preferences.GssapiLibraryName());
+}
+#endif
+
+TEST(HttpAuthPreferencesTest, AuthServerWhitelist) {
+ std::vector<std::string> auth_schemes;
+ HttpAuthPreferences http_auth_preferences(auth_schemes
+#if defined(OS_POSIX) && !defined(OS_ANDROID)
+ ,
+ ""
+#endif
+ );
+ // Check initial value
+ EXPECT_FALSE(http_auth_preferences.CanUseDefaultCredentials(GURL("abc")));
+ http_auth_preferences.set_server_whitelist("*");
+ EXPECT_TRUE(http_auth_preferences.CanUseDefaultCredentials(GURL("abc")));
+}
+
+TEST(HttpAuthPreferencesTest, AuthDelegateWhitelist) {
+ std::vector<std::string> auth_schemes;
+ HttpAuthPreferences http_auth_preferences(auth_schemes
+#if defined(OS_POSIX) && !defined(OS_ANDROID)
+ ,
+ ""
+#endif
+ );
+ // Check initial value
+ EXPECT_FALSE(http_auth_preferences.CanDelegate(GURL("abc")));
+ http_auth_preferences.set_delegate_whitelist("*");
+ EXPECT_TRUE(http_auth_preferences.CanDelegate(GURL("abc")));
+}
+
+} // namespace net
« 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