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

Side by Side Diff: chrome/browser/chromeos/policy/blocking_login_browsertest.cc

Issue 1111593006: Revert of Revert "Enable BlockingLoginTest, ForceMaximizeOnFirstRunTest, UserCloudPolicyManagerTest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 *out = result; 71 *out = result;
72 loop->Quit(); 72 loop->Quit();
73 } 73 }
74 74
75 } // namespace 75 } // namespace
76 76
77 struct BlockingLoginTestParam { 77 struct BlockingLoginTestParam {
78 const int steps; 78 const int steps;
79 const char* username; 79 const char* username;
80 const bool enroll_device; 80 const bool enroll_device;
81 const bool use_webview;
81 }; 82 };
82 83
83 class BlockingLoginTest 84 class BlockingLoginTest
84 : public OobeBaseTest, 85 : public OobeBaseTest,
85 public content::NotificationObserver, 86 public content::NotificationObserver,
86 public testing::WithParamInterface<BlockingLoginTestParam> { 87 public testing::WithParamInterface<BlockingLoginTestParam> {
87 public: 88 public:
88 BlockingLoginTest() : profile_added_(NULL) { 89 BlockingLoginTest() : profile_added_(NULL) {
89 // TODO(nkostylev): Fix this test for webview. http://crbug.com/477402 90 set_use_webview(GetParam().use_webview);
90 set_use_webview(false);
91 } 91 }
92 92
93 void SetUpCommandLine(base::CommandLine* command_line) override { 93 void SetUpCommandLine(base::CommandLine* command_line) override {
94 OobeBaseTest::SetUpCommandLine(command_line); 94 OobeBaseTest::SetUpCommandLine(command_line);
95 95
96 command_line->AppendSwitchASCII(::switches::kAuthExtensionPath,
97 "gaia_auth");
98 command_line->AppendSwitchASCII( 96 command_line->AppendSwitchASCII(
99 policy::switches::kDeviceManagementUrl, 97 policy::switches::kDeviceManagementUrl,
100 embedded_test_server()->GetURL("/device_management").spec()); 98 embedded_test_server()->GetURL("/device_management").spec());
101 } 99 }
102 100
103 void SetUpOnMainThread() override { 101 void SetUpOnMainThread() override {
104 registrar_.Add(this, 102 registrar_.Add(this,
105 chrome::NOTIFICATION_PROFILE_ADDED, 103 chrome::NOTIFICATION_PROFILE_ADDED,
106 content::NotificationService::AllSources()); 104 content::NotificationService::AllSources());
107 105
(...skipping 17 matching lines...) Expand all
125 123
126 void RunUntilIdle() { 124 void RunUntilIdle() {
127 base::RunLoop().RunUntilIdle(); 125 base::RunLoop().RunUntilIdle();
128 } 126 }
129 127
130 policy::BrowserPolicyConnectorChromeOS* browser_policy_connector() { 128 policy::BrowserPolicyConnectorChromeOS* browser_policy_connector() {
131 return g_browser_process->platform_part() 129 return g_browser_process->platform_part()
132 ->browser_policy_connector_chromeos(); 130 ->browser_policy_connector_chromeos();
133 } 131 }
134 132
135 void SkipToSigninScreen() {
136 WizardController::SkipPostLoginScreensForTesting();
137 WizardController* wizard_controller =
138 WizardController::default_controller();
139 ASSERT_TRUE(wizard_controller);
140 wizard_controller->SkipToLoginForTesting(LoginScreenContext());
141
142 content::WindowedNotificationObserver(
143 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE,
144 content::NotificationService::AllSources()).Wait();
145 RunUntilIdle();
146 }
147
148 void EnrollDevice(const std::string& username) { 133 void EnrollDevice(const std::string& username) {
149 base::RunLoop loop; 134 base::RunLoop loop;
150 policy::EnterpriseInstallAttributes::LockResult result; 135 policy::EnterpriseInstallAttributes::LockResult result;
151 browser_policy_connector()->GetInstallAttributes()->LockDevice( 136 browser_policy_connector()->GetInstallAttributes()->LockDevice(
152 username, policy::DEVICE_MODE_ENTERPRISE, "100200300", 137 username, policy::DEVICE_MODE_ENTERPRISE, "100200300",
153 base::Bind(&CopyLockResult, &loop, &result)); 138 base::Bind(&CopyLockResult, &loop, &result));
154 loop.Run(); 139 loop.Run();
155 EXPECT_EQ(policy::EnterpriseInstallAttributes::LOCK_SUCCESS, result); 140 EXPECT_EQ(policy::EnterpriseInstallAttributes::LOCK_SUCCESS, result);
156 RunUntilIdle(); 141 RunUntilIdle();
157 } 142 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 EXPECT_EQ(kDomain, browser_policy_connector()->GetEnterpriseDomain()); 246 EXPECT_EQ(kDomain, browser_policy_connector()->GetEnterpriseDomain());
262 EXPECT_FALSE(profile_added_); 247 EXPECT_FALSE(profile_added_);
263 EXPECT_EQ(policy::USER_AFFILIATION_MANAGED, 248 EXPECT_EQ(policy::USER_AFFILIATION_MANAGED,
264 browser_policy_connector()->GetUserAffiliation(kUsername)); 249 browser_policy_connector()->GetUserAffiliation(kUsername));
265 RunUntilIdle(); 250 RunUntilIdle();
266 EXPECT_FALSE(user_manager->IsKnownUser(kUsername)); 251 EXPECT_FALSE(user_manager->IsKnownUser(kUsername));
267 } 252 }
268 253
269 // Skip the OOBE, go to the sign-in screen, and wait for the login screen to 254 // Skip the OOBE, go to the sign-in screen, and wait for the login screen to
270 // become visible. 255 // become visible.
271 SkipToSigninScreen(); 256 WaitForSigninScreen();
272 EXPECT_FALSE(profile_added_); 257 EXPECT_FALSE(profile_added_);
273 258
274 // Prepare the fake HTTP responses. 259 // Prepare the fake HTTP responses.
275 if (GetParam().steps < 5) { 260 if (GetParam().steps < 5) {
276 // If this instance is not going to complete the entire flow successfully 261 // If this instance is not going to complete the entire flow successfully
277 // then the last step will fail. 262 // then the last step will fail.
278 263
279 // This response body is important to make the gaia fetcher skip its delayed 264 // This response body is important to make the gaia fetcher skip its delayed
280 // retry behavior, which makes testing harder. If this is sent to the policy 265 // retry behavior, which makes testing harder. If this is sent to the policy
281 // fetchers then it will make them fail too. 266 // fetchers then it will make them fail too.
(...skipping 30 matching lines...) Expand all
312 // Login now. This verifies that logging in with the canned responses (which 297 // Login now. This verifies that logging in with the canned responses (which
313 // may include failures) won't be blocked due to the potential failures. 298 // may include failures) won't be blocked due to the potential failures.
314 EXPECT_FALSE(profile_added_); 299 EXPECT_FALSE(profile_added_);
315 Login(GetParam().username); 300 Login(GetParam().username);
316 EXPECT_TRUE(profile_added_); 301 EXPECT_TRUE(profile_added_);
317 ASSERT_TRUE(user_manager->IsUserLoggedIn()); 302 ASSERT_TRUE(user_manager->IsUserLoggedIn());
318 EXPECT_TRUE(user_manager->IsCurrentUserNew()); 303 EXPECT_TRUE(user_manager->IsCurrentUserNew());
319 } 304 }
320 305
321 const BlockingLoginTestParam kBlockinLoginTestCases[] = { 306 const BlockingLoginTestParam kBlockinLoginTestCases[] = {
322 { 0, kUsername, true }, 307 {0, kUsername, true, false},
323 { 1, kUsername, true }, 308 {1, kUsername, true, false},
324 { 2, kUsername, true }, 309 {2, kUsername, true, false},
325 { 3, kUsername, true }, 310 {3, kUsername, true, false},
326 { 4, kUsername, true }, 311 {4, kUsername, true, false},
327 { 5, kUsername, true }, 312 {5, kUsername, true, false},
328 { 0, kUsername, false }, 313 {0, kUsername, false, false},
329 { 1, kUsername, false }, 314 {1, kUsername, false, false},
330 { 2, kUsername, false }, 315 {2, kUsername, false, false},
331 { 3, kUsername, false }, 316 {3, kUsername, false, false},
332 { 4, kUsername, false }, 317 {4, kUsername, false, false},
333 { 5, kUsername, false }, 318 {5, kUsername, false, false},
334 { 0, kUsernameOtherDomain, true }, 319 {0, kUsernameOtherDomain, true, false},
335 { 1, kUsernameOtherDomain, true }, 320 {1, kUsernameOtherDomain, true, false},
336 { 2, kUsernameOtherDomain, true }, 321 {2, kUsernameOtherDomain, true, false},
337 { 3, kUsernameOtherDomain, true }, 322 {3, kUsernameOtherDomain, true, false},
338 { 4, kUsernameOtherDomain, true }, 323 {4, kUsernameOtherDomain, true, false},
339 { 5, kUsernameOtherDomain, true }, 324 {5, kUsernameOtherDomain, true, false},
325
326 {0, kUsername, true, true},
327 {1, kUsername, true, true},
328 {2, kUsername, true, true},
329 {3, kUsername, true, true},
330 {4, kUsername, true, true},
331 {5, kUsername, true, true},
332 {0, kUsername, false, true},
333 {1, kUsername, false, true},
334 {2, kUsername, false, true},
335 {3, kUsername, false, true},
336 {4, kUsername, false, true},
337 {5, kUsername, false, true},
338 {0, kUsernameOtherDomain, true, true},
339 {1, kUsernameOtherDomain, true, true},
340 {2, kUsernameOtherDomain, true, true},
341 {3, kUsernameOtherDomain, true, true},
342 {4, kUsernameOtherDomain, true, true},
343 {5, kUsernameOtherDomain, true, true},
340 }; 344 };
341 345
342 INSTANTIATE_TEST_CASE_P(BlockingLoginTestInstance, 346 INSTANTIATE_TEST_CASE_P(BlockingLoginTestInstance,
343 BlockingLoginTest, 347 BlockingLoginTest,
344 testing::ValuesIn(kBlockinLoginTestCases)); 348 testing::ValuesIn(kBlockinLoginTestCases));
345 349
346 } // namespace chromeos 350 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698