Commit 3fbccfbc authored by Kyle Horimoto's avatar Kyle Horimoto Committed by Commit Bot

[CrOS MultiDevice] Adjust protos to work around Apiary issue.

Some Proto messages are sent to Apiary endpoints, which translate Proto
enums to strings instead of leaving them as enums. Though this doesn't
interact normally with Protos, this behavior has been present in Apiary
from the beginning and is not considered a bug. See this change for
details: https://critique.corp.google.com/#review/187680679.

Thus, when communicating with those endpoints, the proto values should
be converted from enums to strings when send messages to Apiary and
should be converted from strings to enumsm when receiving messages from
Apiary.

This CL adds these conversion functions and integrates them throughout
CryptAuth.

Bug: 824568
Change-Id: Icc2367a6a325fe9da42905f9456d2b2103c5eb25
Reviewed-on: https://chromium-review.googlesource.com/1145588
Commit-Queue: Kyle Horimoto <khorimoto@chromium.org>
Reviewed-by: default avatarJeremy Klein <jlklein@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577027}
parent a9b67302
......@@ -23,7 +23,7 @@
#include "chromeos/components/proximity_auth/remote_status_update.h"
#include "components/cryptauth/cryptauth_enrollment_manager.h"
#include "components/cryptauth/proto/cryptauth_api.pb.h"
#include "components/cryptauth/proto/enum_string_util.h"
#include "components/cryptauth/proto/enum_util.h"
#include "components/cryptauth/remote_device_loader.h"
#include "components/cryptauth/remote_device_ref.h"
#include "components/cryptauth/secure_context.h"
......@@ -660,11 +660,13 @@ ProximityAuthWebUIHandler::ExternalDeviceInfoToDictionary(
dictionary->SetBoolean(
kExternalDeviceUnlockKey,
base::ContainsValue(device_info.enabled_software_features(),
cryptauth::SoftwareFeature::EASY_UNLOCK_HOST));
cryptauth::SoftwareFeatureEnumToString(
cryptauth::SoftwareFeature::EASY_UNLOCK_HOST)));
dictionary->SetBoolean(
kExternalDeviceMobileHotspot,
base::ContainsValue(device_info.supported_software_features(),
cryptauth::SoftwareFeature::MAGIC_TETHER_HOST));
cryptauth::SoftwareFeatureEnumToString(
cryptauth::SoftwareFeature::MAGIC_TETHER_HOST)));
dictionary->SetBoolean(kExternalDeviceIsArcPlusPlusEnrollment,
device_info.arc_plus_plus());
dictionary->SetBoolean(kExternalDeviceIsPixelPhone,
......
......@@ -217,6 +217,7 @@ source_set("unit_tests") {
":test_support",
"//base/test:test_support",
"//components/cryptauth/ble:unit_tests",
"//components/cryptauth/proto:util",
"//components/gcm_driver:test_support",
"//components/prefs:test_support",
"//google_apis:test_support",
......
......@@ -17,6 +17,7 @@
#include "chromeos/components/proximity_auth/logging/logging.h"
#include "components/cryptauth/cryptauth_client.h"
#include "components/cryptauth/pref_names.h"
#include "components/cryptauth/proto/enum_util.h"
#include "components/cryptauth/software_feature_state.h"
#include "components/cryptauth/sync_scheduler_impl.h"
#include "components/prefs/pref_registry_simple.h"
......@@ -109,20 +110,22 @@ void RecordDeviceSyncSoftwareFeaturesResult(bool success) {
// value that can be stored in user prefs.
std::unique_ptr<base::DictionaryValue>
SupportedAndEnabledSoftwareFeaturesToDictionaryValue(
const google::protobuf::RepeatedField<int>& supported_software_features,
const google::protobuf::RepeatedField<int>& enabled_software_features,
const google::protobuf::RepeatedPtrField<std::string>&
supported_software_features,
const google::protobuf::RepeatedPtrField<std::string>&
enabled_software_features,
bool legacy_unlock_key,
bool legacy_mobile_hotspot_supported) {
std::unique_ptr<base::DictionaryValue> dictionary =
std::make_unique<base::DictionaryValue>();
for (const auto& supported_software_feature : supported_software_features) {
dictionary->SetInteger(std::to_string(supported_software_feature),
dictionary->SetInteger(supported_software_feature,
static_cast<int>(SoftwareFeatureState::kSupported));
}
for (const auto& enabled_software_feature : enabled_software_features) {
std::string software_feature_key = std::to_string(enabled_software_feature);
std::string software_feature_key = enabled_software_feature;
int software_feature_state;
if (!dictionary->GetInteger(software_feature_key,
......@@ -148,13 +151,15 @@ SupportedAndEnabledSoftwareFeaturesToDictionaryValue(
// software features, and only serving the deprecated booleans.
int software_feature_state;
std::string software_feature_key;
software_feature_key = std::to_string(SoftwareFeature::EASY_UNLOCK_HOST);
software_feature_key =
SoftwareFeatureEnumToString(cryptauth::SoftwareFeature::EASY_UNLOCK_HOST);
if (legacy_unlock_key &&
!dictionary->GetInteger(software_feature_key, &software_feature_state)) {
dictionary->SetInteger(software_feature_key,
static_cast<int>(SoftwareFeatureState::kEnabled));
}
software_feature_key = std::to_string(SoftwareFeature::MAGIC_TETHER_HOST);
software_feature_key = SoftwareFeatureEnumToString(
cryptauth::SoftwareFeature::MAGIC_TETHER_HOST);
if (legacy_mobile_hotspot_supported &&
!dictionary->GetInteger(software_feature_key, &software_feature_state)) {
dictionary->SetInteger(software_feature_key,
......@@ -301,14 +306,12 @@ void AddSoftwareFeaturesToExternalDevice(
continue;
}
SoftwareFeature software_feature =
static_cast<SoftwareFeature>(std::stoi(it.first));
switch (static_cast<SoftwareFeatureState>(software_feature_state)) {
case SoftwareFeatureState::kEnabled:
external_device->add_enabled_software_features(software_feature);
external_device->add_enabled_software_features(it.first);
FALLTHROUGH;
case SoftwareFeatureState::kSupported:
external_device->add_supported_software_features(software_feature);
external_device->add_supported_software_features(it.first);
break;
default:
break;
......@@ -321,22 +324,25 @@ void AddSoftwareFeaturesToExternalDevice(
// software features. To work around this, these pref values are migrated to
// software features locally.
if (old_unlock_key_value_from_prefs) {
if (!base::ContainsValue(external_device->supported_software_features(),
SoftwareFeature::EASY_UNLOCK_HOST)) {
if (!base::ContainsValue(
external_device->supported_software_features(),
SoftwareFeatureEnumToString(SoftwareFeature::EASY_UNLOCK_HOST))) {
external_device->add_supported_software_features(
SoftwareFeature::EASY_UNLOCK_HOST);
SoftwareFeatureEnumToString(SoftwareFeature::EASY_UNLOCK_HOST));
}
if (!base::ContainsValue(external_device->enabled_software_features(),
SoftwareFeature::EASY_UNLOCK_HOST)) {
if (!base::ContainsValue(
external_device->enabled_software_features(),
SoftwareFeatureEnumToString(SoftwareFeature::EASY_UNLOCK_HOST))) {
external_device->add_enabled_software_features(
SoftwareFeature::EASY_UNLOCK_HOST);
SoftwareFeatureEnumToString(SoftwareFeature::EASY_UNLOCK_HOST));
}
}
if (old_mobile_hotspot_supported_from_prefs) {
if (!base::ContainsValue(external_device->supported_software_features(),
SoftwareFeature::MAGIC_TETHER_HOST)) {
if (!base::ContainsValue(
external_device->supported_software_features(),
SoftwareFeatureEnumToString(SoftwareFeature::MAGIC_TETHER_HOST))) {
external_device->add_supported_software_features(
SoftwareFeature::MAGIC_TETHER_HOST);
SoftwareFeatureEnumToString(SoftwareFeature::MAGIC_TETHER_HOST));
}
}
}
......@@ -561,8 +567,9 @@ std::vector<ExternalDeviceInfo> CryptAuthDeviceManagerImpl::GetUnlockKeys()
const {
std::vector<ExternalDeviceInfo> unlock_keys;
for (const auto& device : synced_devices_) {
if (base::ContainsValue(device.enabled_software_features(),
SoftwareFeature::EASY_UNLOCK_HOST)) {
if (base::ContainsValue(
device.enabled_software_features(),
SoftwareFeatureEnumToString(SoftwareFeature::EASY_UNLOCK_HOST))) {
unlock_keys.push_back(device);
}
}
......@@ -573,8 +580,9 @@ std::vector<ExternalDeviceInfo> CryptAuthDeviceManagerImpl::GetPixelUnlockKeys()
const {
std::vector<ExternalDeviceInfo> unlock_keys;
for (const auto& device : synced_devices_) {
if (base::ContainsValue(device.enabled_software_features(),
SoftwareFeature::EASY_UNLOCK_HOST) &&
if (base::ContainsValue(
device.enabled_software_features(),
SoftwareFeatureEnumToString(SoftwareFeature::EASY_UNLOCK_HOST)) &&
device.pixel_phone()) {
unlock_keys.push_back(device);
}
......@@ -586,8 +594,9 @@ std::vector<ExternalDeviceInfo> CryptAuthDeviceManagerImpl::GetTetherHosts()
const {
std::vector<ExternalDeviceInfo> tether_hosts;
for (const auto& device : synced_devices_) {
if (base::ContainsValue(device.supported_software_features(),
SoftwareFeature::MAGIC_TETHER_HOST)) {
if (base::ContainsValue(
device.supported_software_features(),
SoftwareFeatureEnumToString(SoftwareFeature::MAGIC_TETHER_HOST))) {
tether_hosts.push_back(device);
}
}
......@@ -598,8 +607,9 @@ std::vector<ExternalDeviceInfo>
CryptAuthDeviceManagerImpl::GetPixelTetherHosts() const {
std::vector<ExternalDeviceInfo> tether_hosts;
for (const auto& device : synced_devices_) {
if (base::ContainsValue(device.supported_software_features(),
SoftwareFeature::MAGIC_TETHER_HOST) &&
if (base::ContainsValue(
device.supported_software_features(),
SoftwareFeatureEnumToString(SoftwareFeature::MAGIC_TETHER_HOST)) &&
device.pixel_phone())
tether_hosts.push_back(device);
}
......
......@@ -15,7 +15,7 @@
#include "chromeos/components/proximity_auth/logging/logging.h"
#include "components/cryptauth/cryptauth_enroller.h"
#include "components/cryptauth/pref_names.h"
#include "components/cryptauth/proto/enum_string_util.h"
#include "components/cryptauth/proto/enum_util.h"
#include "components/cryptauth/secure_message_delegate.h"
#include "components/cryptauth/sync_scheduler_impl.h"
#include "components/prefs/pref_registry_simple.h"
......
......@@ -13,8 +13,8 @@ proto_library("proto") {
static_library("util") {
sources = [
"enum_string_util.cc",
"enum_string_util.h",
"enum_util.cc",
"enum_util.h",
]
public_deps = [
......
......@@ -25,6 +25,7 @@ message DeviceClassifier {
optional string device_software_package = 19;
// Device type/platform.
// TODO(khorimoto): Change this to a string so it works with Apiary endpoints.
optional DeviceType device_type = 32 [default = UNKNOWN];
}
......@@ -90,6 +91,7 @@ message ExternalDeviceInfo {
optional bool mobile_hotspot_supported = 7 [ default = false ];
// The type of the device (e.g. Android vs iOS).
// TODO(khorimoto): Change this to a string so it works with Apiary endpoints.
optional DeviceType device_type = 8 [ default = UNKNOWN ];
// A list of seeds for EID BLE advertisements targeting this device.
......@@ -102,11 +104,11 @@ message ExternalDeviceInfo {
optional bool pixel_phone = 11 [default = false];
// A list of multi-device software features supported by the device.
repeated SoftwareFeature supported_software_features = 12;
repeated string supported_software_features = 12;
// A list of multi-device software features currently enabled (active) on the
// device.
repeated SoftwareFeature enabled_software_features = 13;
repeated string enabled_software_features = 13;
}
// Determine if the calling device is allowed to promote the SmartLock
......@@ -163,7 +165,7 @@ message FindEligibleUnlockDevicesRequest {
// The feature for which eligibility should be checked. Note that this RPC is
// overloaded instead of adding new RPCs due to the ongoing V2 transition.
// See go/unified-better-together-cryptauth for more details.
optional SoftwareFeature feature = 8 [default = EASY_UNLOCK_HOST];
optional string feature = 8 [default = "easyUnlockHost"];
}
// Response containing a list of devices that could be made Unlock Keys
......@@ -290,6 +292,7 @@ message GcmDeviceInfo {
optional string device_manufacturer = 31;
// Used to indicate which type of device this is.
// TODO(khorimoto): Change this to a string so it works with Apiary endpoints.
optional DeviceType device_type = 32 [default = ANDROIDOS];
// Fields corresponding to screenlock type/features and hardware features
......@@ -606,7 +609,7 @@ message ToggleEasyUnlockRequest {
// The feature for which enabled state should be toggled. Note that this RPC
// is overloaded instead of adding new RPCs due to the ongoing V2 transition.
// See go/unified-better-together-cryptauth for more details.
optional SoftwareFeature feature = 5 [default = EASY_UNLOCK_HOST];
optional string feature = 5 [default = "easyUnlockHost"];
// True if enabling one device for this feature should disable all others on
// the account.
......
// 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 COMPONENTS_CRYPTAUTH_PROTO_ENUM_STRING_UTIL_H_
#define COMPONENTS_CRYPTAUTH_PROTO_ENUM_STRING_UTIL_H_
#include <ostream>
#include "components/cryptauth/proto/cryptauth_api.pb.h"
namespace cryptauth {
std::ostream& operator<<(std::ostream& stream,
const SoftwareFeature& software_fature);
} // namespace cryptauth
#endif // COMPONENTS_CRYPTAUTH_PROTO_ENUM_STRING_UTIL_H_
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/cryptauth/proto/enum_string_util.h"
#include "components/cryptauth/proto/enum_util.h"
namespace cryptauth {
......@@ -40,4 +40,50 @@ std::ostream& operator<<(std::ostream& stream,
return stream;
}
cryptauth::SoftwareFeature SoftwareFeatureStringToEnum(
const std::string& software_feature_as_string) {
if (software_feature_as_string == "betterTogetherHost")
return cryptauth::SoftwareFeature::BETTER_TOGETHER_HOST;
if (software_feature_as_string == "betterTogetherClient")
return cryptauth::SoftwareFeature::BETTER_TOGETHER_CLIENT;
if (software_feature_as_string == "easyUnlockHost")
return cryptauth::SoftwareFeature::EASY_UNLOCK_HOST;
if (software_feature_as_string == "easyUnlockClient")
return cryptauth::SoftwareFeature::EASY_UNLOCK_CLIENT;
if (software_feature_as_string == "magicTetherHost")
return cryptauth::SoftwareFeature::MAGIC_TETHER_HOST;
if (software_feature_as_string == "magicTetherClient")
return cryptauth::SoftwareFeature::MAGIC_TETHER_CLIENT;
if (software_feature_as_string == "smsConnectHost")
return cryptauth::SoftwareFeature::SMS_CONNECT_HOST;
if (software_feature_as_string == "smsConnectClient")
return cryptauth::SoftwareFeature::SMS_CONNECT_CLIENT;
return cryptauth::SoftwareFeature::UNKNOWN_FEATURE;
}
std::string SoftwareFeatureEnumToString(
cryptauth::SoftwareFeature software_feature) {
switch (software_feature) {
case SoftwareFeature::BETTER_TOGETHER_HOST:
return "betterTogetherHost";
case SoftwareFeature::BETTER_TOGETHER_CLIENT:
return "betterTogetherClient";
case SoftwareFeature::EASY_UNLOCK_HOST:
return "easyUnlockHost";
case SoftwareFeature::EASY_UNLOCK_CLIENT:
return "easyUnlockClient";
case SoftwareFeature::MAGIC_TETHER_HOST:
return "magicTetherHost";
case SoftwareFeature::MAGIC_TETHER_CLIENT:
return "magicTetherClient";
case SoftwareFeature::SMS_CONNECT_HOST:
return "smsConnectHost";
case SoftwareFeature::SMS_CONNECT_CLIENT:
return "smsConnectClient";
default:
return "unknownFeature";
}
}
} // namespace cryptauth
// 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 COMPONENTS_CRYPTAUTH_PROTO_ENUM_UTIL_H_
#define COMPONENTS_CRYPTAUTH_PROTO_ENUM_UTIL_H_
#include <ostream>
#include "components/cryptauth/proto/cryptauth_api.pb.h"
namespace cryptauth {
std::ostream& operator<<(std::ostream& stream,
const SoftwareFeature& software_fature);
// Converts the string representation of a SoftwareFeature to its associated
// Proto enum value. Some Proto messages are sent to Apiary endpoints, which
// translate Proto enums to strings instead of leaving them as enums. Thus, when
// communicating with those endpoints, the proto values should be converted from
// enums to strings before sending them.
cryptauth::SoftwareFeature SoftwareFeatureStringToEnum(
const std::string& software_feature_as_string);
// Converts a Proto enum SoftwareFeature to its associated string
// representation. Some Proto messages are sent to Apiary endpoints, which
// translate Proto enums to strings instead of leaving them as enums. Thus, when
// communicating with those endpoints, the proto values should be converted from
// strings to enums after receiving them.
std::string SoftwareFeatureEnumToString(
cryptauth::SoftwareFeature software_feature);
} // namespace cryptauth
#endif // COMPONENTS_CRYPTAUTH_PROTO_ENUM_UTIL_H_
......@@ -11,10 +11,13 @@
#include "base/bind.h"
#include "base/memory/ptr_util.h"
#include "chromeos/components/proximity_auth/logging/logging.h"
#include "components/cryptauth/proto/enum_util.h"
#include "components/cryptauth/remote_device.h"
#include "components/cryptauth/remote_device_ref.h"
#include "components/cryptauth/secure_message_delegate.h"
namespace cryptauth {
namespace {
std::map<cryptauth::SoftwareFeature, cryptauth::SoftwareFeatureState>
......@@ -23,12 +26,14 @@ GetSoftwareFeatureToStateMap(const cryptauth::ExternalDeviceInfo& device) {
software_feature_to_state_map;
for (int i = 0; i < device.supported_software_features_size(); ++i) {
software_feature_to_state_map[device.supported_software_features(i)] =
software_feature_to_state_map[SoftwareFeatureStringToEnum(
device.supported_software_features(i))] =
cryptauth::SoftwareFeatureState::kSupported;
}
for (int i = 0; i < device.enabled_software_features_size(); ++i) {
software_feature_to_state_map[device.enabled_software_features(i)] =
software_feature_to_state_map[SoftwareFeatureStringToEnum(
device.enabled_software_features(i))] =
cryptauth::SoftwareFeatureState::kEnabled;
}
......@@ -37,8 +42,6 @@ GetSoftwareFeatureToStateMap(const cryptauth::ExternalDeviceInfo& device) {
} // namespace
namespace cryptauth {
// static
RemoteDeviceLoader::Factory* RemoteDeviceLoader::Factory::factory_instance_ =
nullptr;
......
......@@ -12,6 +12,7 @@
#include "base/bind.h"
#include "base/macros.h"
#include "components/cryptauth/fake_secure_message_delegate.h"
#include "components/cryptauth/proto/enum_util.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -148,10 +149,14 @@ TEST_F(CryptAuthRemoteDeviceLoaderTest, SoftwareFeatures) {
BETTER_TOGETHER_HOST};
cryptauth::ExternalDeviceInfo first = CreateDeviceInfo("0");
for (const auto& software_feature : kSupportedSoftwareFeatures)
first.add_supported_software_features(software_feature);
for (const auto& software_feature : kEnabledSoftwareFeatures)
first.add_enabled_software_features(software_feature);
for (const auto& software_feature : kSupportedSoftwareFeatures) {
first.add_supported_software_features(
SoftwareFeatureEnumToString(software_feature));
}
for (const auto& software_feature : kEnabledSoftwareFeatures) {
first.add_enabled_software_features(
SoftwareFeatureEnumToString(software_feature));
}
std::vector<cryptauth::ExternalDeviceInfo> device_infos{first};
......
......@@ -10,6 +10,7 @@
#include "base/memory/ptr_util.h"
#include "base/no_destructor.h"
#include "components/cryptauth/proto/cryptauth_api.pb.h"
#include "components/cryptauth/proto/enum_util.h"
namespace cryptauth {
......@@ -79,7 +80,8 @@ void SoftwareFeatureManagerImpl::SetSoftwareFeatureState(
// Note: For legacy reasons, this proto message mentions "ToggleEasyUnlock"
// instead of "SetSoftwareFeature" in its name.
auto request = std::make_unique<ToggleEasyUnlockRequest>();
request->set_feature(software_feature);
request->set_feature(
cryptauth::SoftwareFeatureEnumToString(software_feature));
request->set_enable(enabled);
request->set_is_exclusive(enabled && is_exclusive);
......@@ -105,7 +107,8 @@ void SoftwareFeatureManagerImpl::FindEligibleDevices(
// Note: For legacy reasons, this proto message mentions "UnlockDevices"
// instead of "MultiDeviceHosts" in its name.
auto request = std::make_unique<FindEligibleUnlockDevicesRequest>();
request->set_feature(software_feature);
request->set_feature(
cryptauth::SoftwareFeatureEnumToString(software_feature));
pending_requests_.emplace(std::make_unique<Request>(
std::move(request), success_callback, error_callback));
......
......@@ -7,6 +7,7 @@
#include "base/bind.h"
#include "base/macros.h"
#include "components/cryptauth/mock_cryptauth_client.h"
#include "components/cryptauth/proto/enum_util.h"
#include "components/cryptauth/remote_device_ref.h"
#include "components/cryptauth/remote_device_test_util.h"
#include "testing/gmock/include/gmock/gmock.h"
......@@ -263,28 +264,30 @@ TEST_F(CryptAuthSoftwareFeatureManagerImplTest, TestOrderUponMultipleRequests) {
false /* enable */);
FindEligibleDevices(SoftwareFeature::BETTER_TOGETHER_CLIENT);
EXPECT_EQ(SoftwareFeature::BETTER_TOGETHER_HOST,
EXPECT_EQ(SoftwareFeatureEnumToString(SoftwareFeature::BETTER_TOGETHER_HOST),
last_toggle_request_.feature());
EXPECT_EQ(true, last_toggle_request_.enable());
EXPECT_EQ(false, last_toggle_request_.is_exclusive());
InvokeSetSoftwareFeatureCallback();
EXPECT_EQ(Result::kSuccess, GetResultAndReset());
EXPECT_EQ(SoftwareFeature::BETTER_TOGETHER_HOST,
EXPECT_EQ(SoftwareFeatureEnumToString(SoftwareFeature::BETTER_TOGETHER_HOST),
last_find_request_.feature());
InvokeFindEligibleDevicesCallback(CreateFindEligibleUnlockDevicesResponse());
EXPECT_EQ(Result::kSuccess, GetResultAndReset());
VerifyDeviceEligibility();
EXPECT_EQ(SoftwareFeature::BETTER_TOGETHER_CLIENT,
last_toggle_request_.feature());
EXPECT_EQ(
SoftwareFeatureEnumToString(SoftwareFeature::BETTER_TOGETHER_CLIENT),
last_toggle_request_.feature());
EXPECT_EQ(false, last_toggle_request_.enable());
EXPECT_EQ(false, last_toggle_request_.is_exclusive());
InvokeSetSoftwareFeatureCallback();
EXPECT_EQ(Result::kSuccess, GetResultAndReset());
EXPECT_EQ(SoftwareFeature::BETTER_TOGETHER_CLIENT,
last_find_request_.feature());
EXPECT_EQ(
SoftwareFeatureEnumToString(SoftwareFeature::BETTER_TOGETHER_CLIENT),
last_find_request_.feature());
InvokeFindEligibleDevicesCallback(CreateFindEligibleUnlockDevicesResponse());
EXPECT_EQ(Result::kSuccess, GetResultAndReset());
VerifyDeviceEligibility();
......@@ -302,21 +305,22 @@ TEST_F(CryptAuthSoftwareFeatureManagerImplTest,
test_eligible_external_devices_infos_[2],
true /* enable */);
EXPECT_EQ(SoftwareFeature::BETTER_TOGETHER_HOST,
EXPECT_EQ(SoftwareFeatureEnumToString(SoftwareFeature::BETTER_TOGETHER_HOST),
last_toggle_request_.feature());
EXPECT_EQ(true, last_toggle_request_.enable());
EXPECT_EQ(false, last_toggle_request_.is_exclusive());
InvokeErrorCallback();
EXPECT_EQ(Result::kErrorSettingFeature, GetResultAndReset());
EXPECT_EQ(SoftwareFeature::BETTER_TOGETHER_CLIENT,
last_toggle_request_.feature());
EXPECT_EQ(
SoftwareFeatureEnumToString(SoftwareFeature::BETTER_TOGETHER_CLIENT),
last_toggle_request_.feature());
EXPECT_EQ(false, last_toggle_request_.enable());
EXPECT_EQ(false, last_toggle_request_.is_exclusive());
InvokeSetSoftwareFeatureCallback();
EXPECT_EQ(Result::kSuccess, GetResultAndReset());
EXPECT_EQ(SoftwareFeature::BETTER_TOGETHER_HOST,
EXPECT_EQ(SoftwareFeatureEnumToString(SoftwareFeature::BETTER_TOGETHER_HOST),
last_toggle_request_.feature());
EXPECT_EQ(true, last_toggle_request_.enable());
EXPECT_EQ(false, last_toggle_request_.is_exclusive());
......@@ -330,18 +334,19 @@ TEST_F(CryptAuthSoftwareFeatureManagerImplTest,
FindEligibleDevices(SoftwareFeature::BETTER_TOGETHER_CLIENT);
FindEligibleDevices(SoftwareFeature::BETTER_TOGETHER_HOST);
EXPECT_EQ(SoftwareFeature::BETTER_TOGETHER_HOST,
EXPECT_EQ(SoftwareFeatureEnumToString(SoftwareFeature::BETTER_TOGETHER_HOST),
last_find_request_.feature());
InvokeFindEligibleDevicesCallback(CreateFindEligibleUnlockDevicesResponse());
EXPECT_EQ(Result::kSuccess, GetResultAndReset());
VerifyDeviceEligibility();
EXPECT_EQ(SoftwareFeature::BETTER_TOGETHER_CLIENT,
last_find_request_.feature());
EXPECT_EQ(
SoftwareFeatureEnumToString(SoftwareFeature::BETTER_TOGETHER_CLIENT),
last_find_request_.feature());
InvokeErrorCallback();
EXPECT_EQ(Result::kErrorFindingEligible, GetResultAndReset());
EXPECT_EQ(SoftwareFeature::BETTER_TOGETHER_HOST,
EXPECT_EQ(SoftwareFeatureEnumToString(SoftwareFeature::BETTER_TOGETHER_HOST),
last_find_request_.feature());
InvokeFindEligibleDevicesCallback(CreateFindEligibleUnlockDevicesResponse());
EXPECT_EQ(Result::kSuccess, GetResultAndReset());
......@@ -354,12 +359,12 @@ TEST_F(CryptAuthSoftwareFeatureManagerImplTest, TestOrderViaMultipleErrors) {
true /* enable */);
FindEligibleDevices(SoftwareFeature::BETTER_TOGETHER_HOST);
EXPECT_EQ(SoftwareFeature::BETTER_TOGETHER_HOST,
EXPECT_EQ(SoftwareFeatureEnumToString(SoftwareFeature::BETTER_TOGETHER_HOST),
last_toggle_request_.feature());
InvokeErrorCallback();
EXPECT_EQ(Result::kErrorSettingFeature, GetResultAndReset());
EXPECT_EQ(SoftwareFeature::BETTER_TOGETHER_HOST,
EXPECT_EQ(SoftwareFeatureEnumToString(SoftwareFeature::BETTER_TOGETHER_HOST),
last_find_request_.feature());
InvokeErrorCallback();
EXPECT_EQ(Result::kErrorFindingEligible, GetResultAndReset());
......@@ -370,7 +375,7 @@ TEST_F(CryptAuthSoftwareFeatureManagerImplTest, TestIsExclusive) {
test_eligible_external_devices_infos_[0],
true /* enable */, true /* is_exclusive */);
EXPECT_EQ(SoftwareFeature::BETTER_TOGETHER_HOST,
EXPECT_EQ(SoftwareFeatureEnumToString(SoftwareFeature::BETTER_TOGETHER_HOST),
last_toggle_request_.feature());
EXPECT_EQ(true, last_toggle_request_.enable());
EXPECT_EQ(true, last_toggle_request_.is_exclusive());
......@@ -383,7 +388,8 @@ TEST_F(CryptAuthSoftwareFeatureManagerImplTest, TestEasyUnlockSpecialCase) {
test_eligible_external_devices_infos_[0],
false /* enable */);
EXPECT_EQ(SoftwareFeature::EASY_UNLOCK_HOST, last_toggle_request_.feature());
EXPECT_EQ(SoftwareFeatureEnumToString(SoftwareFeature::EASY_UNLOCK_HOST),
last_toggle_request_.feature());
EXPECT_EQ(false, last_toggle_request_.enable());
// apply_to_all() should be false when disabling EasyUnlock host capabilities.
EXPECT_EQ(true, last_toggle_request_.apply_to_all());
......
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