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

Side by Side Diff: chrome/browser/chromeos/login/enrollment/enrollment_screen_browsertest.cc

Issue 2186623002: Minimal attestation-based enrollment flow. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed achuithb's feedback. Created 4 years, 3 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 (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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/macros.h" 6 #include "base/macros.h"
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "chrome/browser/chromeos/login/enrollment/enrollment_screen.h" 8 #include "chrome/browser/chromeos/login/enrollment/enrollment_screen.h"
9 #include "chrome/browser/chromeos/login/screens/mock_base_screen_delegate.h" 9 #include "chrome/browser/chromeos/login/screens/mock_base_screen_delegate.h"
10 #include "chrome/browser/chromeos/login/startup_utils.h" 10 #include "chrome/browser/chromeos/login/startup_utils.h"
(...skipping 15 matching lines...) Expand all
26 public: 26 public:
27 EnrollmentScreenTest() 27 EnrollmentScreenTest()
28 : WizardInProcessBrowserTest( 28 : WizardInProcessBrowserTest(
29 WizardController::kEnrollmentScreenName) {} 29 WizardController::kEnrollmentScreenName) {}
30 30
31 private: 31 private:
32 DISALLOW_COPY_AND_ASSIGN(EnrollmentScreenTest); 32 DISALLOW_COPY_AND_ASSIGN(EnrollmentScreenTest);
33 }; 33 };
34 34
35 IN_PROC_BROWSER_TEST_F(EnrollmentScreenTest, TestCancel) { 35 IN_PROC_BROWSER_TEST_F(EnrollmentScreenTest, TestCancel) {
36 ASSERT_TRUE(WizardController::default_controller() != NULL); 36 ASSERT_TRUE(WizardController::default_controller());
37 37
38 EnrollmentScreen* enrollment_screen = 38 EnrollmentScreen* enrollment_screen =
39 EnrollmentScreen::Get(WizardController::default_controller()); 39 EnrollmentScreen::Get(WizardController::default_controller());
40 ASSERT_TRUE(enrollment_screen != NULL); 40 ASSERT_TRUE(enrollment_screen);
41 41
42 base::RunLoop run_loop; 42 base::RunLoop run_loop;
43 MockBaseScreenDelegate mock_base_screen_delegate; 43 MockBaseScreenDelegate mock_base_screen_delegate;
44 static_cast<BaseScreen*>(enrollment_screen)->base_screen_delegate_ = 44 static_cast<BaseScreen*>(enrollment_screen)->base_screen_delegate_ =
45 &mock_base_screen_delegate; 45 &mock_base_screen_delegate;
46 46
47 ASSERT_EQ(WizardController::default_controller()->current_screen(), 47 ASSERT_EQ(WizardController::default_controller()->current_screen(),
48 enrollment_screen); 48 enrollment_screen);
49 49
50 EXPECT_CALL(mock_base_screen_delegate, 50 EXPECT_CALL(mock_base_screen_delegate,
51 OnExit(_, BaseScreenDelegate::ENTERPRISE_ENROLLMENT_COMPLETED, _)) 51 OnExit(_, BaseScreenDelegate::ENTERPRISE_ENROLLMENT_COMPLETED, _))
52 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); 52 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
53 enrollment_screen->OnCancel(); 53 enrollment_screen->OnCancel();
54 content::RunThisRunLoop(&run_loop); 54 content::RunThisRunLoop(&run_loop);
55 Mock::VerifyAndClearExpectations(&mock_base_screen_delegate); 55 Mock::VerifyAndClearExpectations(&mock_base_screen_delegate);
56 56
57 static_cast<BaseScreen*>(enrollment_screen)->base_screen_delegate_ = 57 static_cast<BaseScreen*>(enrollment_screen)->base_screen_delegate_ =
58 WizardController::default_controller(); 58 WizardController::default_controller();
59 } 59 }
60 60
61 // Flaky test: crbug.com/394069 61 // Flaky test: crbug.com/394069
62 IN_PROC_BROWSER_TEST_F(EnrollmentScreenTest, DISABLED_TestSuccess) { 62 IN_PROC_BROWSER_TEST_F(EnrollmentScreenTest, DISABLED_TestSuccess) {
63 ASSERT_TRUE(WizardController::default_controller() != NULL); 63 ASSERT_TRUE(WizardController::default_controller());
64 EXPECT_FALSE(StartupUtils::IsOobeCompleted()); 64 EXPECT_FALSE(StartupUtils::IsOobeCompleted());
65 65
66 EnrollmentScreen* enrollment_screen = 66 EnrollmentScreen* enrollment_screen =
67 EnrollmentScreen::Get(WizardController::default_controller()); 67 EnrollmentScreen::Get(WizardController::default_controller());
68 ASSERT_TRUE(enrollment_screen != NULL); 68 ASSERT_TRUE(enrollment_screen);
69 69
70 base::RunLoop run_loop; 70 base::RunLoop run_loop;
71 MockBaseScreenDelegate mock_base_screen_delegate; 71 MockBaseScreenDelegate mock_base_screen_delegate;
72 static_cast<BaseScreen*>(enrollment_screen)->base_screen_delegate_ = 72 static_cast<BaseScreen*>(enrollment_screen)->base_screen_delegate_ =
73 &mock_base_screen_delegate; 73 &mock_base_screen_delegate;
74 74
75 ASSERT_EQ(WizardController::default_controller()->current_screen(), 75 ASSERT_EQ(WizardController::default_controller()->current_screen(),
76 enrollment_screen); 76 enrollment_screen);
77 77
78 enrollment_screen->OnDeviceEnrolled(""); 78 enrollment_screen->OnDeviceEnrolled("");
79 run_loop.RunUntilIdle(); 79 run_loop.RunUntilIdle();
80 EXPECT_TRUE(StartupUtils::IsOobeCompleted()); 80 EXPECT_TRUE(StartupUtils::IsOobeCompleted());
81 81
82 static_cast<BaseScreen*>(enrollment_screen)->base_screen_delegate_ = 82 static_cast<BaseScreen*>(enrollment_screen)->base_screen_delegate_ =
83 WizardController::default_controller(); 83 WizardController::default_controller();
84 } 84 }
85 85
86 class AttestationAuthEnrollmentScreenTest : public EnrollmentScreenTest {
87 public:
88 AttestationAuthEnrollmentScreenTest() {}
89
90 private:
91 // Overridden from InProcessBrowserTest:
92 void SetUpCommandLine(base::CommandLine* command_line) override {
93 command_line->AppendSwitch(switches::kEnterpriseEnableZeroTouchEnrollment);
94 }
95
96 DISALLOW_COPY_AND_ASSIGN(AttestationAuthEnrollmentScreenTest);
97 };
98
99 IN_PROC_BROWSER_TEST_F(AttestationAuthEnrollmentScreenTest, TestCancel) {
100 ASSERT_TRUE(WizardController::default_controller());
101
102 EnrollmentScreen* enrollment_screen =
103 EnrollmentScreen::Get(WizardController::default_controller());
104 ASSERT_TRUE(enrollment_screen);
105
106 base::RunLoop run_loop;
107 MockBaseScreenDelegate mock_base_screen_delegate;
108 static_cast<BaseScreen*>(enrollment_screen)->base_screen_delegate_ =
109 &mock_base_screen_delegate;
110
111 ASSERT_EQ(WizardController::default_controller()->current_screen(),
112 enrollment_screen);
113
114 EXPECT_CALL(mock_base_screen_delegate,
115 OnExit(_, BaseScreenDelegate::ENTERPRISE_ENROLLMENT_COMPLETED, _))
116 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
117 ASSERT_FALSE(enrollment_screen->AdvanceToNextAuth());
118 enrollment_screen->OnCancel();
119 content::RunThisRunLoop(&run_loop);
120 Mock::VerifyAndClearExpectations(&mock_base_screen_delegate);
121
122 static_cast<BaseScreen*>(enrollment_screen)->base_screen_delegate_ =
123 WizardController::default_controller();
124 }
125
126 class ForcedAttestationAuthEnrollmentScreenTest : public EnrollmentScreenTest {
127 public:
128 ForcedAttestationAuthEnrollmentScreenTest() {}
129
130 private:
131 // Overridden from InProcessBrowserTest:
132 void SetUpCommandLine(base::CommandLine* command_line) override {
133 command_line->AppendSwitchASCII(
134 switches::kEnterpriseEnableZeroTouchEnrollment, "forced");
135 }
136
137 DISALLOW_COPY_AND_ASSIGN(ForcedAttestationAuthEnrollmentScreenTest);
138 };
139
140 IN_PROC_BROWSER_TEST_F(ForcedAttestationAuthEnrollmentScreenTest, TestCancel) {
141 ASSERT_TRUE(WizardController::default_controller());
142
143 EnrollmentScreen* enrollment_screen =
144 EnrollmentScreen::Get(WizardController::default_controller());
145 ASSERT_TRUE(enrollment_screen);
146
147 base::RunLoop run_loop;
148 MockBaseScreenDelegate mock_base_screen_delegate;
149 static_cast<BaseScreen*>(enrollment_screen)->base_screen_delegate_ =
150 &mock_base_screen_delegate;
151
152 ASSERT_EQ(WizardController::default_controller()->current_screen(),
153 enrollment_screen);
154
155 EXPECT_CALL(mock_base_screen_delegate,
156 OnExit(_, BaseScreenDelegate::ENTERPRISE_ENROLLMENT_BACK, _))
157 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
158 ASSERT_FALSE(enrollment_screen->AdvanceToNextAuth());
159 enrollment_screen->OnCancel();
160 content::RunThisRunLoop(&run_loop);
161 Mock::VerifyAndClearExpectations(&mock_base_screen_delegate);
162
163 static_cast<BaseScreen*>(enrollment_screen)->base_screen_delegate_ =
164 WizardController::default_controller();
165 }
166
167 class MultiAuthEnrollmentScreenTest : public EnrollmentScreenTest {
168 public:
169 MultiAuthEnrollmentScreenTest() {}
170
171 private:
172 // Overridden from InProcessBrowserTest:
173 void SetUpCommandLine(base::CommandLine* command_line) override {
174 command_line->AppendSwitch(switches::kEnterpriseEnableZeroTouchEnrollment);
175 // Kiosk mode will force OAuth enrollment.
176 base::FilePath test_data_dir;
177 ASSERT_TRUE(chromeos::test_utils::GetTestDataPath(
178 "app_mode", "kiosk_manifest", &test_data_dir));
179 command_line->AppendSwitchPath(
180 switches::kAppOemManifestFile,
181 test_data_dir.AppendASCII("kiosk_manifest.json"));
182 }
183
184 DISALLOW_COPY_AND_ASSIGN(MultiAuthEnrollmentScreenTest);
185 };
186
187 IN_PROC_BROWSER_TEST_F(MultiAuthEnrollmentScreenTest, TestCancel) {
188 ASSERT_TRUE(WizardController::default_controller());
189
190 EnrollmentScreen* enrollment_screen =
191 EnrollmentScreen::Get(WizardController::default_controller());
192 ASSERT_TRUE(enrollment_screen);
193
194 base::RunLoop run_loop;
195 MockBaseScreenDelegate mock_base_screen_delegate;
196 static_cast<BaseScreen*>(enrollment_screen)->base_screen_delegate_ =
197 &mock_base_screen_delegate;
198
199 ASSERT_EQ(WizardController::default_controller()->current_screen(),
200 enrollment_screen);
201
202 EXPECT_CALL(mock_base_screen_delegate,
203 OnExit(_, BaseScreenDelegate::ENTERPRISE_ENROLLMENT_BACK, _))
204 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
205 ASSERT_TRUE(enrollment_screen->AdvanceToNextAuth());
206 enrollment_screen->OnCancel();
207 content::RunThisRunLoop(&run_loop);
208 Mock::VerifyAndClearExpectations(&mock_base_screen_delegate);
209
210 static_cast<BaseScreen*>(enrollment_screen)->base_screen_delegate_ =
211 WizardController::default_controller();
212 }
213
86 class ProvisionedEnrollmentScreenTest : public EnrollmentScreenTest { 214 class ProvisionedEnrollmentScreenTest : public EnrollmentScreenTest {
87 public: 215 public:
88 ProvisionedEnrollmentScreenTest() {} 216 ProvisionedEnrollmentScreenTest() {}
89 217
90 private: 218 private:
91 // Overridden from InProcessBrowserTest: 219 // Overridden from InProcessBrowserTest:
92 void SetUpCommandLine(base::CommandLine* command_line) override { 220 void SetUpCommandLine(base::CommandLine* command_line) override {
93 base::FilePath test_data_dir; 221 base::FilePath test_data_dir;
94 ASSERT_TRUE(chromeos::test_utils::GetTestDataPath( 222 ASSERT_TRUE(chromeos::test_utils::GetTestDataPath(
95 "app_mode", "kiosk_manifest", &test_data_dir)); 223 "app_mode", "kiosk_manifest", &test_data_dir));
96 command_line->AppendSwitchPath( 224 command_line->AppendSwitchPath(
97 switches::kAppOemManifestFile, 225 switches::kAppOemManifestFile,
98 test_data_dir.AppendASCII("kiosk_manifest.json")); 226 test_data_dir.AppendASCII("kiosk_manifest.json"));
99 } 227 }
100 228
101 DISALLOW_COPY_AND_ASSIGN(ProvisionedEnrollmentScreenTest); 229 DISALLOW_COPY_AND_ASSIGN(ProvisionedEnrollmentScreenTest);
102 }; 230 };
103 231
104 IN_PROC_BROWSER_TEST_F(ProvisionedEnrollmentScreenTest, TestBackButton) { 232 IN_PROC_BROWSER_TEST_F(ProvisionedEnrollmentScreenTest, TestBackButton) {
105 ASSERT_TRUE(WizardController::default_controller() != NULL); 233 ASSERT_TRUE(WizardController::default_controller());
106 234
107 EnrollmentScreen* enrollment_screen = 235 EnrollmentScreen* enrollment_screen =
108 EnrollmentScreen::Get(WizardController::default_controller()); 236 EnrollmentScreen::Get(WizardController::default_controller());
109 ASSERT_TRUE(enrollment_screen != NULL); 237 ASSERT_TRUE(enrollment_screen);
110 238
111 base::RunLoop run_loop; 239 base::RunLoop run_loop;
112 MockBaseScreenDelegate mock_base_screen_delegate; 240 MockBaseScreenDelegate mock_base_screen_delegate;
113 static_cast<BaseScreen*>(enrollment_screen)->base_screen_delegate_ = 241 static_cast<BaseScreen*>(enrollment_screen)->base_screen_delegate_ =
114 &mock_base_screen_delegate; 242 &mock_base_screen_delegate;
115 243
116 ASSERT_EQ(WizardController::default_controller()->current_screen(), 244 ASSERT_EQ(WizardController::default_controller()->current_screen(),
117 enrollment_screen); 245 enrollment_screen);
118 246
119 EXPECT_CALL(mock_base_screen_delegate, 247 EXPECT_CALL(mock_base_screen_delegate,
120 OnExit(_, BaseScreenDelegate::ENTERPRISE_ENROLLMENT_BACK, _)) 248 OnExit(_, BaseScreenDelegate::ENTERPRISE_ENROLLMENT_BACK, _))
121 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); 249 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
122 enrollment_screen->OnCancel(); 250 enrollment_screen->OnCancel();
123 content::RunThisRunLoop(&run_loop); 251 content::RunThisRunLoop(&run_loop);
124 Mock::VerifyAndClearExpectations(&mock_base_screen_delegate); 252 Mock::VerifyAndClearExpectations(&mock_base_screen_delegate);
125 253
126 static_cast<BaseScreen*>(enrollment_screen)->base_screen_delegate_ = 254 static_cast<BaseScreen*>(enrollment_screen)->base_screen_delegate_ =
127 WizardController::default_controller(); 255 WizardController::default_controller();
128 } 256 }
129 257
130 } // namespace chromeos 258 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698