OLD | NEW |
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 Loading... |
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 // TODO(nkostylev): Fix this test for webview. http://crbug.com/477402 |
90 set_use_webview(false); | 91 set_use_webview(GetParam().use_webview); |
91 } | 92 } |
92 | 93 |
93 void SetUpCommandLine(base::CommandLine* command_line) override { | 94 void SetUpCommandLine(base::CommandLine* command_line) override { |
94 OobeBaseTest::SetUpCommandLine(command_line); | 95 OobeBaseTest::SetUpCommandLine(command_line); |
95 | 96 |
96 command_line->AppendSwitchASCII(::switches::kAuthExtensionPath, | |
97 "gaia_auth"); | |
98 command_line->AppendSwitchASCII( | 97 command_line->AppendSwitchASCII( |
99 policy::switches::kDeviceManagementUrl, | 98 policy::switches::kDeviceManagementUrl, |
100 embedded_test_server()->GetURL("/device_management").spec()); | 99 embedded_test_server()->GetURL("/device_management").spec()); |
101 } | 100 } |
102 | 101 |
103 void SetUpOnMainThread() override { | 102 void SetUpOnMainThread() override { |
104 registrar_.Add(this, | 103 registrar_.Add(this, |
105 chrome::NOTIFICATION_PROFILE_ADDED, | 104 chrome::NOTIFICATION_PROFILE_ADDED, |
106 content::NotificationService::AllSources()); | 105 content::NotificationService::AllSources()); |
107 | 106 |
(...skipping 17 matching lines...) Expand all Loading... |
125 | 124 |
126 void RunUntilIdle() { | 125 void RunUntilIdle() { |
127 base::RunLoop().RunUntilIdle(); | 126 base::RunLoop().RunUntilIdle(); |
128 } | 127 } |
129 | 128 |
130 policy::BrowserPolicyConnectorChromeOS* browser_policy_connector() { | 129 policy::BrowserPolicyConnectorChromeOS* browser_policy_connector() { |
131 return g_browser_process->platform_part() | 130 return g_browser_process->platform_part() |
132 ->browser_policy_connector_chromeos(); | 131 ->browser_policy_connector_chromeos(); |
133 } | 132 } |
134 | 133 |
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) { | 134 void EnrollDevice(const std::string& username) { |
149 base::RunLoop loop; | 135 base::RunLoop loop; |
150 policy::EnterpriseInstallAttributes::LockResult result; | 136 policy::EnterpriseInstallAttributes::LockResult result; |
151 browser_policy_connector()->GetInstallAttributes()->LockDevice( | 137 browser_policy_connector()->GetInstallAttributes()->LockDevice( |
152 username, policy::DEVICE_MODE_ENTERPRISE, "100200300", | 138 username, policy::DEVICE_MODE_ENTERPRISE, "100200300", |
153 base::Bind(&CopyLockResult, &loop, &result)); | 139 base::Bind(&CopyLockResult, &loop, &result)); |
154 loop.Run(); | 140 loop.Run(); |
155 EXPECT_EQ(policy::EnterpriseInstallAttributes::LOCK_SUCCESS, result); | 141 EXPECT_EQ(policy::EnterpriseInstallAttributes::LOCK_SUCCESS, result); |
156 RunUntilIdle(); | 142 RunUntilIdle(); |
157 } | 143 } |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 EXPECT_EQ(kDomain, browser_policy_connector()->GetEnterpriseDomain()); | 247 EXPECT_EQ(kDomain, browser_policy_connector()->GetEnterpriseDomain()); |
262 EXPECT_FALSE(profile_added_); | 248 EXPECT_FALSE(profile_added_); |
263 EXPECT_EQ(policy::USER_AFFILIATION_MANAGED, | 249 EXPECT_EQ(policy::USER_AFFILIATION_MANAGED, |
264 browser_policy_connector()->GetUserAffiliation(kUsername)); | 250 browser_policy_connector()->GetUserAffiliation(kUsername)); |
265 RunUntilIdle(); | 251 RunUntilIdle(); |
266 EXPECT_FALSE(user_manager->IsKnownUser(kUsername)); | 252 EXPECT_FALSE(user_manager->IsKnownUser(kUsername)); |
267 } | 253 } |
268 | 254 |
269 // Skip the OOBE, go to the sign-in screen, and wait for the login screen to | 255 // Skip the OOBE, go to the sign-in screen, and wait for the login screen to |
270 // become visible. | 256 // become visible. |
271 SkipToSigninScreen(); | 257 WaitForSigninScreen(); |
272 EXPECT_FALSE(profile_added_); | 258 EXPECT_FALSE(profile_added_); |
273 | 259 |
274 // Prepare the fake HTTP responses. | 260 // Prepare the fake HTTP responses. |
275 if (GetParam().steps < 5) { | 261 if (GetParam().steps < 5) { |
276 // If this instance is not going to complete the entire flow successfully | 262 // If this instance is not going to complete the entire flow successfully |
277 // then the last step will fail. | 263 // then the last step will fail. |
278 | 264 |
279 // This response body is important to make the gaia fetcher skip its delayed | 265 // 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 | 266 // retry behavior, which makes testing harder. If this is sent to the policy |
281 // fetchers then it will make them fail too. | 267 // fetchers then it will make them fail too. |
(...skipping 30 matching lines...) Expand all Loading... |
312 // Login now. This verifies that logging in with the canned responses (which | 298 // 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. | 299 // may include failures) won't be blocked due to the potential failures. |
314 EXPECT_FALSE(profile_added_); | 300 EXPECT_FALSE(profile_added_); |
315 Login(GetParam().username); | 301 Login(GetParam().username); |
316 EXPECT_TRUE(profile_added_); | 302 EXPECT_TRUE(profile_added_); |
317 ASSERT_TRUE(user_manager->IsUserLoggedIn()); | 303 ASSERT_TRUE(user_manager->IsUserLoggedIn()); |
318 EXPECT_TRUE(user_manager->IsCurrentUserNew()); | 304 EXPECT_TRUE(user_manager->IsCurrentUserNew()); |
319 } | 305 } |
320 | 306 |
321 const BlockingLoginTestParam kBlockinLoginTestCases[] = { | 307 const BlockingLoginTestParam kBlockinLoginTestCases[] = { |
322 { 0, kUsername, true }, | 308 {0, kUsername, true, false}, |
323 { 1, kUsername, true }, | 309 {1, kUsername, true, false}, |
324 { 2, kUsername, true }, | 310 {2, kUsername, true, false}, |
325 { 3, kUsername, true }, | 311 {3, kUsername, true, false}, |
326 { 4, kUsername, true }, | 312 {4, kUsername, true, false}, |
327 { 5, kUsername, true }, | 313 {5, kUsername, true, false}, |
328 { 0, kUsername, false }, | 314 {0, kUsername, false, false}, |
329 { 1, kUsername, false }, | 315 {1, kUsername, false, false}, |
330 { 2, kUsername, false }, | 316 {2, kUsername, false, false}, |
331 { 3, kUsername, false }, | 317 {3, kUsername, false, false}, |
332 { 4, kUsername, false }, | 318 {4, kUsername, false, false}, |
333 { 5, kUsername, false }, | 319 {5, kUsername, false, false}, |
334 { 0, kUsernameOtherDomain, true }, | 320 {0, kUsernameOtherDomain, true, false}, |
335 { 1, kUsernameOtherDomain, true }, | 321 {1, kUsernameOtherDomain, true, false}, |
336 { 2, kUsernameOtherDomain, true }, | 322 {2, kUsernameOtherDomain, true, false}, |
337 { 3, kUsernameOtherDomain, true }, | 323 {3, kUsernameOtherDomain, true, false}, |
338 { 4, kUsernameOtherDomain, true }, | 324 {4, kUsernameOtherDomain, true, false}, |
339 { 5, kUsernameOtherDomain, true }, | 325 {5, kUsernameOtherDomain, true, false}, |
| 326 |
| 327 {0, kUsername, true, true}, |
| 328 {1, kUsername, true, true}, |
| 329 {2, kUsername, true, true}, |
| 330 {3, kUsername, true, true}, |
| 331 {4, kUsername, true, true}, |
| 332 {5, kUsername, true, true}, |
| 333 {0, kUsername, false, true}, |
| 334 {1, kUsername, false, true}, |
| 335 {2, kUsername, false, true}, |
| 336 {3, kUsername, false, true}, |
| 337 {4, kUsername, false, true}, |
| 338 {5, kUsername, false, true}, |
| 339 {0, kUsernameOtherDomain, true, true}, |
| 340 {1, kUsernameOtherDomain, true, true}, |
| 341 {2, kUsernameOtherDomain, true, true}, |
| 342 {3, kUsernameOtherDomain, true, true}, |
| 343 {4, kUsernameOtherDomain, true, true}, |
| 344 {5, kUsernameOtherDomain, true, true}, |
340 }; | 345 }; |
341 | 346 |
342 INSTANTIATE_TEST_CASE_P(BlockingLoginTestInstance, | 347 INSTANTIATE_TEST_CASE_P(BlockingLoginTestInstance, |
343 BlockingLoginTest, | 348 BlockingLoginTest, |
344 testing::ValuesIn(kBlockinLoginTestCases)); | 349 testing::ValuesIn(kBlockinLoginTestCases)); |
345 | 350 |
346 } // namespace chromeos | 351 } // namespace chromeos |
OLD | NEW |