Commit 43c7ee45 authored by Josh Nohle's avatar Josh Nohle Committed by Commit Bot

Cros MultiDevice] Re-enroll device if SoftwareFeature supported state changes.

Create a class, DeviceReenroller, that compares GcmDeviceInfo's list of
supported SoftwareFeatures--eg., BETTER_TOGETHER_CLIENT or
MAGIC_TETHER_CLIENT--with those stored in the local device metadata on the
CryptAuth server. If a SoftwareFeature state has changed from supported to
unsupported, or vice versa, then re-enroll the device with CryptAuth. Finally,
after a successful re-enrollment, re-sync with CryptAuth and verify that the
local device metadata was updated correctly.

The flow is as follows:

1) The supported states of CrOS-relevant SoftwareFeatures are set in
//src/chrome/browser/chromeos/cryptauth/gcm_device_info_provider_impl.cc, based
on FeatureList flags.

2) This information is stored in GcmDeviceInfo, which is passed along to the
MultiDeviceSetupService via a ctor argument.

3) On creation, MultiDeviceSetupImpl creates a DeviceReenroller, providing it
   - a DeviceSyncClient, for communicating with CryptAuth to retrieve local
     device metadata, to re-enroll the device, and to sync the device;
   - and access to GcmDeviceInfo, in order to retrieve the latest list of
     supported SoftwareFeatures.

4) In the DeviceReenroller constructor, the supported software features from
the local device metadata are compared with the latest supported-state given
by GcmDeviceInfo's supported_software_features list.

5) If any supported-state changed, a re-enrollment is attempted via the
DeviceSyncClient.

6) If the re-enrollment is successful, a device sync is attempted via the
  DeviceSyncClient.
  - If the re-enrollment is unsuccessful, another attempt is scheduled to
    run after 5 minutes.

7) If the device sync is unsuccessful, another attempt is scheduled to
    run after 5 minutes.

Note that DeviceReenroller logic only runs when the MultiDeviceSetupService is
created, except for possibly retrying failed enrollments or syncs after some
delay. It does NOT act as an observer, checking for changes to GcmDeviceInfo's
supported features list, because we only expect this to change when Chrome
flags change, i.e., when the Chrome binary restarts.

Bug: 870770
Change-Id: I5f26a68448f3ee0e5dd8759aac12d05d1e4760a6
Reviewed-on: https://chromium-review.googlesource.com/1182419Reviewed-by: default avatarRyan Hansberry <hansberry@chromium.org>
Reviewed-by: default avatarRyan Hamilton <rch@chromium.org>
Reviewed-by: default avatarJeremy Klein <jlklein@chromium.org>
Commit-Queue: Josh Nohle <nohle@chromium.org>
Cr-Commit-Position: refs/heads/master@{#589387}
parent 25c6a34f
...@@ -1533,7 +1533,8 @@ ProfileImpl::CreateMultiDeviceSetupService() { ...@@ -1533,7 +1533,8 @@ ProfileImpl::CreateMultiDeviceSetupService() {
chromeos::multidevice_setup::AuthTokenValidatorFactory::GetForProfile( chromeos::multidevice_setup::AuthTokenValidatorFactory::GetForProfile(
this), this),
std::make_unique< std::make_unique<
chromeos::multidevice_setup::AndroidSmsAppHelperDelegateImpl>(this)); chromeos::multidevice_setup::AndroidSmsAppHelperDelegateImpl>(this),
chromeos::GcmDeviceInfoProviderImpl::GetInstance());
} }
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
...@@ -17,12 +17,12 @@ FakeDeviceSyncClient::~FakeDeviceSyncClient() = default; ...@@ -17,12 +17,12 @@ FakeDeviceSyncClient::~FakeDeviceSyncClient() = default;
void FakeDeviceSyncClient::ForceEnrollmentNow( void FakeDeviceSyncClient::ForceEnrollmentNow(
mojom::DeviceSync::ForceEnrollmentNowCallback callback) { mojom::DeviceSync::ForceEnrollmentNowCallback callback) {
std::move(callback).Run(force_enrollment_now_success_); force_enrollment_now_callback_queue_.push(std::move(callback));
} }
void FakeDeviceSyncClient::ForceSyncNow( void FakeDeviceSyncClient::ForceSyncNow(
mojom::DeviceSync::ForceSyncNowCallback callback) { mojom::DeviceSync::ForceSyncNowCallback callback) {
std::move(callback).Run(force_sync_now_success_); force_sync_now_callback_queue_.push(std::move(callback));
} }
cryptauth::RemoteDeviceRefList FakeDeviceSyncClient::GetSyncedDevices() { cryptauth::RemoteDeviceRefList FakeDeviceSyncClient::GetSyncedDevices() {
...@@ -54,6 +54,27 @@ void FakeDeviceSyncClient::GetDebugInfo( ...@@ -54,6 +54,27 @@ void FakeDeviceSyncClient::GetDebugInfo(
get_debug_info_callback_queue_.push(std::move(callback)); get_debug_info_callback_queue_.push(std::move(callback));
} }
int FakeDeviceSyncClient::GetForceEnrollmentNowCallbackQueueSize() {
return force_enrollment_now_callback_queue_.size();
}
int FakeDeviceSyncClient::GetForceSyncNowCallbackQueueSize() {
return force_sync_now_callback_queue_.size();
}
void FakeDeviceSyncClient::InvokePendingForceEnrollmentNowCallback(
bool success) {
DCHECK(force_enrollment_now_callback_queue_.size() > 0);
std::move(force_enrollment_now_callback_queue_.front()).Run(success);
force_enrollment_now_callback_queue_.pop();
}
void FakeDeviceSyncClient::InvokePendingForceSyncNowCallback(bool success) {
DCHECK(force_sync_now_callback_queue_.size() > 0);
std::move(force_sync_now_callback_queue_.front()).Run(success);
force_sync_now_callback_queue_.pop();
}
void FakeDeviceSyncClient::InvokePendingSetSoftwareFeatureStateCallback( void FakeDeviceSyncClient::InvokePendingSetSoftwareFeatureStateCallback(
mojom::NetworkRequestResult result_code) { mojom::NetworkRequestResult result_code) {
std::move(set_software_feature_state_callback_queue_.front()) std::move(set_software_feature_state_callback_queue_.front())
......
...@@ -27,6 +27,10 @@ class FakeDeviceSyncClient : public DeviceSyncClient { ...@@ -27,6 +27,10 @@ class FakeDeviceSyncClient : public DeviceSyncClient {
FakeDeviceSyncClient(); FakeDeviceSyncClient();
~FakeDeviceSyncClient() override; ~FakeDeviceSyncClient() override;
int GetForceEnrollmentNowCallbackQueueSize();
int GetForceSyncNowCallbackQueueSize();
void InvokePendingForceEnrollmentNowCallback(bool success);
void InvokePendingForceSyncNowCallback(bool success);
void InvokePendingSetSoftwareFeatureStateCallback( void InvokePendingSetSoftwareFeatureStateCallback(
mojom::NetworkRequestResult result_code); mojom::NetworkRequestResult result_code);
void InvokePendingFindEligibleDevicesCallback( void InvokePendingFindEligibleDevicesCallback(
...@@ -35,14 +39,6 @@ class FakeDeviceSyncClient : public DeviceSyncClient { ...@@ -35,14 +39,6 @@ class FakeDeviceSyncClient : public DeviceSyncClient {
cryptauth::RemoteDeviceRefList ineligible_devices); cryptauth::RemoteDeviceRefList ineligible_devices);
void InvokePendingGetDebugInfoCallback(mojom::DebugInfoPtr debug_info_ptr); void InvokePendingGetDebugInfoCallback(mojom::DebugInfoPtr debug_info_ptr);
void set_force_enrollment_now_success(bool force_enrollment_now_success) {
force_enrollment_now_success_ = force_enrollment_now_success;
}
void set_force_sync_now_success(bool force_sync_now_success) {
force_sync_now_success_ = force_sync_now_success;
}
void set_synced_devices(cryptauth::RemoteDeviceRefList synced_devices) { void set_synced_devices(cryptauth::RemoteDeviceRefList synced_devices) {
synced_devices_ = synced_devices; synced_devices_ = synced_devices;
} }
...@@ -52,9 +48,9 @@ class FakeDeviceSyncClient : public DeviceSyncClient { ...@@ -52,9 +48,9 @@ class FakeDeviceSyncClient : public DeviceSyncClient {
local_device_metadata_ = local_device_metadata; local_device_metadata_ = local_device_metadata;
} }
using DeviceSyncClient::NotifyReady;
using DeviceSyncClient::NotifyEnrollmentFinished; using DeviceSyncClient::NotifyEnrollmentFinished;
using DeviceSyncClient::NotifyNewDevicesSynced; using DeviceSyncClient::NotifyNewDevicesSynced;
using DeviceSyncClient::NotifyReady;
private: private:
// DeviceSyncClient: // DeviceSyncClient:
...@@ -73,11 +69,13 @@ class FakeDeviceSyncClient : public DeviceSyncClient { ...@@ -73,11 +69,13 @@ class FakeDeviceSyncClient : public DeviceSyncClient {
FindEligibleDevicesCallback callback) override; FindEligibleDevicesCallback callback) override;
void GetDebugInfo(mojom::DeviceSync::GetDebugInfoCallback callback) override; void GetDebugInfo(mojom::DeviceSync::GetDebugInfoCallback callback) override;
bool force_enrollment_now_success_;
bool force_sync_now_success_;
cryptauth::RemoteDeviceRefList synced_devices_; cryptauth::RemoteDeviceRefList synced_devices_;
base::Optional<cryptauth::RemoteDeviceRef> local_device_metadata_; base::Optional<cryptauth::RemoteDeviceRef> local_device_metadata_;
std::queue<mojom::DeviceSync::ForceEnrollmentNowCallback>
force_enrollment_now_callback_queue_;
std::queue<mojom::DeviceSync::ForceSyncNowCallback>
force_sync_now_callback_queue_;
std::queue<mojom::DeviceSync::SetSoftwareFeatureStateCallback> std::queue<mojom::DeviceSync::SetSoftwareFeatureStateCallback>
set_software_feature_state_callback_queue_; set_software_feature_state_callback_queue_;
std::queue<FindEligibleDevicesCallback> find_eligible_devices_callback_queue_; std::queue<FindEligibleDevicesCallback> find_eligible_devices_callback_queue_;
......
...@@ -14,6 +14,8 @@ static_library("multidevice_setup") { ...@@ -14,6 +14,8 @@ static_library("multidevice_setup") {
"account_status_change_delegate_notifier.h", "account_status_change_delegate_notifier.h",
"account_status_change_delegate_notifier_impl.cc", "account_status_change_delegate_notifier_impl.cc",
"account_status_change_delegate_notifier_impl.h", "account_status_change_delegate_notifier_impl.h",
"device_reenroller.cc",
"device_reenroller.h",
"eligible_host_devices_provider.h", "eligible_host_devices_provider.h",
"eligible_host_devices_provider_impl.cc", "eligible_host_devices_provider_impl.cc",
"eligible_host_devices_provider_impl.h", "eligible_host_devices_provider_impl.h",
...@@ -110,6 +112,7 @@ source_set("unit_tests") { ...@@ -110,6 +112,7 @@ source_set("unit_tests") {
sources = [ sources = [
"account_status_change_delegate_notifier_impl_unittest.cc", "account_status_change_delegate_notifier_impl_unittest.cc",
"device_reenroller_unittest.cc",
"eligible_host_devices_provider_impl_unittest.cc", "eligible_host_devices_provider_impl_unittest.cc",
"feature_state_manager_impl_unittest.cc", "feature_state_manager_impl_unittest.cc",
"host_backend_delegate_impl_unittest.cc", "host_backend_delegate_impl_unittest.cc",
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chromeos/services/multidevice_setup/device_reenroller.h"
#include "base/containers/flat_set.h"
#include "base/no_destructor.h"
#include "chromeos/components/proximity_auth/logging/logging.h"
#include "chromeos/services/device_sync/public/cpp/device_sync_client.h"
#include "components/cryptauth/gcm_device_info_provider.h"
namespace chromeos {
namespace multidevice_setup {
namespace {
// The number of minutes to wait before retrying a failed re-enrollment or
// device sync attempt.
const int kNumMinutesBetweenRetries = 5;
std::vector<cryptauth::SoftwareFeature>
ComputeSupportedSoftwareFeaturesSortedDedupedListFromGcmDeviceInfo(
const cryptauth::GcmDeviceInfo& gcm_device_info) {
base::flat_set<cryptauth::SoftwareFeature> sorted_and_deduped_set;
for (int i = 0; i < gcm_device_info.supported_software_features_size(); ++i) {
sorted_and_deduped_set.insert(
gcm_device_info.supported_software_features(i));
}
return std::vector<cryptauth::SoftwareFeature>(sorted_and_deduped_set.begin(),
sorted_and_deduped_set.end());
}
std::vector<cryptauth::SoftwareFeature>
ComputeSupportedSoftwareFeaturesSortedDedupedListFromLocalDeviceMetadata(
const cryptauth::RemoteDeviceRef& local_device_metadata) {
base::flat_set<cryptauth::SoftwareFeature> sorted_and_deduped_set;
for (int i = cryptauth::SoftwareFeature_MIN;
i <= cryptauth::SoftwareFeature_MAX; ++i) {
cryptauth::SoftwareFeature feature =
static_cast<cryptauth::SoftwareFeature>(i);
if (local_device_metadata.GetSoftwareFeatureState(feature) !=
cryptauth::SoftwareFeatureState::kNotSupported) {
sorted_and_deduped_set.insert(feature);
}
}
return std::vector<cryptauth::SoftwareFeature>(sorted_and_deduped_set.begin(),
sorted_and_deduped_set.end());
}
} // namespace
// static
DeviceReenroller::Factory* DeviceReenroller::Factory::test_factory_ = nullptr;
// static
DeviceReenroller::Factory* DeviceReenroller::Factory::Get() {
if (test_factory_)
return test_factory_;
static base::NoDestructor<Factory> factory;
return factory.get();
}
// static
void DeviceReenroller::Factory::SetFactoryForTesting(Factory* test_factory) {
test_factory_ = test_factory;
}
DeviceReenroller::Factory::~Factory() = default;
std::unique_ptr<DeviceReenroller> DeviceReenroller::Factory::BuildInstance(
device_sync::DeviceSyncClient* device_sync_client,
const cryptauth::GcmDeviceInfoProvider* gcm_device_info_provider,
std::unique_ptr<base::OneShotTimer> timer) {
return base::WrapUnique(new DeviceReenroller(
device_sync_client, gcm_device_info_provider, std::move(timer)));
}
DeviceReenroller::~DeviceReenroller() = default;
DeviceReenroller::DeviceReenroller(
device_sync::DeviceSyncClient* device_sync_client,
const cryptauth::GcmDeviceInfoProvider* gcm_device_info_provider,
std::unique_ptr<base::OneShotTimer> timer)
: device_sync_client_(device_sync_client),
gcm_supported_software_features_(
ComputeSupportedSoftwareFeaturesSortedDedupedListFromGcmDeviceInfo(
gcm_device_info_provider->GetGcmDeviceInfo())),
timer_(std::move(timer)) {
// If the current set of supported software features from GcmDeviceInfo
// differs from that of the local device metadata on the CryptAuth server,
// attempt re-enrollment. Note: Both lists here are sorted and duplicate-free.
if (gcm_supported_software_features_ !=
ComputeSupportedSoftwareFeaturesSortedDedupedListFromLocalDeviceMetadata(
*device_sync_client_->GetLocalDeviceMetadata())) {
AttemptReenrollment();
}
}
void DeviceReenroller::AttemptReenrollment() {
DCHECK(!timer_->IsRunning());
device_sync_client_->ForceEnrollmentNow(base::BindOnce(
&DeviceReenroller::OnForceEnrollmentNowComplete, base::Unretained(this)));
}
void DeviceReenroller::AttemptDeviceSync() {
DCHECK(!timer_->IsRunning());
device_sync_client_->ForceSyncNow(base::BindOnce(
&DeviceReenroller::OnForceSyncNowComplete, base::Unretained(this)));
}
void DeviceReenroller::OnForceEnrollmentNowComplete(bool success) {
if (success) {
PA_LOG(INFO) << "DeviceReenroller::OnForceEnrollmentNowComplete(): "
<< "Forced enrollment attempt was successful. "
<< "Syncing devices now.";
AttemptDeviceSync();
return;
}
PA_LOG(WARNING) << "DeviceReenroller::OnForceEnrollmentNowComplete(): "
<< "Forced enrollment attempt was unsuccessful. Retrying in "
<< kNumMinutesBetweenRetries << " minutes.";
timer_->Start(FROM_HERE,
base::TimeDelta::FromMinutes(kNumMinutesBetweenRetries),
base::BindOnce(&DeviceReenroller::AttemptReenrollment,
base::Unretained(this)));
}
void DeviceReenroller::OnForceSyncNowComplete(bool success) {
// This is used to track if the device sync properly updated the local device
// metadata to reflect the supported software features from GcmDeviceInfo.
bool local_device_metadata_agrees =
device_sync_client_->GetLocalDeviceMetadata() &&
ComputeSupportedSoftwareFeaturesSortedDedupedListFromLocalDeviceMetadata(
*device_sync_client_->GetLocalDeviceMetadata()) ==
gcm_supported_software_features_;
if (success && local_device_metadata_agrees) {
PA_LOG(INFO) << "DeviceReenroller::OnForceSyncNowComplete(): "
<< "Forced device sync attempt was successful.";
return;
}
if (!success) {
PA_LOG(WARNING) << "DeviceReenroller::OnForceSyncNowComplete(): "
<< "Forced device sync attempt was unsuccessful. "
<< "Retrying in " << kNumMinutesBetweenRetries
<< " minutes.";
} else {
DCHECK(!local_device_metadata_agrees);
PA_LOG(WARNING) << "DeviceReenroller::OnForceSyncNowComplete(): "
<< "The local device metadata's supported software "
<< "features do not agree with the set extracted from GCM "
<< "device info. Retrying in " << kNumMinutesBetweenRetries
<< " minutes.";
}
timer_->Start(FROM_HERE,
base::TimeDelta::FromMinutes(kNumMinutesBetweenRetries),
base::BindOnce(&DeviceReenroller::AttemptDeviceSync,
base::Unretained(this)));
}
} // namespace multidevice_setup
} // namespace chromeos
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROMEOS_SERVICES_MULTIDEVICE_SETUP_DEVICE_REENROLLER_H_
#define CHROMEOS_SERVICES_MULTIDEVICE_SETUP_DEVICE_REENROLLER_H_
#include <memory>
#include "base/macros.h"
#include "components/cryptauth/proto/cryptauth_api.pb.h"
namespace base {
class OneShotTimer;
} // namespace base
namespace cryptauth {
class GcmDeviceInfoProvider;
} // namespace cryptauth
namespace chromeos {
namespace device_sync {
class DeviceSyncClient;
} // namespace device_sync
namespace multidevice_setup {
// The DeviceReenroller constructor re-enrolls and syncs the device if the set
// of supported SoftwareFeatures in the current GCM device info differs from
// that of the local device metadata on the CryptAuth server.
class DeviceReenroller {
public:
class Factory {
public:
static Factory* Get();
static void SetFactoryForTesting(Factory* test_factory);
virtual ~Factory();
virtual std::unique_ptr<DeviceReenroller> BuildInstance(
device_sync::DeviceSyncClient* device_sync_client,
const cryptauth::GcmDeviceInfoProvider* gcm_device_info_provider,
std::unique_ptr<base::OneShotTimer> timer =
std::make_unique<base::OneShotTimer>());
private:
static Factory* test_factory_;
};
virtual ~DeviceReenroller();
private:
DeviceReenroller(
device_sync::DeviceSyncClient* device_sync_client,
const cryptauth::GcmDeviceInfoProvider* gcm_device_info_provider,
std::unique_ptr<base::OneShotTimer> timer);
void AttemptReenrollment();
void AttemptDeviceSync();
// If the re-enrollment was successful, force a device sync; otherwise, retry
// re-enrollment every 5 minutes or until success.
void OnForceEnrollmentNowComplete(bool success);
// If the device sync was successful and the list of supported software
// features on the CryptAuth server now agrees with the list of supported
// software features in GcmDeviceInfo, log the success; otherwise, retry
// device sync every 5 minutes or until success.
void OnForceSyncNowComplete(bool success);
device_sync::DeviceSyncClient* device_sync_client_;
// The sorted and deduped list of supported software features extracted from
// GcmDeviceInfo.
std::vector<cryptauth::SoftwareFeature> gcm_supported_software_features_;
std::unique_ptr<base::OneShotTimer> timer_;
DISALLOW_COPY_AND_ASSIGN(DeviceReenroller);
};
} // namespace multidevice_setup
} // namespace chromeos
#endif // CHROMEOS_SERVICES_MULTIDEVICE_SETUP_DEVICE_REENROLLER_H_
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chromeos/services/multidevice_setup/device_reenroller.h"
#include "base/macros.h"
#include "base/timer/mock_timer.h"
#include "chromeos/services/device_sync/public/cpp/fake_device_sync_client.h"
#include "components/cryptauth/fake_gcm_device_info_provider.h"
#include "components/cryptauth/remote_device_test_util.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace chromeos {
namespace multidevice_setup {
class MultiDeviceSetupDeviceReenrollerTest : public testing::Test {
protected:
MultiDeviceSetupDeviceReenrollerTest()
: test_local_device_(cryptauth::CreateRemoteDeviceRefForTest()) {}
~MultiDeviceSetupDeviceReenrollerTest() override = default;
// testing::Test:
void SetUp() override {
fake_device_sync_client_ =
std::make_unique<device_sync::FakeDeviceSyncClient>();
fake_gcm_device_info_provider_ =
std::make_unique<cryptauth::FakeGcmDeviceInfoProvider>(
cryptauth::GcmDeviceInfo());
}
void SetLocalDeviceMetadataSoftwareFeaturesMap(
const std::map<cryptauth::SoftwareFeature,
cryptauth::SoftwareFeatureState>& map) {
cryptauth::GetMutableRemoteDevice(test_local_device_)->software_features =
map;
fake_device_sync_client_->set_local_device_metadata(test_local_device_);
}
void SetFakeGcmDeviceInfoProviderWithSupportedSoftwareFeatures(
const std::vector<cryptauth::SoftwareFeature>&
supported_software_features) {
cryptauth::GcmDeviceInfo gcm_device_info;
gcm_device_info.clear_supported_software_features();
for (cryptauth::SoftwareFeature feature : supported_software_features) {
gcm_device_info.add_supported_software_features(feature);
}
fake_gcm_device_info_provider_ =
std::make_unique<cryptauth::FakeGcmDeviceInfoProvider>(gcm_device_info);
}
device_sync::FakeDeviceSyncClient* fake_device_sync_client() {
return fake_device_sync_client_.get();
}
base::MockOneShotTimer* timer() { return mock_timer_; }
void CreateDeviceReenroller() {
auto mock_timer = std::make_unique<base::MockOneShotTimer>();
mock_timer_ = mock_timer.get();
device_reenroller_ = DeviceReenroller::Factory::Get()->BuildInstance(
fake_device_sync_client_.get(), fake_gcm_device_info_provider_.get(),
std::move(mock_timer));
}
private:
std::unique_ptr<DeviceReenroller> device_reenroller_;
std::unique_ptr<device_sync::FakeDeviceSyncClient> fake_device_sync_client_;
std::unique_ptr<cryptauth::FakeGcmDeviceInfoProvider>
fake_gcm_device_info_provider_;
base::MockOneShotTimer* mock_timer_;
cryptauth::RemoteDeviceRef test_local_device_;
DISALLOW_COPY_AND_ASSIGN(MultiDeviceSetupDeviceReenrollerTest);
};
TEST_F(MultiDeviceSetupDeviceReenrollerTest,
IfGmcDeviceInfoAndLocalDeviceMetadataMatchThenNoReenrollment) {
// Set the current local device metadata to contain a sample of supported
// software features.
SetLocalDeviceMetadataSoftwareFeaturesMap(
std::map<cryptauth::SoftwareFeature, cryptauth::SoftwareFeatureState>{
{cryptauth::SoftwareFeature::BETTER_TOGETHER_CLIENT,
cryptauth::SoftwareFeatureState::kSupported},
{cryptauth::SoftwareFeature::EASY_UNLOCK_CLIENT,
cryptauth::SoftwareFeatureState::kSupported}});
// Set the current GcmDeviceInfo supported software features to contain the
// same set.
SetFakeGcmDeviceInfoProviderWithSupportedSoftwareFeatures(
std::vector<cryptauth::SoftwareFeature>{
cryptauth::SoftwareFeature::BETTER_TOGETHER_CLIENT,
cryptauth::SoftwareFeature::EASY_UNLOCK_CLIENT});
CreateDeviceReenroller();
// No enrollment or device sync attempts should have taken place nor should
// any be scheduled.
EXPECT_EQ(
0, fake_device_sync_client()->GetForceEnrollmentNowCallbackQueueSize());
EXPECT_EQ(0, fake_device_sync_client()->GetForceSyncNowCallbackQueueSize());
EXPECT_FALSE(timer()->IsRunning());
}
TEST_F(MultiDeviceSetupDeviceReenrollerTest,
IfFeaturesBecomeUnsupportedThenUpdateAndReenroll) {
// Set the current local device metadata to contain a sample of supported
// software features.
SetLocalDeviceMetadataSoftwareFeaturesMap(
std::map<cryptauth::SoftwareFeature, cryptauth::SoftwareFeatureState>{
{cryptauth::SoftwareFeature::BETTER_TOGETHER_CLIENT,
cryptauth::SoftwareFeatureState::kSupported},
{cryptauth::SoftwareFeature::EASY_UNLOCK_CLIENT,
cryptauth::SoftwareFeatureState::kSupported}});
// Remove one supported software feature in the GcmDeviceInfo.
SetFakeGcmDeviceInfoProviderWithSupportedSoftwareFeatures(
std::vector<cryptauth::SoftwareFeature>{
cryptauth::SoftwareFeature::BETTER_TOGETHER_CLIENT});
CreateDeviceReenroller();
// Assume successful enrollment, sync, and local device metadata update.
EXPECT_EQ(
1, fake_device_sync_client()->GetForceEnrollmentNowCallbackQueueSize());
fake_device_sync_client()->InvokePendingForceEnrollmentNowCallback(
true /* success */);
EXPECT_EQ(1, fake_device_sync_client()->GetForceSyncNowCallbackQueueSize());
SetLocalDeviceMetadataSoftwareFeaturesMap(
std::map<cryptauth::SoftwareFeature, cryptauth::SoftwareFeatureState>{
{cryptauth::SoftwareFeature::BETTER_TOGETHER_CLIENT,
cryptauth::SoftwareFeatureState::kSupported}});
fake_device_sync_client()->InvokePendingForceSyncNowCallback(
true /* success */);
// No other attempts should be scheduled.
EXPECT_FALSE(timer()->IsRunning());
}
TEST_F(MultiDeviceSetupDeviceReenrollerTest,
IfFeaturesBecomeSupportedThenUpdateAndReenroll) {
// Set the current local device metadata to contain a sample of supported
// software features.
SetLocalDeviceMetadataSoftwareFeaturesMap(
std::map<cryptauth::SoftwareFeature, cryptauth::SoftwareFeatureState>{
{cryptauth::SoftwareFeature::BETTER_TOGETHER_CLIENT,
cryptauth::SoftwareFeatureState::kSupported},
{cryptauth::SoftwareFeature::EASY_UNLOCK_CLIENT,
cryptauth::SoftwareFeatureState::kSupported}});
// Add one more supported software feature in the GcmDeviceInfo.
SetFakeGcmDeviceInfoProviderWithSupportedSoftwareFeatures(
std::vector<cryptauth::SoftwareFeature>{
cryptauth::SoftwareFeature::BETTER_TOGETHER_CLIENT,
cryptauth::SoftwareFeature::EASY_UNLOCK_CLIENT,
cryptauth::SoftwareFeature::MAGIC_TETHER_CLIENT});
CreateDeviceReenroller();
// Assume successful enrollment, sync, and local device metadata update.
EXPECT_EQ(
1, fake_device_sync_client()->GetForceEnrollmentNowCallbackQueueSize());
fake_device_sync_client()->InvokePendingForceEnrollmentNowCallback(
true /* success */);
EXPECT_EQ(1, fake_device_sync_client()->GetForceSyncNowCallbackQueueSize());
SetLocalDeviceMetadataSoftwareFeaturesMap(
std::map<cryptauth::SoftwareFeature, cryptauth::SoftwareFeatureState>{
{cryptauth::SoftwareFeature::BETTER_TOGETHER_CLIENT,
cryptauth::SoftwareFeatureState::kSupported},
{cryptauth::SoftwareFeature::EASY_UNLOCK_CLIENT,
cryptauth::SoftwareFeatureState::kSupported},
{cryptauth::SoftwareFeature::MAGIC_TETHER_CLIENT,
cryptauth::SoftwareFeatureState::kSupported}});
fake_device_sync_client()->InvokePendingForceSyncNowCallback(
true /* success */);
// No other attempts should be scheduled.
EXPECT_FALSE(timer()->IsRunning());
}
TEST_F(MultiDeviceSetupDeviceReenrollerTest,
IfReenrollmentFailsThenScheduleAnotherAttempt) {
// Set the current local device metadata to contain a sample of supported
// software features.
SetLocalDeviceMetadataSoftwareFeaturesMap(
std::map<cryptauth::SoftwareFeature, cryptauth::SoftwareFeatureState>{
{cryptauth::SoftwareFeature::BETTER_TOGETHER_CLIENT,
cryptauth::SoftwareFeatureState::kSupported},
{cryptauth::SoftwareFeature::EASY_UNLOCK_CLIENT,
cryptauth::SoftwareFeatureState::kSupported}});
// Add one more supported software feature in the GcmDeviceInfo to trigger a
// re-enrollment attempt.
SetFakeGcmDeviceInfoProviderWithSupportedSoftwareFeatures(
std::vector<cryptauth::SoftwareFeature>{
cryptauth::SoftwareFeature::BETTER_TOGETHER_CLIENT,
cryptauth::SoftwareFeature::EASY_UNLOCK_CLIENT,
cryptauth::SoftwareFeature::MAGIC_TETHER_CLIENT});
CreateDeviceReenroller();
EXPECT_EQ(
1, fake_device_sync_client()->GetForceEnrollmentNowCallbackQueueSize());
// Assume unsuccessful re-enrollment attempt.
fake_device_sync_client()->InvokePendingForceEnrollmentNowCallback(
false /* success */);
// No device sync call should have been made.
EXPECT_EQ(0, fake_device_sync_client()->GetForceSyncNowCallbackQueueSize());
// Another re-enrollment attempt should be scheduled.
EXPECT_TRUE(timer()->IsRunning());
// This should trigger another enrollment attempt.
timer()->Fire();
EXPECT_EQ(
1, fake_device_sync_client()->GetForceEnrollmentNowCallbackQueueSize());
EXPECT_EQ(0, fake_device_sync_client()->GetForceSyncNowCallbackQueueSize());
}
TEST_F(MultiDeviceSetupDeviceReenrollerTest,
IfDeviceSyncFailsThenScheduleAnotherAttempt) {
// Set the current local device metadata to contain a sample of supported
// software features.
SetLocalDeviceMetadataSoftwareFeaturesMap(
std::map<cryptauth::SoftwareFeature, cryptauth::SoftwareFeatureState>{
{cryptauth::SoftwareFeature::BETTER_TOGETHER_CLIENT,
cryptauth::SoftwareFeatureState::kSupported},
{cryptauth::SoftwareFeature::EASY_UNLOCK_CLIENT,
cryptauth::SoftwareFeatureState::kSupported}});
// Add one more supported software feature in the GcmDeviceInfo to trigger a
// re-enrollment attempt.
SetFakeGcmDeviceInfoProviderWithSupportedSoftwareFeatures(
std::vector<cryptauth::SoftwareFeature>{
cryptauth::SoftwareFeature::BETTER_TOGETHER_CLIENT,
cryptauth::SoftwareFeature::EASY_UNLOCK_CLIENT,
cryptauth::SoftwareFeature::MAGIC_TETHER_CLIENT});
CreateDeviceReenroller();
// Assume successful re-enrollment attempt.
EXPECT_EQ(
1, fake_device_sync_client()->GetForceEnrollmentNowCallbackQueueSize());
fake_device_sync_client()->InvokePendingForceEnrollmentNowCallback(
true /* success */);
EXPECT_EQ(1, fake_device_sync_client()->GetForceSyncNowCallbackQueueSize());
// Assume unsuccessful device sync attempt.
fake_device_sync_client()->InvokePendingForceSyncNowCallback(
false /* success */);
// Another device sync attempt should be scheduled.
EXPECT_TRUE(timer()->IsRunning());
// This should trigger another device sync attempt.
timer()->Fire();
EXPECT_EQ(
0, fake_device_sync_client()->GetForceEnrollmentNowCallbackQueueSize());
EXPECT_EQ(1, fake_device_sync_client()->GetForceSyncNowCallbackQueueSize());
}
TEST_F(MultiDeviceSetupDeviceReenrollerTest,
IfLocalDeviceMetadataNotUpdatedCorrectlyThenScheduleAnotherSyncAttempt) {
// Set the current local device metadata to contain a sample of supported
// software features.
SetLocalDeviceMetadataSoftwareFeaturesMap(
std::map<cryptauth::SoftwareFeature, cryptauth::SoftwareFeatureState>{
{cryptauth::SoftwareFeature::BETTER_TOGETHER_CLIENT,
cryptauth::SoftwareFeatureState::kSupported},
{cryptauth::SoftwareFeature::EASY_UNLOCK_CLIENT,
cryptauth::SoftwareFeatureState::kSupported}});
// Add one more supported software feature in the GcmDeviceInfo to trigger a
// re-enrollment attempt.
SetFakeGcmDeviceInfoProviderWithSupportedSoftwareFeatures(
std::vector<cryptauth::SoftwareFeature>{
cryptauth::SoftwareFeature::BETTER_TOGETHER_CLIENT,
cryptauth::SoftwareFeature::EASY_UNLOCK_CLIENT,
cryptauth::SoftwareFeature::MAGIC_TETHER_CLIENT});
CreateDeviceReenroller();
// Assume successful enrollment and device sync.
EXPECT_EQ(
1, fake_device_sync_client()->GetForceEnrollmentNowCallbackQueueSize());
fake_device_sync_client()->InvokePendingForceEnrollmentNowCallback(
true /* success */);
EXPECT_EQ(1, fake_device_sync_client()->GetForceSyncNowCallbackQueueSize());
// Assume local device metadata was not updated correctly.
SetLocalDeviceMetadataSoftwareFeaturesMap(
std::map<cryptauth::SoftwareFeature, cryptauth::SoftwareFeatureState>{
{cryptauth::SoftwareFeature::BETTER_TOGETHER_CLIENT,
cryptauth::SoftwareFeatureState::kSupported},
{cryptauth::SoftwareFeature::EASY_UNLOCK_CLIENT,
cryptauth::SoftwareFeatureState::kSupported}});
fake_device_sync_client()->InvokePendingForceSyncNowCallback(
true /* success */);
// Another device sync attempt should be scheduled.
EXPECT_TRUE(timer()->IsRunning());
// This should trigger another device sync attempt.
timer()->Fire();
EXPECT_EQ(
0, fake_device_sync_client()->GetForceEnrollmentNowCallbackQueueSize());
EXPECT_EQ(1, fake_device_sync_client()->GetForceSyncNowCallbackQueueSize());
}
TEST_F(MultiDeviceSetupDeviceReenrollerTest,
GcmDeviceInfoFeatureListOrderingAndDuplicatesAreIrrelevantForReenroll) {
// Set the current local device metadata to contain a sample of supported
// software features.
SetLocalDeviceMetadataSoftwareFeaturesMap(
std::map<cryptauth::SoftwareFeature, cryptauth::SoftwareFeatureState>{
{cryptauth::SoftwareFeature::BETTER_TOGETHER_CLIENT,
cryptauth::SoftwareFeatureState::kSupported},
{cryptauth::SoftwareFeature::EASY_UNLOCK_CLIENT,
cryptauth::SoftwareFeatureState::kSupported},
{cryptauth::SoftwareFeature::MAGIC_TETHER_CLIENT,
cryptauth::SoftwareFeatureState::kSupported}});
// Add one more supported software feature in the GcmDeviceInfo.
SetFakeGcmDeviceInfoProviderWithSupportedSoftwareFeatures(
std::vector<cryptauth::SoftwareFeature>{
cryptauth::SoftwareFeature::SMS_CONNECT_CLIENT,
cryptauth::SoftwareFeature::BETTER_TOGETHER_CLIENT,
cryptauth::SoftwareFeature::EASY_UNLOCK_CLIENT,
cryptauth::SoftwareFeature::BETTER_TOGETHER_CLIENT,
cryptauth::SoftwareFeature::SMS_CONNECT_CLIENT,
cryptauth::SoftwareFeature::MAGIC_TETHER_CLIENT});
CreateDeviceReenroller();
// Assume successful enrollment, sync, and local device metadata update.
EXPECT_EQ(
1, fake_device_sync_client()->GetForceEnrollmentNowCallbackQueueSize());
fake_device_sync_client()->InvokePendingForceEnrollmentNowCallback(
true /* success */);
EXPECT_EQ(1, fake_device_sync_client()->GetForceSyncNowCallbackQueueSize());
SetLocalDeviceMetadataSoftwareFeaturesMap(
std::map<cryptauth::SoftwareFeature, cryptauth::SoftwareFeatureState>{
{cryptauth::SoftwareFeature::BETTER_TOGETHER_CLIENT,
cryptauth::SoftwareFeatureState::kSupported},
{cryptauth::SoftwareFeature::EASY_UNLOCK_CLIENT,
cryptauth::SoftwareFeatureState::kSupported},
{cryptauth::SoftwareFeature::MAGIC_TETHER_CLIENT,
cryptauth::SoftwareFeatureState::kSupported},
{cryptauth::SoftwareFeature::SMS_CONNECT_CLIENT,
cryptauth::SoftwareFeatureState::kSupported}});
fake_device_sync_client()->InvokePendingForceSyncNowCallback(
true /* success */);
// No other attempts should be scheduled.
EXPECT_FALSE(timer()->IsRunning());
}
TEST_F(
MultiDeviceSetupDeviceReenrollerTest,
GcmDeviceInfoFeatureListOrderingAndDuplicatesAreIrrelevantForNoReenroll) {
// Set the current local device metadata to contain a sample of supported
// software features.
SetLocalDeviceMetadataSoftwareFeaturesMap(
std::map<cryptauth::SoftwareFeature, cryptauth::SoftwareFeatureState>{
{cryptauth::SoftwareFeature::BETTER_TOGETHER_CLIENT,
cryptauth::SoftwareFeatureState::kSupported},
{cryptauth::SoftwareFeature::EASY_UNLOCK_CLIENT,
cryptauth::SoftwareFeatureState::kSupported},
{cryptauth::SoftwareFeature::MAGIC_TETHER_CLIENT,
cryptauth::SoftwareFeatureState::kSupported}});
// Add one more supported software feature in the GcmDeviceInfo.
SetFakeGcmDeviceInfoProviderWithSupportedSoftwareFeatures(
std::vector<cryptauth::SoftwareFeature>{
cryptauth::SoftwareFeature::EASY_UNLOCK_CLIENT,
cryptauth::SoftwareFeature::BETTER_TOGETHER_CLIENT,
cryptauth::SoftwareFeature::EASY_UNLOCK_CLIENT,
cryptauth::SoftwareFeature::BETTER_TOGETHER_CLIENT,
cryptauth::SoftwareFeature::MAGIC_TETHER_CLIENT});
CreateDeviceReenroller();
EXPECT_EQ(
0, fake_device_sync_client()->GetForceEnrollmentNowCallbackQueueSize());
EXPECT_EQ(0, fake_device_sync_client()->GetForceSyncNowCallbackQueueSize());
// No other attempts should be scheduled.
EXPECT_FALSE(timer()->IsRunning());
}
} // namespace multidevice_setup
} // namespace chromeos
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/time/default_clock.h" #include "base/time/default_clock.h"
#include "chromeos/components/proximity_auth/logging/logging.h" #include "chromeos/components/proximity_auth/logging/logging.h"
#include "chromeos/services/multidevice_setup/account_status_change_delegate_notifier_impl.h" #include "chromeos/services/multidevice_setup/account_status_change_delegate_notifier_impl.h"
#include "chromeos/services/multidevice_setup/device_reenroller.h"
#include "chromeos/services/multidevice_setup/eligible_host_devices_provider_impl.h" #include "chromeos/services/multidevice_setup/eligible_host_devices_provider_impl.h"
#include "chromeos/services/multidevice_setup/feature_state_manager_impl.h" #include "chromeos/services/multidevice_setup/feature_state_manager_impl.h"
#include "chromeos/services/multidevice_setup/host_backend_delegate_impl.h" #include "chromeos/services/multidevice_setup/host_backend_delegate_impl.h"
...@@ -54,10 +55,12 @@ MultiDeviceSetupImpl::Factory::BuildInstance( ...@@ -54,10 +55,12 @@ MultiDeviceSetupImpl::Factory::BuildInstance(
secure_channel::SecureChannelClient* secure_channel_client, secure_channel::SecureChannelClient* secure_channel_client,
AuthTokenValidator* auth_token_validator, AuthTokenValidator* auth_token_validator,
std::unique_ptr<AndroidSmsAppHelperDelegate> std::unique_ptr<AndroidSmsAppHelperDelegate>
android_sms_app_helper_delegate) { android_sms_app_helper_delegate,
const cryptauth::GcmDeviceInfoProvider* gcm_device_info_provider) {
return base::WrapUnique(new MultiDeviceSetupImpl( return base::WrapUnique(new MultiDeviceSetupImpl(
pref_service, device_sync_client, secure_channel_client, pref_service, device_sync_client, secure_channel_client,
auth_token_validator, std::move(android_sms_app_helper_delegate))); auth_token_validator, std::move(android_sms_app_helper_delegate),
gcm_device_info_provider));
} }
MultiDeviceSetupImpl::MultiDeviceSetupImpl( MultiDeviceSetupImpl::MultiDeviceSetupImpl(
...@@ -66,7 +69,8 @@ MultiDeviceSetupImpl::MultiDeviceSetupImpl( ...@@ -66,7 +69,8 @@ MultiDeviceSetupImpl::MultiDeviceSetupImpl(
secure_channel::SecureChannelClient* secure_channel_client, secure_channel::SecureChannelClient* secure_channel_client,
AuthTokenValidator* auth_token_validator, AuthTokenValidator* auth_token_validator,
std::unique_ptr<AndroidSmsAppHelperDelegate> std::unique_ptr<AndroidSmsAppHelperDelegate>
android_sms_app_helper_delegate) android_sms_app_helper_delegate,
const cryptauth::GcmDeviceInfoProvider* gcm_device_info_provider)
: android_sms_app_helper_delegate_( : android_sms_app_helper_delegate_(
std::move(android_sms_app_helper_delegate)), std::move(android_sms_app_helper_delegate)),
eligible_host_devices_provider_( eligible_host_devices_provider_(
...@@ -102,6 +106,9 @@ MultiDeviceSetupImpl::MultiDeviceSetupImpl( ...@@ -102,6 +106,9 @@ MultiDeviceSetupImpl::MultiDeviceSetupImpl(
pref_service, pref_service,
setup_flow_completion_recorder_.get(), setup_flow_completion_recorder_.get(),
base::DefaultClock::GetInstance())), base::DefaultClock::GetInstance())),
device_reenroller_(DeviceReenroller::Factory::Get()->BuildInstance(
device_sync_client,
gcm_device_info_provider)),
auth_token_validator_(auth_token_validator) { auth_token_validator_(auth_token_validator) {
host_status_provider_->AddObserver(this); host_status_provider_->AddObserver(this);
feature_state_manager_->AddObserver(this); feature_state_manager_->AddObserver(this);
......
...@@ -17,6 +17,10 @@ ...@@ -17,6 +17,10 @@
class PrefService; class PrefService;
namespace cryptauth {
class GcmDeviceInfoProvider;
} // namespace cryptauth
namespace chromeos { namespace chromeos {
namespace device_sync { namespace device_sync {
...@@ -32,6 +36,7 @@ namespace multidevice_setup { ...@@ -32,6 +36,7 @@ namespace multidevice_setup {
class AccountStatusChangeDelegateNotifier; class AccountStatusChangeDelegateNotifier;
class AndroidSmsAppHelperDelegate; class AndroidSmsAppHelperDelegate;
class AuthTokenValidator; class AuthTokenValidator;
class DeviceReenroller;
class HostBackendDelegate; class HostBackendDelegate;
class HostStatusProvider; class HostStatusProvider;
class HostVerifier; class HostVerifier;
...@@ -54,7 +59,8 @@ class MultiDeviceSetupImpl : public mojom::MultiDeviceSetup, ...@@ -54,7 +59,8 @@ class MultiDeviceSetupImpl : public mojom::MultiDeviceSetup,
secure_channel::SecureChannelClient* secure_channel_client, secure_channel::SecureChannelClient* secure_channel_client,
AuthTokenValidator* auth_token_validator, AuthTokenValidator* auth_token_validator,
std::unique_ptr<AndroidSmsAppHelperDelegate> std::unique_ptr<AndroidSmsAppHelperDelegate>
android_sms_app_helper_delegate); android_sms_app_helper_delegate,
const cryptauth::GcmDeviceInfoProvider* gcm_device_info_provider);
private: private:
static Factory* test_factory_; static Factory* test_factory_;
...@@ -72,7 +78,8 @@ class MultiDeviceSetupImpl : public mojom::MultiDeviceSetup, ...@@ -72,7 +78,8 @@ class MultiDeviceSetupImpl : public mojom::MultiDeviceSetup,
secure_channel::SecureChannelClient* secure_channel_client, secure_channel::SecureChannelClient* secure_channel_client,
AuthTokenValidator* auth_token_validator, AuthTokenValidator* auth_token_validator,
std::unique_ptr<AndroidSmsAppHelperDelegate> std::unique_ptr<AndroidSmsAppHelperDelegate>
android_sms_app_helper_delegate); android_sms_app_helper_delegate,
const cryptauth::GcmDeviceInfoProvider* gcm_device_info_provider);
// mojom::MultiDeviceSetup: // mojom::MultiDeviceSetup:
void SetAccountStatusChangeDelegate( void SetAccountStatusChangeDelegate(
...@@ -114,6 +121,7 @@ class MultiDeviceSetupImpl : public mojom::MultiDeviceSetup, ...@@ -114,6 +121,7 @@ class MultiDeviceSetupImpl : public mojom::MultiDeviceSetup,
std::unique_ptr<FeatureStateManager> feature_state_manager_; std::unique_ptr<FeatureStateManager> feature_state_manager_;
std::unique_ptr<SetupFlowCompletionRecorder> setup_flow_completion_recorder_; std::unique_ptr<SetupFlowCompletionRecorder> setup_flow_completion_recorder_;
std::unique_ptr<AccountStatusChangeDelegateNotifier> delegate_notifier_; std::unique_ptr<AccountStatusChangeDelegateNotifier> delegate_notifier_;
std::unique_ptr<DeviceReenroller> device_reenroller_;
AuthTokenValidator* auth_token_validator_; AuthTokenValidator* auth_token_validator_;
mojo::InterfacePtrSet<mojom::HostStatusObserver> host_status_observers_; mojo::InterfacePtrSet<mojom::HostStatusObserver> host_status_observers_;
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/test/scoped_task_environment.h" #include "base/test/scoped_task_environment.h"
#include "chromeos/services/device_sync/public/cpp/fake_device_sync_client.h" #include "chromeos/services/device_sync/public/cpp/fake_device_sync_client.h"
#include "chromeos/services/multidevice_setup/account_status_change_delegate_notifier_impl.h" #include "chromeos/services/multidevice_setup/account_status_change_delegate_notifier_impl.h"
#include "chromeos/services/multidevice_setup/device_reenroller.h"
#include "chromeos/services/multidevice_setup/eligible_host_devices_provider_impl.h" #include "chromeos/services/multidevice_setup/eligible_host_devices_provider_impl.h"
#include "chromeos/services/multidevice_setup/fake_account_status_change_delegate.h" #include "chromeos/services/multidevice_setup/fake_account_status_change_delegate.h"
#include "chromeos/services/multidevice_setup/fake_account_status_change_delegate_notifier.h" #include "chromeos/services/multidevice_setup/fake_account_status_change_delegate_notifier.h"
...@@ -31,6 +32,7 @@ ...@@ -31,6 +32,7 @@
#include "chromeos/services/multidevice_setup/public/mojom/multidevice_setup.mojom.h" #include "chromeos/services/multidevice_setup/public/mojom/multidevice_setup.mojom.h"
#include "chromeos/services/multidevice_setup/setup_flow_completion_recorder_impl.h" #include "chromeos/services/multidevice_setup/setup_flow_completion_recorder_impl.h"
#include "chromeos/services/secure_channel/public/cpp/client/fake_secure_channel_client.h" #include "chromeos/services/secure_channel/public/cpp/client/fake_secure_channel_client.h"
#include "components/cryptauth/fake_gcm_device_info_provider.h"
#include "components/cryptauth/remote_device_test_util.h" #include "components/cryptauth/remote_device_test_util.h"
#include "components/sync_preferences/testing_pref_service_syncable.h" #include "components/sync_preferences/testing_pref_service_syncable.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -350,6 +352,36 @@ class FakeAccountStatusChangeDelegateNotifierFactory ...@@ -350,6 +352,36 @@ class FakeAccountStatusChangeDelegateNotifierFactory
DISALLOW_COPY_AND_ASSIGN(FakeAccountStatusChangeDelegateNotifierFactory); DISALLOW_COPY_AND_ASSIGN(FakeAccountStatusChangeDelegateNotifierFactory);
}; };
class FakeDeviceReenrollerFactory : public DeviceReenroller::Factory {
public:
FakeDeviceReenrollerFactory(
device_sync::FakeDeviceSyncClient* expected_device_sync_client,
const cryptauth::FakeGcmDeviceInfoProvider*
expected_gcm_device_info_provider)
: expected_device_sync_client_(expected_device_sync_client),
expected_gcm_device_info_provider_(expected_gcm_device_info_provider) {}
~FakeDeviceReenrollerFactory() override = default;
private:
// DeviceReenroller::Factory:
std::unique_ptr<DeviceReenroller> BuildInstance(
device_sync::DeviceSyncClient* device_sync_client,
const cryptauth::GcmDeviceInfoProvider* gcm_device_info_provider,
std::unique_ptr<base::OneShotTimer> timer) override {
EXPECT_EQ(expected_device_sync_client_, device_sync_client);
EXPECT_EQ(expected_gcm_device_info_provider_, gcm_device_info_provider);
// Only check inputs and return nullptr. We do not want to trigger the
// DeviceReenroller logic in these unit tests.
return nullptr;
}
device_sync::FakeDeviceSyncClient* expected_device_sync_client_;
const cryptauth::GcmDeviceInfoProvider* expected_gcm_device_info_provider_;
DISALLOW_COPY_AND_ASSIGN(FakeDeviceReenrollerFactory);
};
} // namespace } // namespace
class MultiDeviceSetupImplTest : public testing::Test { class MultiDeviceSetupImplTest : public testing::Test {
...@@ -375,6 +407,10 @@ class MultiDeviceSetupImplTest : public testing::Test { ...@@ -375,6 +407,10 @@ class MultiDeviceSetupImplTest : public testing::Test {
fake_android_sms_app_helper_delegate_ = fake_android_sms_app_helper_delegate_ =
fake_android_sms_app_helper_delegate.get(); fake_android_sms_app_helper_delegate.get();
fake_gcm_device_info_provider_ =
std::make_unique<cryptauth::FakeGcmDeviceInfoProvider>(
cryptauth::GcmDeviceInfo());
fake_eligible_host_devices_provider_factory_ = fake_eligible_host_devices_provider_factory_ =
std::make_unique<FakeEligibleHostDevicesProviderFactory>( std::make_unique<FakeEligibleHostDevicesProviderFactory>(
fake_device_sync_client_.get()); fake_device_sync_client_.get());
...@@ -422,10 +458,18 @@ class MultiDeviceSetupImplTest : public testing::Test { ...@@ -422,10 +458,18 @@ class MultiDeviceSetupImplTest : public testing::Test {
AccountStatusChangeDelegateNotifierImpl::Factory::SetFactoryForTesting( AccountStatusChangeDelegateNotifierImpl::Factory::SetFactoryForTesting(
fake_account_status_change_delegate_notifier_factory_.get()); fake_account_status_change_delegate_notifier_factory_.get());
fake_device_reenroller_factory_ =
std::make_unique<FakeDeviceReenrollerFactory>(
fake_device_sync_client_.get(),
fake_gcm_device_info_provider_.get());
DeviceReenroller::Factory::SetFactoryForTesting(
fake_device_reenroller_factory_.get());
multidevice_setup_ = MultiDeviceSetupImpl::Factory::Get()->BuildInstance( multidevice_setup_ = MultiDeviceSetupImpl::Factory::Get()->BuildInstance(
test_pref_service_.get(), fake_device_sync_client_.get(), test_pref_service_.get(), fake_device_sync_client_.get(),
fake_secure_channel_client_.get(), fake_auth_token_validator_.get(), fake_secure_channel_client_.get(), fake_auth_token_validator_.get(),
std::move(fake_android_sms_app_helper_delegate)); std::move(fake_android_sms_app_helper_delegate),
fake_gcm_device_info_provider_.get());
} }
void TearDown() override { void TearDown() override {
...@@ -437,6 +481,7 @@ class MultiDeviceSetupImplTest : public testing::Test { ...@@ -437,6 +481,7 @@ class MultiDeviceSetupImplTest : public testing::Test {
SetupFlowCompletionRecorderImpl::Factory::SetFactoryForTesting(nullptr); SetupFlowCompletionRecorderImpl::Factory::SetFactoryForTesting(nullptr);
AccountStatusChangeDelegateNotifierImpl::Factory::SetFactoryForTesting( AccountStatusChangeDelegateNotifierImpl::Factory::SetFactoryForTesting(
nullptr); nullptr);
DeviceReenroller::Factory::SetFactoryForTesting(nullptr);
} }
void CallSetAccountStatusChangeDelegate() { void CallSetAccountStatusChangeDelegate() {
...@@ -685,6 +730,8 @@ class MultiDeviceSetupImplTest : public testing::Test { ...@@ -685,6 +730,8 @@ class MultiDeviceSetupImplTest : public testing::Test {
std::unique_ptr<secure_channel::FakeSecureChannelClient> std::unique_ptr<secure_channel::FakeSecureChannelClient>
fake_secure_channel_client_; fake_secure_channel_client_;
std::unique_ptr<FakeAuthTokenValidator> fake_auth_token_validator_; std::unique_ptr<FakeAuthTokenValidator> fake_auth_token_validator_;
std::unique_ptr<cryptauth::FakeGcmDeviceInfoProvider>
fake_gcm_device_info_provider_;
std::unique_ptr<FakeEligibleHostDevicesProviderFactory> std::unique_ptr<FakeEligibleHostDevicesProviderFactory>
fake_eligible_host_devices_provider_factory_; fake_eligible_host_devices_provider_factory_;
...@@ -699,6 +746,7 @@ class MultiDeviceSetupImplTest : public testing::Test { ...@@ -699,6 +746,7 @@ class MultiDeviceSetupImplTest : public testing::Test {
fake_setup_flow_completion_recorder_factory_; fake_setup_flow_completion_recorder_factory_;
std::unique_ptr<FakeAccountStatusChangeDelegateNotifierFactory> std::unique_ptr<FakeAccountStatusChangeDelegateNotifierFactory>
fake_account_status_change_delegate_notifier_factory_; fake_account_status_change_delegate_notifier_factory_;
std::unique_ptr<FakeDeviceReenrollerFactory> fake_device_reenroller_factory_;
FakeAndroidSmsAppHelperDelegate* fake_android_sms_app_helper_delegate_; FakeAndroidSmsAppHelperDelegate* fake_android_sms_app_helper_delegate_;
std::unique_ptr<FakeAccountStatusChangeDelegate> std::unique_ptr<FakeAccountStatusChangeDelegate>
......
...@@ -44,10 +44,12 @@ MultiDeviceSetupInitializer::Factory::BuildInstance( ...@@ -44,10 +44,12 @@ MultiDeviceSetupInitializer::Factory::BuildInstance(
secure_channel::SecureChannelClient* secure_channel_client, secure_channel::SecureChannelClient* secure_channel_client,
AuthTokenValidator* auth_token_validator, AuthTokenValidator* auth_token_validator,
std::unique_ptr<AndroidSmsAppHelperDelegate> std::unique_ptr<AndroidSmsAppHelperDelegate>
android_sms_app_helper_delegate) { android_sms_app_helper_delegate,
const cryptauth::GcmDeviceInfoProvider* gcm_device_info_provider) {
return base::WrapUnique(new MultiDeviceSetupInitializer( return base::WrapUnique(new MultiDeviceSetupInitializer(
pref_service, device_sync_client, secure_channel_client, pref_service, device_sync_client, secure_channel_client,
auth_token_validator, std::move(android_sms_app_helper_delegate))); auth_token_validator, std::move(android_sms_app_helper_delegate),
gcm_device_info_provider));
} }
MultiDeviceSetupInitializer::MultiDeviceSetupInitializer( MultiDeviceSetupInitializer::MultiDeviceSetupInitializer(
...@@ -56,13 +58,15 @@ MultiDeviceSetupInitializer::MultiDeviceSetupInitializer( ...@@ -56,13 +58,15 @@ MultiDeviceSetupInitializer::MultiDeviceSetupInitializer(
secure_channel::SecureChannelClient* secure_channel_client, secure_channel::SecureChannelClient* secure_channel_client,
AuthTokenValidator* auth_token_validator, AuthTokenValidator* auth_token_validator,
std::unique_ptr<AndroidSmsAppHelperDelegate> std::unique_ptr<AndroidSmsAppHelperDelegate>
android_sms_app_helper_delegate) android_sms_app_helper_delegate,
const cryptauth::GcmDeviceInfoProvider* gcm_device_info_provider)
: pref_service_(pref_service), : pref_service_(pref_service),
device_sync_client_(device_sync_client), device_sync_client_(device_sync_client),
secure_channel_client_(secure_channel_client), secure_channel_client_(secure_channel_client),
auth_token_validator_(auth_token_validator), auth_token_validator_(auth_token_validator),
android_sms_app_helper_delegate_( android_sms_app_helper_delegate_(
std::move(android_sms_app_helper_delegate)) { std::move(android_sms_app_helper_delegate)),
gcm_device_info_provider_(gcm_device_info_provider) {
if (device_sync_client_->is_ready()) { if (device_sync_client_->is_ready()) {
InitializeImplementation(); InitializeImplementation();
return; return;
...@@ -221,7 +225,8 @@ void MultiDeviceSetupInitializer::InitializeImplementation() { ...@@ -221,7 +225,8 @@ void MultiDeviceSetupInitializer::InitializeImplementation() {
multidevice_setup_impl_ = MultiDeviceSetupImpl::Factory::Get()->BuildInstance( multidevice_setup_impl_ = MultiDeviceSetupImpl::Factory::Get()->BuildInstance(
pref_service_, device_sync_client_, secure_channel_client_, pref_service_, device_sync_client_, secure_channel_client_,
auth_token_validator_, std::move(android_sms_app_helper_delegate_)); auth_token_validator_, std::move(android_sms_app_helper_delegate_),
gcm_device_info_provider_);
if (pending_delegate_) { if (pending_delegate_) {
multidevice_setup_impl_->SetAccountStatusChangeDelegate( multidevice_setup_impl_->SetAccountStatusChangeDelegate(
......
...@@ -16,6 +16,10 @@ ...@@ -16,6 +16,10 @@
class PrefService; class PrefService;
namespace cryptauth {
class GcmDeviceInfoProvider;
} // namespace cryptauth
namespace chromeos { namespace chromeos {
namespace secure_channel { namespace secure_channel {
...@@ -45,7 +49,8 @@ class MultiDeviceSetupInitializer ...@@ -45,7 +49,8 @@ class MultiDeviceSetupInitializer
secure_channel::SecureChannelClient* secure_channel_client, secure_channel::SecureChannelClient* secure_channel_client,
AuthTokenValidator* auth_token_validator, AuthTokenValidator* auth_token_validator,
std::unique_ptr<AndroidSmsAppHelperDelegate> std::unique_ptr<AndroidSmsAppHelperDelegate>
android_sms_app_helper_delegate); android_sms_app_helper_delegate,
const cryptauth::GcmDeviceInfoProvider* gcm_device_info_provider);
private: private:
static Factory* test_factory_; static Factory* test_factory_;
...@@ -60,7 +65,8 @@ class MultiDeviceSetupInitializer ...@@ -60,7 +65,8 @@ class MultiDeviceSetupInitializer
secure_channel::SecureChannelClient* secure_channel_client, secure_channel::SecureChannelClient* secure_channel_client,
AuthTokenValidator* auth_token_validator, AuthTokenValidator* auth_token_validator,
std::unique_ptr<AndroidSmsAppHelperDelegate> std::unique_ptr<AndroidSmsAppHelperDelegate>
android_sms_app_helper_delegate); android_sms_app_helper_delegate,
const cryptauth::GcmDeviceInfoProvider* gcm_device_info_provider);
// mojom::MultiDeviceSetup: // mojom::MultiDeviceSetup:
void SetAccountStatusChangeDelegate( void SetAccountStatusChangeDelegate(
...@@ -94,6 +100,7 @@ class MultiDeviceSetupInitializer ...@@ -94,6 +100,7 @@ class MultiDeviceSetupInitializer
secure_channel::SecureChannelClient* secure_channel_client_; secure_channel::SecureChannelClient* secure_channel_client_;
AuthTokenValidator* auth_token_validator_; AuthTokenValidator* auth_token_validator_;
std::unique_ptr<AndroidSmsAppHelperDelegate> android_sms_app_helper_delegate_; std::unique_ptr<AndroidSmsAppHelperDelegate> android_sms_app_helper_delegate_;
const cryptauth::GcmDeviceInfoProvider* gcm_device_info_provider_;
std::unique_ptr<mojom::MultiDeviceSetup> multidevice_setup_impl_; std::unique_ptr<mojom::MultiDeviceSetup> multidevice_setup_impl_;
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "chromeos/components/proximity_auth/logging/logging.h" #include "chromeos/components/proximity_auth/logging/logging.h"
#include "chromeos/services/multidevice_setup/account_status_change_delegate_notifier_impl.h" #include "chromeos/services/multidevice_setup/account_status_change_delegate_notifier_impl.h"
#include "chromeos/services/multidevice_setup/device_reenroller.h"
#include "chromeos/services/multidevice_setup/host_backend_delegate_impl.h" #include "chromeos/services/multidevice_setup/host_backend_delegate_impl.h"
#include "chromeos/services/multidevice_setup/host_verifier_impl.h" #include "chromeos/services/multidevice_setup/host_verifier_impl.h"
#include "chromeos/services/multidevice_setup/multidevice_setup_base.h" #include "chromeos/services/multidevice_setup/multidevice_setup_base.h"
...@@ -32,14 +33,16 @@ MultiDeviceSetupService::MultiDeviceSetupService( ...@@ -32,14 +33,16 @@ MultiDeviceSetupService::MultiDeviceSetupService(
secure_channel::SecureChannelClient* secure_channel_client, secure_channel::SecureChannelClient* secure_channel_client,
AuthTokenValidator* auth_token_validator, AuthTokenValidator* auth_token_validator,
std::unique_ptr<AndroidSmsAppHelperDelegate> std::unique_ptr<AndroidSmsAppHelperDelegate>
android_sms_app_helper_delegate) android_sms_app_helper_delegate,
const cryptauth::GcmDeviceInfoProvider* gcm_device_info_provider)
: multidevice_setup_( : multidevice_setup_(
MultiDeviceSetupInitializer::Factory::Get()->BuildInstance( MultiDeviceSetupInitializer::Factory::Get()->BuildInstance(
pref_service, pref_service,
device_sync_client, device_sync_client,
secure_channel_client, secure_channel_client,
auth_token_validator, auth_token_validator,
std::move(android_sms_app_helper_delegate))) {} std::move(android_sms_app_helper_delegate),
gcm_device_info_provider)) {}
MultiDeviceSetupService::~MultiDeviceSetupService() = default; MultiDeviceSetupService::~MultiDeviceSetupService() = default;
......
...@@ -14,6 +14,10 @@ ...@@ -14,6 +14,10 @@
class PrefService; class PrefService;
class PrefRegistrySimple; class PrefRegistrySimple;
namespace cryptauth {
class GcmDeviceInfoProvider;
} // namespace cryptauth
namespace chromeos { namespace chromeos {
namespace device_sync { namespace device_sync {
...@@ -41,7 +45,8 @@ class MultiDeviceSetupService : public service_manager::Service { ...@@ -41,7 +45,8 @@ class MultiDeviceSetupService : public service_manager::Service {
secure_channel::SecureChannelClient* secure_channel_client, secure_channel::SecureChannelClient* secure_channel_client,
AuthTokenValidator* auth_token_validator, AuthTokenValidator* auth_token_validator,
std::unique_ptr<AndroidSmsAppHelperDelegate> std::unique_ptr<AndroidSmsAppHelperDelegate>
android_sms_app_helper_delegate); android_sms_app_helper_delegate,
const cryptauth::GcmDeviceInfoProvider* gcm_device_info_provider);
~MultiDeviceSetupService() override; ~MultiDeviceSetupService() override;
static void RegisterProfilePrefs(PrefRegistrySimple* registry); static void RegisterProfilePrefs(PrefRegistrySimple* registry);
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "chromeos/services/multidevice_setup/public/mojom/constants.mojom.h" #include "chromeos/services/multidevice_setup/public/mojom/constants.mojom.h"
#include "chromeos/services/multidevice_setup/public/mojom/multidevice_setup.mojom.h" #include "chromeos/services/multidevice_setup/public/mojom/multidevice_setup.mojom.h"
#include "chromeos/services/secure_channel/public/cpp/client/fake_secure_channel_client.h" #include "chromeos/services/secure_channel/public/cpp/client/fake_secure_channel_client.h"
#include "components/cryptauth/fake_gcm_device_info_provider.h"
#include "components/cryptauth/remote_device_test_util.h" #include "components/cryptauth/remote_device_test_util.h"
#include "components/sync_preferences/testing_pref_service_syncable.h" #include "components/sync_preferences/testing_pref_service_syncable.h"
#include "services/service_manager/public/cpp/test/test_connector_factory.h" #include "services/service_manager/public/cpp/test/test_connector_factory.h"
...@@ -39,13 +40,16 @@ class FakeMultiDeviceSetupFactory : public MultiDeviceSetupImpl::Factory { ...@@ -39,13 +40,16 @@ class FakeMultiDeviceSetupFactory : public MultiDeviceSetupImpl::Factory {
device_sync::FakeDeviceSyncClient* expected_device_sync_client, device_sync::FakeDeviceSyncClient* expected_device_sync_client,
secure_channel::FakeSecureChannelClient* expected_secure_channel_client, secure_channel::FakeSecureChannelClient* expected_secure_channel_client,
FakeAuthTokenValidator* expected_auth_token_validator, FakeAuthTokenValidator* expected_auth_token_validator,
FakeAndroidSmsAppHelperDelegate* expected_android_sms_app_helper_delegate) FakeAndroidSmsAppHelperDelegate* expected_android_sms_app_helper_delegate,
const cryptauth::FakeGcmDeviceInfoProvider*
expected_gcm_device_info_provider)
: expected_testing_pref_service_(expected_testing_pref_service), : expected_testing_pref_service_(expected_testing_pref_service),
expected_device_sync_client_(expected_device_sync_client), expected_device_sync_client_(expected_device_sync_client),
expected_secure_channel_client_(expected_secure_channel_client), expected_secure_channel_client_(expected_secure_channel_client),
expected_auth_token_validator_(expected_auth_token_validator), expected_auth_token_validator_(expected_auth_token_validator),
expected_android_sms_app_helper_delegate_( expected_android_sms_app_helper_delegate_(
expected_android_sms_app_helper_delegate) {} expected_android_sms_app_helper_delegate),
expected_gcm_device_info_provider_(expected_gcm_device_info_provider) {}
~FakeMultiDeviceSetupFactory() override = default; ~FakeMultiDeviceSetupFactory() override = default;
...@@ -58,7 +62,9 @@ class FakeMultiDeviceSetupFactory : public MultiDeviceSetupImpl::Factory { ...@@ -58,7 +62,9 @@ class FakeMultiDeviceSetupFactory : public MultiDeviceSetupImpl::Factory {
secure_channel::SecureChannelClient* secure_channel_client, secure_channel::SecureChannelClient* secure_channel_client,
AuthTokenValidator* auth_token_validator, AuthTokenValidator* auth_token_validator,
std::unique_ptr<AndroidSmsAppHelperDelegate> std::unique_ptr<AndroidSmsAppHelperDelegate>
android_sms_app_helper_delegate) override { android_sms_app_helper_delegate,
const cryptauth::GcmDeviceInfoProvider* gcm_device_info_provider)
override {
EXPECT_FALSE(instance_); EXPECT_FALSE(instance_);
EXPECT_EQ(expected_testing_pref_service_, pref_service); EXPECT_EQ(expected_testing_pref_service_, pref_service);
EXPECT_EQ(expected_device_sync_client_, device_sync_client); EXPECT_EQ(expected_device_sync_client_, device_sync_client);
...@@ -66,6 +72,7 @@ class FakeMultiDeviceSetupFactory : public MultiDeviceSetupImpl::Factory { ...@@ -66,6 +72,7 @@ class FakeMultiDeviceSetupFactory : public MultiDeviceSetupImpl::Factory {
EXPECT_EQ(expected_auth_token_validator_, auth_token_validator); EXPECT_EQ(expected_auth_token_validator_, auth_token_validator);
EXPECT_EQ(expected_android_sms_app_helper_delegate_, EXPECT_EQ(expected_android_sms_app_helper_delegate_,
android_sms_app_helper_delegate.get()); android_sms_app_helper_delegate.get());
EXPECT_EQ(expected_gcm_device_info_provider_, gcm_device_info_provider);
auto instance = std::make_unique<FakeMultiDeviceSetup>(); auto instance = std::make_unique<FakeMultiDeviceSetup>();
instance_ = instance.get(); instance_ = instance.get();
...@@ -77,6 +84,8 @@ class FakeMultiDeviceSetupFactory : public MultiDeviceSetupImpl::Factory { ...@@ -77,6 +84,8 @@ class FakeMultiDeviceSetupFactory : public MultiDeviceSetupImpl::Factory {
secure_channel::FakeSecureChannelClient* expected_secure_channel_client_; secure_channel::FakeSecureChannelClient* expected_secure_channel_client_;
FakeAuthTokenValidator* expected_auth_token_validator_; FakeAuthTokenValidator* expected_auth_token_validator_;
FakeAndroidSmsAppHelperDelegate* expected_android_sms_app_helper_delegate_; FakeAndroidSmsAppHelperDelegate* expected_android_sms_app_helper_delegate_;
const cryptauth::FakeGcmDeviceInfoProvider*
expected_gcm_device_info_provider_;
FakeMultiDeviceSetup* instance_ = nullptr; FakeMultiDeviceSetup* instance_ = nullptr;
...@@ -105,12 +114,16 @@ class MultiDeviceSetupServiceTest : public testing::Test { ...@@ -105,12 +114,16 @@ class MultiDeviceSetupServiceTest : public testing::Test {
std::make_unique<FakeAndroidSmsAppHelperDelegate>(); std::make_unique<FakeAndroidSmsAppHelperDelegate>();
fake_android_sms_app_helper_delegate_ = fake_android_sms_app_helper_delegate_ =
fake_android_sms_app_helper_delegate.get(); fake_android_sms_app_helper_delegate.get();
fake_gcm_device_info_provider_ =
std::make_unique<cryptauth::FakeGcmDeviceInfoProvider>(
cryptauth::GcmDeviceInfo());
fake_multidevice_setup_factory_ = fake_multidevice_setup_factory_ =
std::make_unique<FakeMultiDeviceSetupFactory>( std::make_unique<FakeMultiDeviceSetupFactory>(
test_pref_service_.get(), fake_device_sync_client_.get(), test_pref_service_.get(), fake_device_sync_client_.get(),
fake_secure_channel_client_.get(), fake_auth_token_validator_.get(), fake_secure_channel_client_.get(), fake_auth_token_validator_.get(),
fake_android_sms_app_helper_delegate_); fake_android_sms_app_helper_delegate_,
fake_gcm_device_info_provider_.get());
MultiDeviceSetupImpl::Factory::SetFactoryForTesting( MultiDeviceSetupImpl::Factory::SetFactoryForTesting(
fake_multidevice_setup_factory_.get()); fake_multidevice_setup_factory_.get());
...@@ -120,7 +133,8 @@ class MultiDeviceSetupServiceTest : public testing::Test { ...@@ -120,7 +133,8 @@ class MultiDeviceSetupServiceTest : public testing::Test {
test_pref_service_.get(), fake_device_sync_client_.get(), test_pref_service_.get(), fake_device_sync_client_.get(),
fake_secure_channel_client_.get(), fake_secure_channel_client_.get(),
fake_auth_token_validator_.get(), fake_auth_token_validator_.get(),
std::move(fake_android_sms_app_helper_delegate))); std::move(fake_android_sms_app_helper_delegate),
fake_gcm_device_info_provider_.get()));
auto connector = connector_factory_->CreateConnector(); auto connector = connector_factory_->CreateConnector();
connector->BindInterface(mojom::kServiceName, &multidevice_setup_ptr_); connector->BindInterface(mojom::kServiceName, &multidevice_setup_ptr_);
...@@ -178,6 +192,8 @@ class MultiDeviceSetupServiceTest : public testing::Test { ...@@ -178,6 +192,8 @@ class MultiDeviceSetupServiceTest : public testing::Test {
fake_secure_channel_client_; fake_secure_channel_client_;
std::unique_ptr<FakeAuthTokenValidator> fake_auth_token_validator_; std::unique_ptr<FakeAuthTokenValidator> fake_auth_token_validator_;
FakeAndroidSmsAppHelperDelegate* fake_android_sms_app_helper_delegate_; FakeAndroidSmsAppHelperDelegate* fake_android_sms_app_helper_delegate_;
std::unique_ptr<cryptauth::FakeGcmDeviceInfoProvider>
fake_gcm_device_info_provider_;
std::unique_ptr<FakeMultiDeviceSetupFactory> fake_multidevice_setup_factory_; std::unique_ptr<FakeMultiDeviceSetupFactory> fake_multidevice_setup_factory_;
......
...@@ -47,7 +47,9 @@ class FakeMultiDeviceSetupInitializerFactory ...@@ -47,7 +47,9 @@ class FakeMultiDeviceSetupInitializerFactory
secure_channel::SecureChannelClient* secure_channel_client, secure_channel::SecureChannelClient* secure_channel_client,
AuthTokenValidator* auth_token_validator, AuthTokenValidator* auth_token_validator,
std::unique_ptr<AndroidSmsAppHelperDelegate> std::unique_ptr<AndroidSmsAppHelperDelegate>
android_sms_app_helper_delegate) override { android_sms_app_helper_delegate,
const cryptauth::GcmDeviceInfoProvider* gcm_device_info_provider)
override {
EXPECT_TRUE(fake_multidevice_setup_); EXPECT_TRUE(fake_multidevice_setup_);
return std::move(fake_multidevice_setup_); return std::move(fake_multidevice_setup_);
} }
...@@ -122,7 +124,8 @@ class MultiDeviceSetupClientImplTest : public testing::Test { ...@@ -122,7 +124,8 @@ class MultiDeviceSetupClientImplTest : public testing::Test {
auto multidevice_setup_service = std::make_unique<MultiDeviceSetupService>( auto multidevice_setup_service = std::make_unique<MultiDeviceSetupService>(
nullptr /* pref_service */, nullptr /* device_sync_client */, nullptr /* pref_service */, nullptr /* device_sync_client */,
nullptr /* secure_channel_client */, nullptr /* auth_token_validator */, nullptr /* secure_channel_client */, nullptr /* auth_token_validator */,
nullptr /* android_sms_app_helper_delegate */); nullptr /* android_sms_app_helper_delegate */,
nullptr /* gcm_device_info_provider */);
connector_factory_ = connector_factory_ =
service_manager::TestConnectorFactory::CreateForUniqueService( service_manager::TestConnectorFactory::CreateForUniqueService(
......
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