Commit 5d908ca7 authored by Denis Kuznetsov's avatar Denis Kuznetsov Committed by Commit Bot

Add OOBE UI Zero touch end-to-end test.

Bug: 883985
Change-Id: If43f93fe27ce84fddc098aca8870b3cc729d7541
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1692168
Commit-Queue: Denis Kuznetsov <antrim@chromium.org>
Reviewed-by: default avatarRoman Sorokin [CET] <rsorokin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#675714}
parent 0f98fa81
...@@ -46,11 +46,6 @@ namespace chromeos { ...@@ -46,11 +46,6 @@ namespace chromeos {
namespace { namespace {
constexpr char kTestDomain[] = "test-domain.com";
constexpr char kTestRlzBrandCodeKey[] = "TEST";
constexpr char kTestSerialNumber[] = "111111";
constexpr char kTestHardwareClass[] = "hw";
std::string GetDmTokenFromPolicy(const std::string& blob) { std::string GetDmTokenFromPolicy(const std::string& blob) {
enterprise_management::PolicyFetchResponse policy; enterprise_management::PolicyFetchResponse policy;
CHECK(policy.ParseFromString(blob)); CHECK(policy.ParseFromString(blob));
...@@ -150,7 +145,7 @@ class AutoEnrollmentWithStatistics : public AutoEnrollmentLocalPolicyServer { ...@@ -150,7 +145,7 @@ class AutoEnrollmentWithStatistics : public AutoEnrollmentLocalPolicyServer {
// AutoEnrollmentController assumes that VPD is in valid state if // AutoEnrollmentController assumes that VPD is in valid state if
// "serial_number" or "Product_S/N" could be read from it. // "serial_number" or "Product_S/N" could be read from it.
fake_statistics_provider_.SetMachineStatistic( fake_statistics_provider_.SetMachineStatistic(
system::kSerialNumberKeyForTest, kTestSerialNumber); system::kSerialNumberKeyForTest, test::kTestSerialNumber);
} }
~AutoEnrollmentWithStatistics() override = default; ~AutoEnrollmentWithStatistics() override = default;
...@@ -195,12 +190,8 @@ class AutoEnrollmentNoStateKeys : public AutoEnrollmentWithStatistics { ...@@ -195,12 +190,8 @@ class AutoEnrollmentNoStateKeys : public AutoEnrollmentWithStatistics {
class InitialEnrollmentTest : public EnrollmentLocalPolicyServerBase { class InitialEnrollmentTest : public EnrollmentLocalPolicyServerBase {
public: public:
InitialEnrollmentTest() { InitialEnrollmentTest() {
fake_statistics_provider_.SetMachineStatistic(system::kRlzBrandCodeKey, policy_server_.ConfigureFakeStatisticsForZeroTouch(
kTestRlzBrandCodeKey); &fake_statistics_provider_);
fake_statistics_provider_.SetMachineStatistic(
system::kSerialNumberKeyForTest, kTestSerialNumber);
fake_statistics_provider_.SetMachineStatistic(system::kHardwareClassKey,
kTestHardwareClass);
} }
void SetUpCommandLine(base::CommandLine* command_line) override { void SetUpCommandLine(base::CommandLine* command_line) override {
...@@ -491,7 +482,7 @@ IN_PROC_BROWSER_TEST_F(AutoEnrollmentLocalPolicyServer, ReenrollmentNone) { ...@@ -491,7 +482,7 @@ IN_PROC_BROWSER_TEST_F(AutoEnrollmentLocalPolicyServer, ReenrollmentNone) {
EXPECT_TRUE(policy_server_.SetDeviceStateRetrievalResponse( EXPECT_TRUE(policy_server_.SetDeviceStateRetrievalResponse(
state_keys_broker(), state_keys_broker(),
enterprise_management::DeviceStateRetrievalResponse::RESTORE_MODE_NONE, enterprise_management::DeviceStateRetrievalResponse::RESTORE_MODE_NONE,
kTestDomain)); test::kTestDomain));
host()->StartWizard(AutoEnrollmentCheckScreenView::kScreenId); host()->StartWizard(AutoEnrollmentCheckScreenView::kScreenId);
OobeScreenWaiter(GaiaView::kScreenId).Wait(); OobeScreenWaiter(GaiaView::kScreenId).Wait();
} }
...@@ -502,7 +493,7 @@ IN_PROC_BROWSER_TEST_F(AutoEnrollmentLocalPolicyServer, ReenrollmentRequested) { ...@@ -502,7 +493,7 @@ IN_PROC_BROWSER_TEST_F(AutoEnrollmentLocalPolicyServer, ReenrollmentRequested) {
state_keys_broker(), state_keys_broker(),
enterprise_management::DeviceStateRetrievalResponse:: enterprise_management::DeviceStateRetrievalResponse::
RESTORE_MODE_REENROLLMENT_REQUESTED, RESTORE_MODE_REENROLLMENT_REQUESTED,
kTestDomain)); test::kTestDomain));
host()->StartWizard(AutoEnrollmentCheckScreenView::kScreenId); host()->StartWizard(AutoEnrollmentCheckScreenView::kScreenId);
OobeScreenWaiter(EnrollmentScreenView::kScreenId).Wait(); OobeScreenWaiter(EnrollmentScreenView::kScreenId).Wait();
enrollment_screen()->OnCancel(); enrollment_screen()->OnCancel();
...@@ -515,7 +506,7 @@ IN_PROC_BROWSER_TEST_F(AutoEnrollmentLocalPolicyServer, ReenrollmentForced) { ...@@ -515,7 +506,7 @@ IN_PROC_BROWSER_TEST_F(AutoEnrollmentLocalPolicyServer, ReenrollmentForced) {
state_keys_broker(), state_keys_broker(),
enterprise_management::DeviceStateRetrievalResponse:: enterprise_management::DeviceStateRetrievalResponse::
RESTORE_MODE_REENROLLMENT_ENFORCED, RESTORE_MODE_REENROLLMENT_ENFORCED,
kTestDomain)); test::kTestDomain));
host()->StartWizard(AutoEnrollmentCheckScreenView::kScreenId); host()->StartWizard(AutoEnrollmentCheckScreenView::kScreenId);
OobeScreenWaiter(EnrollmentScreenView::kScreenId).Wait(); OobeScreenWaiter(EnrollmentScreenView::kScreenId).Wait();
enrollment_ui_.SetExitHandler(); enrollment_ui_.SetExitHandler();
...@@ -529,7 +520,7 @@ IN_PROC_BROWSER_TEST_F(AutoEnrollmentLocalPolicyServer, DeviceDisabled) { ...@@ -529,7 +520,7 @@ IN_PROC_BROWSER_TEST_F(AutoEnrollmentLocalPolicyServer, DeviceDisabled) {
state_keys_broker(), state_keys_broker(),
enterprise_management::DeviceStateRetrievalResponse:: enterprise_management::DeviceStateRetrievalResponse::
RESTORE_MODE_DISABLED, RESTORE_MODE_DISABLED,
kTestDomain)); test::kTestDomain));
host()->StartWizard(AutoEnrollmentCheckScreenView::kScreenId); host()->StartWizard(AutoEnrollmentCheckScreenView::kScreenId);
OobeScreenWaiter(DeviceDisabledScreenView::kScreenId).Wait(); OobeScreenWaiter(DeviceDisabledScreenView::kScreenId).Wait();
} }
...@@ -541,7 +532,7 @@ IN_PROC_BROWSER_TEST_F(AutoEnrollmentLocalPolicyServer, Attestation) { ...@@ -541,7 +532,7 @@ IN_PROC_BROWSER_TEST_F(AutoEnrollmentLocalPolicyServer, Attestation) {
state_keys_broker(), state_keys_broker(),
enterprise_management::DeviceStateRetrievalResponse:: enterprise_management::DeviceStateRetrievalResponse::
RESTORE_MODE_REENROLLMENT_ZERO_TOUCH, RESTORE_MODE_REENROLLMENT_ZERO_TOUCH,
kTestDomain)); test::kTestDomain));
host()->StartWizard(AutoEnrollmentCheckScreenView::kScreenId); host()->StartWizard(AutoEnrollmentCheckScreenView::kScreenId);
enrollment_ui_.WaitForStep(test::ui::kEnrollmentStepSuccess); enrollment_ui_.WaitForStep(test::ui::kEnrollmentStepSuccess);
...@@ -576,7 +567,7 @@ IN_PROC_BROWSER_TEST_F(AutoEnrollmentWithStatistics, FREExplicitlyNotRequired) { ...@@ -576,7 +567,7 @@ IN_PROC_BROWSER_TEST_F(AutoEnrollmentWithStatistics, FREExplicitlyNotRequired) {
state_keys_broker(), state_keys_broker(),
enterprise_management::DeviceStateRetrievalResponse:: enterprise_management::DeviceStateRetrievalResponse::
RESTORE_MODE_REENROLLMENT_ENFORCED, RESTORE_MODE_REENROLLMENT_ENFORCED,
kTestDomain)); test::kTestDomain));
host()->StartWizard(AutoEnrollmentCheckScreenView::kScreenId); host()->StartWizard(AutoEnrollmentCheckScreenView::kScreenId);
OobeScreenWaiter(GaiaView::kScreenId).Wait(); OobeScreenWaiter(GaiaView::kScreenId).Wait();
...@@ -589,7 +580,7 @@ IN_PROC_BROWSER_TEST_F(AutoEnrollmentWithStatistics, MachineNotActivated) { ...@@ -589,7 +580,7 @@ IN_PROC_BROWSER_TEST_F(AutoEnrollmentWithStatistics, MachineNotActivated) {
state_keys_broker(), state_keys_broker(),
enterprise_management::DeviceStateRetrievalResponse:: enterprise_management::DeviceStateRetrievalResponse::
RESTORE_MODE_REENROLLMENT_ENFORCED, RESTORE_MODE_REENROLLMENT_ENFORCED,
kTestDomain)); test::kTestDomain));
host()->StartWizard(AutoEnrollmentCheckScreenView::kScreenId); host()->StartWizard(AutoEnrollmentCheckScreenView::kScreenId);
OobeScreenWaiter(GaiaView::kScreenId).Wait(); OobeScreenWaiter(GaiaView::kScreenId).Wait();
...@@ -603,7 +594,7 @@ IN_PROC_BROWSER_TEST_F(AutoEnrollmentWithStatistics, MachineActivated) { ...@@ -603,7 +594,7 @@ IN_PROC_BROWSER_TEST_F(AutoEnrollmentWithStatistics, MachineActivated) {
state_keys_broker(), state_keys_broker(),
enterprise_management::DeviceStateRetrievalResponse:: enterprise_management::DeviceStateRetrievalResponse::
RESTORE_MODE_REENROLLMENT_ENFORCED, RESTORE_MODE_REENROLLMENT_ENFORCED,
kTestDomain)); test::kTestDomain));
host()->StartWizard(AutoEnrollmentCheckScreenView::kScreenId); host()->StartWizard(AutoEnrollmentCheckScreenView::kScreenId);
OobeScreenWaiter(EnrollmentScreenView::kScreenId).Wait(); OobeScreenWaiter(EnrollmentScreenView::kScreenId).Wait();
...@@ -617,7 +608,7 @@ IN_PROC_BROWSER_TEST_F(AutoEnrollmentWithStatistics, CorruptedVPD) { ...@@ -617,7 +608,7 @@ IN_PROC_BROWSER_TEST_F(AutoEnrollmentWithStatistics, CorruptedVPD) {
state_keys_broker(), state_keys_broker(),
enterprise_management::DeviceStateRetrievalResponse:: enterprise_management::DeviceStateRetrievalResponse::
RESTORE_MODE_REENROLLMENT_ENFORCED, RESTORE_MODE_REENROLLMENT_ENFORCED,
kTestDomain)); test::kTestDomain));
host()->StartWizard(AutoEnrollmentCheckScreenView::kScreenId); host()->StartWizard(AutoEnrollmentCheckScreenView::kScreenId);
OobeScreenWaiter(EnrollmentScreenView::kScreenId).Wait(); OobeScreenWaiter(EnrollmentScreenView::kScreenId).Wait();
...@@ -687,8 +678,8 @@ IN_PROC_BROWSER_TEST_F(InitialEnrollmentTest, EnrollmentForced) { ...@@ -687,8 +678,8 @@ IN_PROC_BROWSER_TEST_F(InitialEnrollmentTest, EnrollmentForced) {
enterprise_management::DeviceInitialEnrollmentStateResponse:: enterprise_management::DeviceInitialEnrollmentStateResponse::
INITIAL_ENROLLMENT_MODE_ENROLLMENT_ENFORCED; INITIAL_ENROLLMENT_MODE_ENROLLMENT_ENFORCED;
policy_server_.SetDeviceInitialEnrollmentResponse( policy_server_.SetDeviceInitialEnrollmentResponse(
kTestRlzBrandCodeKey, kTestSerialNumber, initial_enrollment, kTestDomain, test::kTestRlzBrandCodeKey, test::kTestSerialNumber, initial_enrollment,
base::nullopt /* is_license_packaged_with_device */); test::kTestDomain, base::nullopt /* is_license_packaged_with_device */);
host()->StartWizard(AutoEnrollmentCheckScreenView::kScreenId); host()->StartWizard(AutoEnrollmentCheckScreenView::kScreenId);
OobeScreenWaiter(EnrollmentScreenView::kScreenId).Wait(); OobeScreenWaiter(EnrollmentScreenView::kScreenId).Wait();
...@@ -714,8 +705,8 @@ IN_PROC_BROWSER_TEST_F(InitialEnrollmentTest, ZeroTouchForcedAttestationFail) { ...@@ -714,8 +705,8 @@ IN_PROC_BROWSER_TEST_F(InitialEnrollmentTest, ZeroTouchForcedAttestationFail) {
enterprise_management::DeviceInitialEnrollmentStateResponse:: enterprise_management::DeviceInitialEnrollmentStateResponse::
INITIAL_ENROLLMENT_MODE_ZERO_TOUCH_ENFORCED; INITIAL_ENROLLMENT_MODE_ZERO_TOUCH_ENFORCED;
policy_server_.SetDeviceInitialEnrollmentResponse( policy_server_.SetDeviceInitialEnrollmentResponse(
kTestRlzBrandCodeKey, kTestSerialNumber, initial_enrollment, kTestDomain, test::kTestRlzBrandCodeKey, test::kTestSerialNumber, initial_enrollment,
base::nullopt /* is_license_packaged_with_device */); test::kTestDomain, base::nullopt /* is_license_packaged_with_device */);
host()->StartWizard(AutoEnrollmentCheckScreenView::kScreenId); host()->StartWizard(AutoEnrollmentCheckScreenView::kScreenId);
OobeScreenWaiter(EnrollmentScreenView::kScreenId).Wait(); OobeScreenWaiter(EnrollmentScreenView::kScreenId).Wait();
...@@ -746,13 +737,7 @@ IN_PROC_BROWSER_TEST_F(InitialEnrollmentTest, ZeroTouchForcedAttestationFail) { ...@@ -746,13 +737,7 @@ IN_PROC_BROWSER_TEST_F(InitialEnrollmentTest, ZeroTouchForcedAttestationFail) {
IN_PROC_BROWSER_TEST_F(InitialEnrollmentTest, IN_PROC_BROWSER_TEST_F(InitialEnrollmentTest,
ZeroTouchForcedAttestationSuccess) { ZeroTouchForcedAttestationSuccess) {
policy_server_.SetFakeAttestationFlow(); policy_server_.SetupZeroTouchForcedEnrollment();
auto initial_enrollment =
enterprise_management::DeviceInitialEnrollmentStateResponse::
INITIAL_ENROLLMENT_MODE_ZERO_TOUCH_ENFORCED;
policy_server_.SetDeviceInitialEnrollmentResponse(
kTestRlzBrandCodeKey, kTestSerialNumber, initial_enrollment, kTestDomain,
base::nullopt /* is_license_packaged_with_device */);
host()->StartWizard(AutoEnrollmentCheckScreenView::kScreenId); host()->StartWizard(AutoEnrollmentCheckScreenView::kScreenId);
enrollment_ui_.WaitForStep(test::ui::kEnrollmentStepSuccess); enrollment_ui_.WaitForStep(test::ui::kEnrollmentStepSuccess);
......
...@@ -18,8 +18,10 @@ ...@@ -18,8 +18,10 @@
#include "chrome/browser/chromeos/login/screens/recommend_apps/scoped_test_recommend_apps_fetcher_factory.h" #include "chrome/browser/chromeos/login/screens/recommend_apps/scoped_test_recommend_apps_fetcher_factory.h"
#include "chrome/browser/chromeos/login/test/device_state_mixin.h" #include "chrome/browser/chromeos/login/test/device_state_mixin.h"
#include "chrome/browser/chromeos/login/test/embedded_test_server_mixin.h" #include "chrome/browser/chromeos/login/test/embedded_test_server_mixin.h"
#include "chrome/browser/chromeos/login/test/enrollment_ui_mixin.h"
#include "chrome/browser/chromeos/login/test/fake_gaia_mixin.h" #include "chrome/browser/chromeos/login/test/fake_gaia_mixin.h"
#include "chrome/browser/chromeos/login/test/js_checker.h" #include "chrome/browser/chromeos/login/test/js_checker.h"
#include "chrome/browser/chromeos/login/test/local_policy_test_server_mixin.h"
#include "chrome/browser/chromeos/login/test/login_manager_mixin.h" #include "chrome/browser/chromeos/login/test/login_manager_mixin.h"
#include "chrome/browser/chromeos/login/test/oobe_base_test.h" #include "chrome/browser/chromeos/login/test/oobe_base_test.h"
#include "chrome/browser/chromeos/login/test/oobe_screen_exit_waiter.h" #include "chrome/browser/chromeos/login/test/oobe_screen_exit_waiter.h"
...@@ -38,6 +40,7 @@ ...@@ -38,6 +40,7 @@
#include "chrome/browser/ui/webui/chromeos/login/terms_of_service_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/terms_of_service_screen_handler.h"
#include "chromeos/constants/chromeos_switches.h" #include "chromeos/constants/chromeos_switches.h"
#include "chromeos/dbus/update_engine_client.h" #include "chromeos/dbus/update_engine_client.h"
#include "chromeos/system/fake_statistics_provider.h"
#include "components/arc/arc_service_manager.h" #include "components/arc/arc_service_manager.h"
#include "components/arc/arc_util.h" #include "components/arc/arc_util.h"
#include "components/arc/session/arc_session_runner.h" #include "components/arc/session/arc_session_runner.h"
...@@ -491,6 +494,11 @@ class OobeInteractiveUITest ...@@ -491,6 +494,11 @@ class OobeInteractiveUITest
LOG(INFO) << "OobeInteractiveUITest: LoginDisplayHost is down."; LOG(INFO) << "OobeInteractiveUITest: LoginDisplayHost is down.";
} }
void PerformStepsBeforeEnrollmentCheck();
void PerformSessionSignInSteps(
const ScopedQuickUnlockPrivateGetAuthTokenFunctionObserver&
get_auth_token_observer);
void SimpleEndToEnd(); void SimpleEndToEnd();
const OobeEndToEndTestSetupMixin* test_setup() const { return &setup_; } const OobeEndToEndTestSetupMixin* test_setup() const { return &setup_; }
...@@ -505,9 +513,7 @@ class OobeInteractiveUITest ...@@ -505,9 +513,7 @@ class OobeInteractiveUITest
DISALLOW_COPY_AND_ASSIGN(OobeInteractiveUITest); DISALLOW_COPY_AND_ASSIGN(OobeInteractiveUITest);
}; };
void OobeInteractiveUITest::SimpleEndToEnd() { void OobeInteractiveUITest::PerformStepsBeforeEnrollmentCheck() {
ScopedQuickUnlockPrivateGetAuthTokenFunctionObserver get_auth_token_observer;
test::WaitForWelcomeScreen(); test::WaitForWelcomeScreen();
RunWelcomeScreenChecks(); RunWelcomeScreenChecks();
test::TapWelcomeNext(); test::TapWelcomeNext();
...@@ -524,7 +530,11 @@ void OobeInteractiveUITest::SimpleEndToEnd() { ...@@ -524,7 +530,11 @@ void OobeInteractiveUITest::SimpleEndToEnd() {
test::WaitForUpdateScreen(); test::WaitForUpdateScreen();
test::ExitUpdateScreenNoUpdate(); test::ExitUpdateScreenNoUpdate();
}
void OobeInteractiveUITest::PerformSessionSignInSteps(
const ScopedQuickUnlockPrivateGetAuthTokenFunctionObserver&
get_auth_token_observer) {
WaitForGaiaSignInScreen(test_setup()->arc_state() != ArcState::kNotAvailable); WaitForGaiaSignInScreen(test_setup()->arc_state() != ArcState::kNotAvailable);
LogInAsRegularUser(); LogInAsRegularUser();
...@@ -561,6 +571,12 @@ void OobeInteractiveUITest::SimpleEndToEnd() { ...@@ -561,6 +571,12 @@ void OobeInteractiveUITest::SimpleEndToEnd() {
} }
HandleAssistantOptInScreen(); HandleAssistantOptInScreen();
}
void OobeInteractiveUITest::SimpleEndToEnd() {
ScopedQuickUnlockPrivateGetAuthTokenFunctionObserver get_auth_token_observer;
PerformStepsBeforeEnrollmentCheck();
PerformSessionSignInSteps(get_auth_token_observer);
WaitForLoginDisplayHostShutdown(); WaitForLoginDisplayHostShutdown();
} }
...@@ -578,6 +594,64 @@ INSTANTIATE_TEST_SUITE_P( ...@@ -578,6 +594,64 @@ INSTANTIATE_TEST_SUITE_P(
ArcState::kAcceptTerms, ArcState::kAcceptTerms,
ArcState::kDeclineTerms))); ArcState::kDeclineTerms)));
class OobeZeroTouchInteractiveUITest : public OobeInteractiveUITest {
public:
OobeZeroTouchInteractiveUITest() = default;
~OobeZeroTouchInteractiveUITest() override = default;
void SetUpOnMainThread() override {
OobeInteractiveUITest::SetUpOnMainThread();
policy_server_.ConfigureFakeStatisticsForZeroTouch(
&fake_statistics_provider_);
}
void SetUpCommandLine(base::CommandLine* command_line) override {
OobeInteractiveUITest::SetUpCommandLine(command_line);
command_line->AppendSwitchASCII(
switches::kEnterpriseEnableInitialEnrollment,
AutoEnrollmentController::kInitialEnrollmentAlways);
}
void ZeroTouchEndToEnd();
private:
LocalPolicyTestServerMixin policy_server_{&mixin_host_};
test::EnrollmentUIMixin enrollment_ui_{&mixin_host_};
system::ScopedFakeStatisticsProvider fake_statistics_provider_;
DISALLOW_COPY_AND_ASSIGN(OobeZeroTouchInteractiveUITest);
};
void OobeZeroTouchInteractiveUITest::ZeroTouchEndToEnd() {
policy_server_.SetupZeroTouchForcedEnrollment();
ScopedQuickUnlockPrivateGetAuthTokenFunctionObserver get_auth_token_observer;
PerformStepsBeforeEnrollmentCheck();
test::WaitForEnrollmentScreen();
enrollment_ui_.WaitForStep(test::ui::kEnrollmentStepSuccess);
enrollment_ui_.LeaveSuccessScreen();
PerformSessionSignInSteps(get_auth_token_observer);
WaitForLoginDisplayHostShutdown();
}
IN_PROC_BROWSER_TEST_P(OobeZeroTouchInteractiveUITest, EndToEnd) {
ZeroTouchEndToEnd();
}
INSTANTIATE_TEST_SUITE_P(
OobeZeroTouchInteractiveUITestImpl,
OobeZeroTouchInteractiveUITest,
testing::Combine(testing::Bool(),
testing::Bool(),
testing::Values(ArcState::kNotAvailable,
ArcState::kAcceptTerms,
ArcState::kDeclineTerms)));
class PublicSessionOobeTest class PublicSessionOobeTest
: public MixinBasedInProcessBrowserTest, : public MixinBasedInProcessBrowserTest,
public ::testing::WithParamInterface<std::tuple<bool, bool, ArcState>> { public ::testing::WithParamInterface<std::tuple<bool, bool, ArcState>> {
......
...@@ -55,6 +55,9 @@ std::string StepElementID(const std::string& step) { ...@@ -55,6 +55,9 @@ std::string StepElementID(const std::string& step) {
const std::initializer_list<base::StringPiece> kEnrollmentErrorButtonPath = { const std::initializer_list<base::StringPiece> kEnrollmentErrorButtonPath = {
kEnrollmentUI, "oauth-enroll-error-card", "submitButton"}; kEnrollmentUI, "oauth-enroll-error-card", "submitButton"};
const std::initializer_list<base::StringPiece> kEnrollmentSuccessButtonPath = {
kEnrollmentUI, "success-done-button"};
} // namespace } // namespace
EnrollmentUIMixin::EnrollmentUIMixin(InProcessBrowserTestMixinHost* host) EnrollmentUIMixin::EnrollmentUIMixin(InProcessBrowserTestMixinHost* host)
...@@ -116,6 +119,10 @@ void EnrollmentUIMixin::LeaveDeviceAttributeErrorScreen() { ...@@ -116,6 +119,10 @@ void EnrollmentUIMixin::LeaveDeviceAttributeErrorScreen() {
OobeJS().ClickOnPath(kEnrollmentErrorButtonPath); OobeJS().ClickOnPath(kEnrollmentErrorButtonPath);
} }
void EnrollmentUIMixin::LeaveSuccessScreen() {
OobeJS().ClickOnPath(kEnrollmentSuccessButtonPath);
}
void EnrollmentUIMixin::SubmitDeviceAttributes(const std::string& asset_id, void EnrollmentUIMixin::SubmitDeviceAttributes(const std::string& asset_id,
const std::string& location) { const std::string& location) {
OobeJS().TypeIntoPath(asset_id, {kEnrollmentUI, "oauth-enroll-asset-id"}); OobeJS().TypeIntoPath(asset_id, {kEnrollmentUI, "oauth-enroll-asset-id"});
......
...@@ -65,6 +65,8 @@ class EnrollmentUIMixin : public InProcessBrowserTestMixin { ...@@ -65,6 +65,8 @@ class EnrollmentUIMixin : public InProcessBrowserTestMixin {
void LeaveDeviceAttributeErrorScreen(); void LeaveDeviceAttributeErrorScreen();
void LeaveSuccessScreen();
// Selects enrollment license. // Selects enrollment license.
void SelectEnrollmentLicense(const std::string& license_type); void SelectEnrollmentLicense(const std::string& license_type);
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "chromeos/attestation/mock_attestation_flow.h" #include "chromeos/attestation/mock_attestation_flow.h"
#include "chromeos/cryptohome/async_method_caller.h" #include "chromeos/cryptohome/async_method_caller.h"
#include "chromeos/dbus/cryptohome/fake_cryptohome_client.h" #include "chromeos/dbus/cryptohome/fake_cryptohome_client.h"
#include "chromeos/system/fake_statistics_provider.h"
#include "components/policy/core/common/cloud/cloud_policy_constants.h" #include "components/policy/core/common/cloud/cloud_policy_constants.h"
#include "components/policy/core/common/cloud/policy_builder.h" #include "components/policy/core/common/cloud/policy_builder.h"
#include "components/policy/core/common/policy_switches.h" #include "components/policy/core/common/policy_switches.h"
...@@ -235,6 +236,27 @@ bool LocalPolicyTestServerMixin::SetDeviceInitialEnrollmentResponse( ...@@ -235,6 +236,27 @@ bool LocalPolicyTestServerMixin::SetDeviceInitialEnrollmentResponse(
return true; return true;
} }
void LocalPolicyTestServerMixin::SetupZeroTouchForcedEnrollment() {
SetFakeAttestationFlow();
auto initial_enrollment =
enterprise_management::DeviceInitialEnrollmentStateResponse::
INITIAL_ENROLLMENT_MODE_ZERO_TOUCH_ENFORCED;
SetUpdateDeviceAttributesPermission(false);
SetDeviceInitialEnrollmentResponse(
test::kTestRlzBrandCodeKey, test::kTestSerialNumber, initial_enrollment,
test::kTestDomain, base::nullopt /* is_license_packaged_with_device */);
}
void LocalPolicyTestServerMixin::ConfigureFakeStatisticsForZeroTouch(
system::ScopedFakeStatisticsProvider* provider) {
provider->SetMachineStatistic(system::kRlzBrandCodeKey,
test::kTestRlzBrandCodeKey);
provider->SetMachineStatistic(system::kSerialNumberKeyForTest,
test::kTestSerialNumber);
provider->SetMachineStatistic(system::kHardwareClassKey,
test::kTestHardwareClass);
}
LocalPolicyTestServerMixin::~LocalPolicyTestServerMixin() = default; LocalPolicyTestServerMixin::~LocalPolicyTestServerMixin() = default;
} // namespace chromeos } // namespace chromeos
...@@ -19,6 +19,20 @@ ...@@ -19,6 +19,20 @@
namespace chromeos { namespace chromeos {
namespace system {
class ScopedFakeStatisticsProvider;
} // namespace system
namespace test {
// Test constants used during enrollment wherever appropriate.
constexpr char kTestDomain[] = "test-domain.com";
constexpr char kTestRlzBrandCodeKey[] = "TEST";
constexpr char kTestSerialNumber[] = "111111";
constexpr char kTestHardwareClass[] = "hw";
} // namespace test
// This test mixin covers setting up LocalPolicyTestServer and adding a // This test mixin covers setting up LocalPolicyTestServer and adding a
// command-line flag to use it. Please see SetUp function for default settings. // command-line flag to use it. Please see SetUp function for default settings.
// Server is started after SetUp execution. // Server is started after SetUp execution.
...@@ -88,6 +102,16 @@ class LocalPolicyTestServerMixin : public InProcessBrowserTestMixin { ...@@ -88,6 +102,16 @@ class LocalPolicyTestServerMixin : public InProcessBrowserTestMixin {
const base::Optional<std::string>& management_domain, const base::Optional<std::string>& management_domain,
const base::Optional<bool> is_license_packaged_with_device); const base::Optional<bool> is_license_packaged_with_device);
// Utility function that configures server parameters for zero-touch
// enrollment. Should be used in conjunction with enabling zero-touch
// via command line and calling |ConfigureFakeStatisticsForZeroTouch|.
void SetupZeroTouchForcedEnrollment();
// Configures fake statistics provider with values that can be used with
// zero-touch enrollment.
void ConfigureFakeStatisticsForZeroTouch(
system::ScopedFakeStatisticsProvider* provider);
private: private:
std::unique_ptr<policy::LocalPolicyTestServer> policy_test_server_; std::unique_ptr<policy::LocalPolicyTestServer> policy_test_server_;
base::Value server_config_; base::Value server_config_;
......
...@@ -137,6 +137,10 @@ void SkipToEnrollmentOnRecovery() { ...@@ -137,6 +137,10 @@ void SkipToEnrollmentOnRecovery() {
WaitFor(EnrollmentScreenView::kScreenId); WaitFor(EnrollmentScreenView::kScreenId);
} }
void WaitForEnrollmentScreen() {
WaitFor(EnrollmentScreenView::kScreenId);
}
#if defined(GOOGLE_CHROME_BUILD) #if defined(GOOGLE_CHROME_BUILD)
void WaitForEulaScreen() { void WaitForEulaScreen() {
WaitFor(EulaView::kScreenId); WaitFor(EulaView::kScreenId);
......
...@@ -20,6 +20,7 @@ void ExitFingerprintPinSetupScreen(); ...@@ -20,6 +20,7 @@ void ExitFingerprintPinSetupScreen();
void WaitForDiscoverScreen(); void WaitForDiscoverScreen();
void ExitDiscoverPinSetupScreen(); void ExitDiscoverPinSetupScreen();
void SkipToEnrollmentOnRecovery(); void SkipToEnrollmentOnRecovery();
void WaitForEnrollmentScreen();
#if defined(GOOGLE_CHROME_BUILD) #if defined(GOOGLE_CHROME_BUILD)
void WaitForEulaScreen(); void WaitForEulaScreen();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment