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

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: Rebased after 2265163002 so we can pass presubmit. Created 4 years, 4 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
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() != NULL);
achuithb 2016/08/23 18:16:44 either nullptr, or drop the comparison. Here and b
The one and only Dr. Crash 2016/08/23 21:24:18 Done.
101
102 EnrollmentScreen* enrollment_screen =
103 EnrollmentScreen::Get(WizardController::default_controller());
104 ASSERT_TRUE(enrollment_screen != NULL);
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() != NULL);
142
143 EnrollmentScreen* enrollment_screen =
144 EnrollmentScreen::Get(WizardController::default_controller());
145 ASSERT_TRUE(enrollment_screen != NULL);
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() != NULL);
189
190 EnrollmentScreen* enrollment_screen =
191 EnrollmentScreen::Get(WizardController::default_controller());
192 ASSERT_TRUE(enrollment_screen != NULL);
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));
(...skipping 25 matching lines...) Expand all
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