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

Side by Side Diff: chrome/browser/chromeos/settings/cros_settings_unittest.cc

Issue 148843002: Make an online wildcard login check for enterprise devices. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 6 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 <map> 5 #include <map>
6 #include <string> 6 #include <string>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 em::PolicyFetchResponse response; 81 em::PolicyFetchResponse response;
82 em::ChromeDeviceSettingsProto pol; 82 em::ChromeDeviceSettingsProto pol;
83 policy->set_policy_type(policy::dm_protocol::kChromeDevicePolicyType); 83 policy->set_policy_type(policy::dm_protocol::kChromeDevicePolicyType);
84 policy->set_username("me@owner"); 84 policy->set_username("me@owner");
85 policy->set_policy_value(pol.SerializeAsString()); 85 policy->set_policy_value(pol.SerializeAsString());
86 // Wipe the signed settings store. 86 // Wipe the signed settings store.
87 response.set_policy_data(policy->SerializeAsString()); 87 response.set_policy_data(policy->SerializeAsString());
88 response.set_policy_data_signature("false"); 88 response.set_policy_data_signature("false");
89 } 89 }
90 90
91 static bool IsWhitelisted(CrosSettings* cs, const std::string& username) {
92 return cs->FindEmailInList(kAccountsPrefUsers, username, NULL);
93 }
94
91 base::MessageLoopForUI message_loop_; 95 base::MessageLoopForUI message_loop_;
92 content::TestBrowserThread ui_thread_; 96 content::TestBrowserThread ui_thread_;
93 97
94 ScopedTestingLocalState local_state_; 98 ScopedTestingLocalState local_state_;
95 ScopedDeviceSettingsTestHelper device_settings_test_helper_; 99 ScopedDeviceSettingsTestHelper device_settings_test_helper_;
96 CrosSettings settings_; 100 CrosSettings settings_;
97 101
98 base::WeakPtrFactory<CrosSettingsTest> weak_factory_; 102 base::WeakPtrFactory<CrosSettingsTest> weak_factory_;
99 103
100 std::map<std::string, base::Value*> expected_props_; 104 std::map<std::string, base::Value*> expected_props_;
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 TEST_F(CrosSettingsTest, FindEmailInList) { 227 TEST_F(CrosSettingsTest, FindEmailInList) {
224 base::ListValue list; 228 base::ListValue list;
225 list.Append(new base::StringValue("user@example.com")); 229 list.Append(new base::StringValue("user@example.com"));
226 list.Append(new base::StringValue("nodomain")); 230 list.Append(new base::StringValue("nodomain"));
227 list.Append(new base::StringValue("with.dots@gmail.com")); 231 list.Append(new base::StringValue("with.dots@gmail.com"));
228 list.Append(new base::StringValue("Upper@example.com")); 232 list.Append(new base::StringValue("Upper@example.com"));
229 233
230 CrosSettings* cs = &settings_; 234 CrosSettings* cs = &settings_;
231 cs->Set(kAccountsPrefUsers, list); 235 cs->Set(kAccountsPrefUsers, list);
232 236
233 EXPECT_TRUE(cs->FindEmailInList(kAccountsPrefUsers, "user@example.com")); 237 EXPECT_TRUE(IsWhitelisted(cs, "user@example.com"));
234 EXPECT_FALSE(cs->FindEmailInList(kAccountsPrefUsers, "us.er@example.com")); 238 EXPECT_FALSE(IsWhitelisted(cs, "us.er@example.com"));
235 EXPECT_TRUE(cs->FindEmailInList(kAccountsPrefUsers, "USER@example.com")); 239 EXPECT_TRUE(IsWhitelisted(cs, "USER@example.com"));
236 EXPECT_FALSE(cs->FindEmailInList(kAccountsPrefUsers, "user")); 240 EXPECT_FALSE(IsWhitelisted(cs, "user"));
237 241
238 EXPECT_TRUE(cs->FindEmailInList(kAccountsPrefUsers, "nodomain")); 242 EXPECT_TRUE(IsWhitelisted(cs, "nodomain"));
239 EXPECT_TRUE(cs->FindEmailInList(kAccountsPrefUsers, "nodomain@gmail.com")); 243 EXPECT_TRUE(IsWhitelisted(cs, "nodomain@gmail.com"));
240 EXPECT_TRUE(cs->FindEmailInList(kAccountsPrefUsers, "no.domain@gmail.com")); 244 EXPECT_TRUE(IsWhitelisted(cs, "no.domain@gmail.com"));
241 EXPECT_TRUE(cs->FindEmailInList(kAccountsPrefUsers, "NO.DOMAIN")); 245 EXPECT_TRUE(IsWhitelisted(cs, "NO.DOMAIN"));
242 246
243 EXPECT_TRUE(cs->FindEmailInList(kAccountsPrefUsers, "with.dots@gmail.com")); 247 EXPECT_TRUE(IsWhitelisted(cs, "with.dots@gmail.com"));
244 EXPECT_TRUE(cs->FindEmailInList(kAccountsPrefUsers, "withdots@gmail.com")); 248 EXPECT_TRUE(IsWhitelisted(cs, "withdots@gmail.com"));
245 EXPECT_TRUE(cs->FindEmailInList(kAccountsPrefUsers, "WITH.DOTS@gmail.com")); 249 EXPECT_TRUE(IsWhitelisted(cs, "WITH.DOTS@gmail.com"));
246 EXPECT_TRUE(cs->FindEmailInList(kAccountsPrefUsers, "WITHDOTS")); 250 EXPECT_TRUE(IsWhitelisted(cs, "WITHDOTS"));
247 251
248 EXPECT_TRUE(cs->FindEmailInList(kAccountsPrefUsers, "Upper@example.com")); 252 EXPECT_TRUE(IsWhitelisted(cs, "Upper@example.com"));
249 EXPECT_FALSE(cs->FindEmailInList(kAccountsPrefUsers, "U.pper@example.com")); 253 EXPECT_FALSE(IsWhitelisted(cs, "U.pper@example.com"));
250 EXPECT_FALSE(cs->FindEmailInList(kAccountsPrefUsers, "Upper")); 254 EXPECT_FALSE(IsWhitelisted(cs, "Upper"));
251 EXPECT_TRUE(cs->FindEmailInList(kAccountsPrefUsers, "upper@example.com")); 255 EXPECT_TRUE(IsWhitelisted(cs, "upper@example.com"));
252 } 256 }
253 257
254 } // namespace chromeos 258 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698