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

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: Made ZTE independent of enterprise enrollment. 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 MultiAuthEnrollmentScreenTest : public EnrollmentScreenTest {
87 public:
88 MultiAuthEnrollmentScreenTest() {}
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(MultiAuthEnrollmentScreenTest);
97 };
98
99 IN_PROC_BROWSER_TEST_F(MultiAuthEnrollmentScreenTest, TestCancel) {
100 ASSERT_TRUE(WizardController::default_controller() != NULL);
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_EQ(EnrollmentScreen::AUTH_OAUTH, enrollment_screen->last_auth_);
118 ASSERT_EQ(EnrollmentScreen::AUTH_ATTESTATION,
119 enrollment_screen->current_auth_);
120 ASSERT_TRUE(enrollment_screen->AdvanceToNextAuth());
121 ASSERT_EQ(EnrollmentScreen::AUTH_OAUTH, enrollment_screen->current_auth_);
122 enrollment_screen->OnCancel();
123 content::RunThisRunLoop(&run_loop);
124 Mock::VerifyAndClearExpectations(&mock_base_screen_delegate);
125
126 static_cast<BaseScreen*>(enrollment_screen)->base_screen_delegate_ =
127 WizardController::default_controller();
128 }
129
130 class AttestationAuthEnrollmentScreenTest : public EnrollmentScreenTest {
131 public:
132 AttestationAuthEnrollmentScreenTest() {}
133
134 private:
135 // Overridden from InProcessBrowserTest:
136 void SetUpCommandLine(base::CommandLine* command_line) override {
137 command_line->AppendSwitchASCII(
138 switches::kEnterpriseEnableZeroTouchEnrollment, "forced");
139 }
140
141 DISALLOW_COPY_AND_ASSIGN(AttestationAuthEnrollmentScreenTest);
142 };
143
144 IN_PROC_BROWSER_TEST_F(AttestationAuthEnrollmentScreenTest, TestCancel) {
145 ASSERT_TRUE(WizardController::default_controller() != NULL);
146
147 EnrollmentScreen* enrollment_screen =
148 EnrollmentScreen::Get(WizardController::default_controller());
149 ASSERT_TRUE(enrollment_screen != NULL);
150
151 base::RunLoop run_loop;
152 MockBaseScreenDelegate mock_base_screen_delegate;
153 static_cast<BaseScreen*>(enrollment_screen)->base_screen_delegate_ =
154 &mock_base_screen_delegate;
155
156 ASSERT_EQ(WizardController::default_controller()->current_screen(),
157 enrollment_screen);
158
159 EXPECT_CALL(mock_base_screen_delegate,
160 OnExit(_, BaseScreenDelegate::ENTERPRISE_ENROLLMENT_BACK, _))
161 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
162 ASSERT_EQ(EnrollmentScreen::AUTH_ATTESTATION, enrollment_screen->last_auth_);
163 ASSERT_EQ(EnrollmentScreen::AUTH_ATTESTATION,
164 enrollment_screen->current_auth_);
165 enrollment_screen->OnCancel();
166 ASSERT_EQ(EnrollmentScreen::AUTH_ATTESTATION,
167 enrollment_screen->current_auth_);
168 content::RunThisRunLoop(&run_loop);
169 Mock::VerifyAndClearExpectations(&mock_base_screen_delegate);
170
171 static_cast<BaseScreen*>(enrollment_screen)->base_screen_delegate_ =
172 WizardController::default_controller();
173 }
174
86 class ProvisionedEnrollmentScreenTest : public EnrollmentScreenTest { 175 class ProvisionedEnrollmentScreenTest : public EnrollmentScreenTest {
87 public: 176 public:
88 ProvisionedEnrollmentScreenTest() {} 177 ProvisionedEnrollmentScreenTest() {}
89 178
90 private: 179 private:
91 // Overridden from InProcessBrowserTest: 180 // Overridden from InProcessBrowserTest:
92 void SetUpCommandLine(base::CommandLine* command_line) override { 181 void SetUpCommandLine(base::CommandLine* command_line) override {
93 base::FilePath test_data_dir; 182 base::FilePath test_data_dir;
94 ASSERT_TRUE(chromeos::test_utils::GetTestDataPath( 183 ASSERT_TRUE(chromeos::test_utils::GetTestDataPath(
95 "app_mode", "kiosk_manifest", &test_data_dir)); 184 "app_mode", "kiosk_manifest", &test_data_dir));
(...skipping 25 matching lines...) Expand all
121 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); 210 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
122 enrollment_screen->OnCancel(); 211 enrollment_screen->OnCancel();
123 content::RunThisRunLoop(&run_loop); 212 content::RunThisRunLoop(&run_loop);
124 Mock::VerifyAndClearExpectations(&mock_base_screen_delegate); 213 Mock::VerifyAndClearExpectations(&mock_base_screen_delegate);
125 214
126 static_cast<BaseScreen*>(enrollment_screen)->base_screen_delegate_ = 215 static_cast<BaseScreen*>(enrollment_screen)->base_screen_delegate_ =
127 WizardController::default_controller(); 216 WizardController::default_controller();
128 } 217 }
129 218
130 } // namespace chromeos 219 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698