Commit ebf7b226 authored by Josh Nohle's avatar Josh Nohle Committed by Commit Bot

Prefix unit tests in device_sync with "DeviceSync"

Add the prefix "DeviceSync" to all unit tests in the
chromeos/service/device_sync directory so all tests can be run with
--gtest-filter="DeviceSync*".

Bug: 899080
Change-Id: I0ed1124daa853da2c4ebecd2ec229dbcf5fea7bf
Reviewed-on: https://chromium-review.googlesource.com/c/1495796Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Commit-Queue: Josh Nohle <nohle@chromium.org>
Cr-Commit-Position: refs/heads/master@{#636569}
parent c2cae7d5
...@@ -98,9 +98,9 @@ void SaveResultConstRef(T* out, const T& result) { ...@@ -98,9 +98,9 @@ void SaveResultConstRef(T* out, const T& result) {
} // namespace } // namespace
class CryptAuthClientTest : public testing::Test { class DeviceSyncCryptAuthClientTest : public testing::Test {
protected: protected:
CryptAuthClientTest() DeviceSyncCryptAuthClientTest()
: api_call_flow_(new StrictMock<MockCryptAuthApiCallFlow>()), : api_call_flow_(new StrictMock<MockCryptAuthApiCallFlow>()),
serialized_request_(std::string()) { serialized_request_(std::string()) {
shared_factory_ = shared_factory_ =
...@@ -171,7 +171,7 @@ class CryptAuthClientTest : public testing::Test { ...@@ -171,7 +171,7 @@ class CryptAuthClientTest : public testing::Test {
CryptAuthApiCallFlow::ErrorCallback flow_error_callback_; CryptAuthApiCallFlow::ErrorCallback flow_error_callback_;
}; };
TEST_F(CryptAuthClientTest, GetMyDevicesSuccess) { TEST_F(DeviceSyncCryptAuthClientTest, GetMyDevicesSuccess) {
ExpectRequest( ExpectRequest(
"https://www.testgoogleapis.com/cryptauth/v1/deviceSync/" "https://www.testgoogleapis.com/cryptauth/v1/deviceSync/"
"getmydevices?alt=proto"); "getmydevices?alt=proto");
...@@ -216,7 +216,7 @@ TEST_F(CryptAuthClientTest, GetMyDevicesSuccess) { ...@@ -216,7 +216,7 @@ TEST_F(CryptAuthClientTest, GetMyDevicesSuccess) {
EXPECT_TRUE(result_proto.devices(1).unlockable()); EXPECT_TRUE(result_proto.devices(1).unlockable());
} }
TEST_F(CryptAuthClientTest, GetMyDevicesFailure) { TEST_F(DeviceSyncCryptAuthClientTest, GetMyDevicesFailure) {
ExpectRequest( ExpectRequest(
"https://www.testgoogleapis.com/cryptauth/v1/deviceSync/" "https://www.testgoogleapis.com/cryptauth/v1/deviceSync/"
"getmydevices?alt=proto"); "getmydevices?alt=proto");
...@@ -235,7 +235,7 @@ TEST_F(CryptAuthClientTest, GetMyDevicesFailure) { ...@@ -235,7 +235,7 @@ TEST_F(CryptAuthClientTest, GetMyDevicesFailure) {
EXPECT_EQ(NetworkRequestError::kInternalServerError, error); EXPECT_EQ(NetworkRequestError::kInternalServerError, error);
} }
TEST_F(CryptAuthClientTest, FindEligibleUnlockDevicesSuccess) { TEST_F(DeviceSyncCryptAuthClientTest, FindEligibleUnlockDevicesSuccess) {
ExpectRequest( ExpectRequest(
"https://www.testgoogleapis.com/cryptauth/v1/deviceSync/" "https://www.testgoogleapis.com/cryptauth/v1/deviceSync/"
"findeligibleunlockdevices?alt=proto"); "findeligibleunlockdevices?alt=proto");
...@@ -283,7 +283,7 @@ TEST_F(CryptAuthClientTest, FindEligibleUnlockDevicesSuccess) { ...@@ -283,7 +283,7 @@ TEST_F(CryptAuthClientTest, FindEligibleUnlockDevicesSuccess) {
result_proto.ineligible_devices(0).reasons(0)); result_proto.ineligible_devices(0).reasons(0));
} }
TEST_F(CryptAuthClientTest, FindEligibleUnlockDevicesFailure) { TEST_F(DeviceSyncCryptAuthClientTest, FindEligibleUnlockDevicesFailure) {
ExpectRequest( ExpectRequest(
"https://www.testgoogleapis.com/cryptauth/v1/deviceSync/" "https://www.testgoogleapis.com/cryptauth/v1/deviceSync/"
"findeligibleunlockdevices?alt=proto"); "findeligibleunlockdevices?alt=proto");
...@@ -304,7 +304,7 @@ TEST_F(CryptAuthClientTest, FindEligibleUnlockDevicesFailure) { ...@@ -304,7 +304,7 @@ TEST_F(CryptAuthClientTest, FindEligibleUnlockDevicesFailure) {
EXPECT_EQ(NetworkRequestError::kAuthenticationError, error); EXPECT_EQ(NetworkRequestError::kAuthenticationError, error);
} }
TEST_F(CryptAuthClientTest, FindEligibleForPromotionSuccess) { TEST_F(DeviceSyncCryptAuthClientTest, FindEligibleForPromotionSuccess) {
ExpectRequest( ExpectRequest(
"https://www.testgoogleapis.com/cryptauth/v1/deviceSync/" "https://www.testgoogleapis.com/cryptauth/v1/deviceSync/"
"findeligibleforpromotion?alt=proto"); "findeligibleforpromotion?alt=proto");
...@@ -327,7 +327,7 @@ TEST_F(CryptAuthClientTest, FindEligibleForPromotionSuccess) { ...@@ -327,7 +327,7 @@ TEST_F(CryptAuthClientTest, FindEligibleForPromotionSuccess) {
FinishApiCallFlow(&response_proto); FinishApiCallFlow(&response_proto);
} }
TEST_F(CryptAuthClientTest, SendDeviceSyncTickleSuccess) { TEST_F(DeviceSyncCryptAuthClientTest, SendDeviceSyncTickleSuccess) {
ExpectRequest( ExpectRequest(
"https://www.testgoogleapis.com/cryptauth/v1/deviceSync/" "https://www.testgoogleapis.com/cryptauth/v1/deviceSync/"
"senddevicesynctickle?alt=proto"); "senddevicesynctickle?alt=proto");
...@@ -350,7 +350,7 @@ TEST_F(CryptAuthClientTest, SendDeviceSyncTickleSuccess) { ...@@ -350,7 +350,7 @@ TEST_F(CryptAuthClientTest, SendDeviceSyncTickleSuccess) {
FinishApiCallFlow(&response_proto); FinishApiCallFlow(&response_proto);
} }
TEST_F(CryptAuthClientTest, ToggleEasyUnlockSuccess) { TEST_F(DeviceSyncCryptAuthClientTest, ToggleEasyUnlockSuccess) {
ExpectRequest( ExpectRequest(
"https://www.testgoogleapis.com/cryptauth/v1/deviceSync/" "https://www.testgoogleapis.com/cryptauth/v1/deviceSync/"
"toggleeasyunlock?alt=proto"); "toggleeasyunlock?alt=proto");
...@@ -379,7 +379,7 @@ TEST_F(CryptAuthClientTest, ToggleEasyUnlockSuccess) { ...@@ -379,7 +379,7 @@ TEST_F(CryptAuthClientTest, ToggleEasyUnlockSuccess) {
FinishApiCallFlow(&response_proto); FinishApiCallFlow(&response_proto);
} }
TEST_F(CryptAuthClientTest, SetupEnrollmentSuccess) { TEST_F(DeviceSyncCryptAuthClientTest, SetupEnrollmentSuccess) {
ExpectRequest( ExpectRequest(
"https://www.testgoogleapis.com/cryptauth/v1/enrollment/" "https://www.testgoogleapis.com/cryptauth/v1/enrollment/"
"setup?alt=proto"); "setup?alt=proto");
...@@ -429,7 +429,7 @@ TEST_F(CryptAuthClientTest, SetupEnrollmentSuccess) { ...@@ -429,7 +429,7 @@ TEST_F(CryptAuthClientTest, SetupEnrollmentSuccess) {
EXPECT_EQ("ephemeral_key", result_proto.infos(0).server_ephemeral_key()); EXPECT_EQ("ephemeral_key", result_proto.infos(0).server_ephemeral_key());
} }
TEST_F(CryptAuthClientTest, FinishEnrollmentSuccess) { TEST_F(DeviceSyncCryptAuthClientTest, FinishEnrollmentSuccess) {
ExpectRequest( ExpectRequest(
"https://www.testgoogleapis.com/cryptauth/v1/enrollment/" "https://www.testgoogleapis.com/cryptauth/v1/enrollment/"
"finish?alt=proto"); "finish?alt=proto");
...@@ -465,7 +465,7 @@ TEST_F(CryptAuthClientTest, FinishEnrollmentSuccess) { ...@@ -465,7 +465,7 @@ TEST_F(CryptAuthClientTest, FinishEnrollmentSuccess) {
EXPECT_EQ("OK", result_proto.status()); EXPECT_EQ("OK", result_proto.status());
} }
TEST_F(CryptAuthClientTest, SyncKeysSuccess) { TEST_F(DeviceSyncCryptAuthClientTest, SyncKeysSuccess) {
ExpectRequest( ExpectRequest(
"https://cryptauthenrollment.testgoogleapis.com/v1:syncKeys?alt=proto"); "https://cryptauthenrollment.testgoogleapis.com/v1:syncKeys?alt=proto");
...@@ -497,7 +497,7 @@ TEST_F(CryptAuthClientTest, SyncKeysSuccess) { ...@@ -497,7 +497,7 @@ TEST_F(CryptAuthClientTest, SyncKeysSuccess) {
EXPECT_EQ(kRandomSessionId, result_proto.random_session_id()); EXPECT_EQ(kRandomSessionId, result_proto.random_session_id());
} }
TEST_F(CryptAuthClientTest, EnrollKeysSuccess) { TEST_F(DeviceSyncCryptAuthClientTest, EnrollKeysSuccess) {
ExpectRequest( ExpectRequest(
"https://cryptauthenrollment.testgoogleapis.com/v1:enrollKeys?alt=proto"); "https://cryptauthenrollment.testgoogleapis.com/v1:enrollKeys?alt=proto");
...@@ -535,7 +535,7 @@ TEST_F(CryptAuthClientTest, EnrollKeysSuccess) { ...@@ -535,7 +535,7 @@ TEST_F(CryptAuthClientTest, EnrollKeysSuccess) {
result_proto.enroll_single_key_responses(0).certificate(0).common_name()); result_proto.enroll_single_key_responses(0).certificate(0).common_name());
} }
TEST_F(CryptAuthClientTest, FetchAccessTokenFailure) { TEST_F(DeviceSyncCryptAuthClientTest, FetchAccessTokenFailure) {
NetworkRequestError error; NetworkRequestError error;
client_->GetMyDevices( client_->GetMyDevices(
cryptauth::GetMyDevicesRequest(), cryptauth::GetMyDevicesRequest(),
...@@ -549,7 +549,7 @@ TEST_F(CryptAuthClientTest, FetchAccessTokenFailure) { ...@@ -549,7 +549,7 @@ TEST_F(CryptAuthClientTest, FetchAccessTokenFailure) {
EXPECT_EQ(NetworkRequestError::kAuthenticationError, error); EXPECT_EQ(NetworkRequestError::kAuthenticationError, error);
} }
TEST_F(CryptAuthClientTest, ParseResponseProtoFailure) { TEST_F(DeviceSyncCryptAuthClientTest, ParseResponseProtoFailure) {
ExpectRequest( ExpectRequest(
"https://www.testgoogleapis.com/cryptauth/v1/deviceSync/" "https://www.testgoogleapis.com/cryptauth/v1/deviceSync/"
"getmydevices?alt=proto"); "getmydevices?alt=proto");
...@@ -568,7 +568,8 @@ TEST_F(CryptAuthClientTest, ParseResponseProtoFailure) { ...@@ -568,7 +568,8 @@ TEST_F(CryptAuthClientTest, ParseResponseProtoFailure) {
EXPECT_EQ(NetworkRequestError::kResponseMalformed, error); EXPECT_EQ(NetworkRequestError::kResponseMalformed, error);
} }
TEST_F(CryptAuthClientTest, MakeSecondRequestBeforeFirstRequestSucceeds) { TEST_F(DeviceSyncCryptAuthClientTest,
MakeSecondRequestBeforeFirstRequestSucceeds) {
ExpectRequest( ExpectRequest(
"https://www.testgoogleapis.com/cryptauth/v1/deviceSync/" "https://www.testgoogleapis.com/cryptauth/v1/deviceSync/"
"getmydevices?alt=proto"); "getmydevices?alt=proto");
...@@ -607,7 +608,8 @@ TEST_F(CryptAuthClientTest, MakeSecondRequestBeforeFirstRequestSucceeds) { ...@@ -607,7 +608,8 @@ TEST_F(CryptAuthClientTest, MakeSecondRequestBeforeFirstRequestSucceeds) {
EXPECT_EQ(kPublicKey1, result_proto.devices(0).public_key()); EXPECT_EQ(kPublicKey1, result_proto.devices(0).public_key());
} }
TEST_F(CryptAuthClientTest, MakeSecondRequestAfterFirstRequestSucceeds) { TEST_F(DeviceSyncCryptAuthClientTest,
MakeSecondRequestAfterFirstRequestSucceeds) {
// Make first request successfully. // Make first request successfully.
{ {
ExpectRequest( ExpectRequest(
...@@ -643,7 +645,7 @@ TEST_F(CryptAuthClientTest, MakeSecondRequestAfterFirstRequestSucceeds) { ...@@ -643,7 +645,7 @@ TEST_F(CryptAuthClientTest, MakeSecondRequestAfterFirstRequestSucceeds) {
} }
} }
TEST_F(CryptAuthClientTest, DeviceClassifierIsSet) { TEST_F(DeviceSyncCryptAuthClientTest, DeviceClassifierIsSet) {
ExpectRequest( ExpectRequest(
"https://www.testgoogleapis.com/cryptauth/v1/deviceSync/" "https://www.testgoogleapis.com/cryptauth/v1/deviceSync/"
"getmydevices?alt=proto"); "getmydevices?alt=proto");
...@@ -674,7 +676,7 @@ TEST_F(CryptAuthClientTest, DeviceClassifierIsSet) { ...@@ -674,7 +676,7 @@ TEST_F(CryptAuthClientTest, DeviceClassifierIsSet) {
DeviceTypeStringToEnum(device_classifier.device_type())); DeviceTypeStringToEnum(device_classifier.device_type()));
} }
TEST_F(CryptAuthClientTest, GetAccessTokenUsed) { TEST_F(DeviceSyncCryptAuthClientTest, GetAccessTokenUsed) {
EXPECT_TRUE(client_->GetAccessTokenUsed().empty()); EXPECT_TRUE(client_->GetAccessTokenUsed().empty());
ExpectRequest( ExpectRequest(
......
...@@ -19,14 +19,14 @@ const char kFakePrivateKey[] = "fake-private-key"; ...@@ -19,14 +19,14 @@ const char kFakePrivateKey[] = "fake-private-key";
} // namespace } // namespace
TEST(CryptAuthKeyBundleTest, CreateKeyBundle) { TEST(DeviceSyncCryptAuthKeyBundleTest, CreateKeyBundle) {
CryptAuthKeyBundle bundle(CryptAuthKeyBundle::Name::kUserKeyPair); CryptAuthKeyBundle bundle(CryptAuthKeyBundle::Name::kUserKeyPair);
EXPECT_EQ(bundle.name(), CryptAuthKeyBundle::Name::kUserKeyPair); EXPECT_EQ(bundle.name(), CryptAuthKeyBundle::Name::kUserKeyPair);
EXPECT_TRUE(bundle.handle_to_key_map().empty()); EXPECT_TRUE(bundle.handle_to_key_map().empty());
EXPECT_FALSE(bundle.key_directive()); EXPECT_FALSE(bundle.key_directive());
} }
TEST(CryptAuthKeyBundleTest, SetKeyDirective) { TEST(DeviceSyncCryptAuthKeyBundleTest, SetKeyDirective) {
CryptAuthKeyBundle bundle(CryptAuthKeyBundle::Name::kUserKeyPair); CryptAuthKeyBundle bundle(CryptAuthKeyBundle::Name::kUserKeyPair);
cryptauthv2::KeyDirective key_directive; cryptauthv2::KeyDirective key_directive;
bundle.set_key_directive(key_directive); bundle.set_key_directive(key_directive);
...@@ -35,7 +35,7 @@ TEST(CryptAuthKeyBundleTest, SetKeyDirective) { ...@@ -35,7 +35,7 @@ TEST(CryptAuthKeyBundleTest, SetKeyDirective) {
key_directive.SerializeAsString()); key_directive.SerializeAsString());
} }
TEST(CryptAuthKeyBundleTest, AddKey) { TEST(DeviceSyncCryptAuthKeyBundleTest, AddKey) {
CryptAuthKeyBundle bundle(CryptAuthKeyBundle::Name::kUserKeyPair); CryptAuthKeyBundle bundle(CryptAuthKeyBundle::Name::kUserKeyPair);
CryptAuthKey key(kFakeSymmetricKey, CryptAuthKey::Status::kActive, CryptAuthKey key(kFakeSymmetricKey, CryptAuthKey::Status::kActive,
cryptauthv2::KeyType::RAW256, kFakeSymmetricKeyHandle); cryptauthv2::KeyType::RAW256, kFakeSymmetricKeyHandle);
...@@ -48,7 +48,7 @@ TEST(CryptAuthKeyBundleTest, AddKey) { ...@@ -48,7 +48,7 @@ TEST(CryptAuthKeyBundleTest, AddKey) {
EXPECT_EQ(it->second, key); EXPECT_EQ(it->second, key);
} }
TEST(CryptAuthKeyBundleTest, AddKey_Inactive) { TEST(DeviceSyncCryptAuthKeyBundleTest, AddKey_Inactive) {
CryptAuthKeyBundle bundle(CryptAuthKeyBundle::Name::kUserKeyPair); CryptAuthKeyBundle bundle(CryptAuthKeyBundle::Name::kUserKeyPair);
CryptAuthKey symmetric_key(kFakeSymmetricKey, CryptAuthKey::Status::kActive, CryptAuthKey symmetric_key(kFakeSymmetricKey, CryptAuthKey::Status::kActive,
cryptauthv2::KeyType::RAW256, cryptauthv2::KeyType::RAW256,
...@@ -71,7 +71,7 @@ TEST(CryptAuthKeyBundleTest, AddKey_Inactive) { ...@@ -71,7 +71,7 @@ TEST(CryptAuthKeyBundleTest, AddKey_Inactive) {
CryptAuthKey::Status::kInactive); CryptAuthKey::Status::kInactive);
} }
TEST(CryptAuthKeyBundleTest, AddKey_ActiveKeyDeactivatesOthers) { TEST(DeviceSyncCryptAuthKeyBundleTest, AddKey_ActiveKeyDeactivatesOthers) {
CryptAuthKeyBundle bundle(CryptAuthKeyBundle::Name::kUserKeyPair); CryptAuthKeyBundle bundle(CryptAuthKeyBundle::Name::kUserKeyPair);
CryptAuthKey symmetric_key(kFakeSymmetricKey, CryptAuthKey::Status::kActive, CryptAuthKey symmetric_key(kFakeSymmetricKey, CryptAuthKey::Status::kActive,
cryptauthv2::KeyType::RAW256, cryptauthv2::KeyType::RAW256,
...@@ -94,7 +94,7 @@ TEST(CryptAuthKeyBundleTest, AddKey_ActiveKeyDeactivatesOthers) { ...@@ -94,7 +94,7 @@ TEST(CryptAuthKeyBundleTest, AddKey_ActiveKeyDeactivatesOthers) {
CryptAuthKey::Status::kActive); CryptAuthKey::Status::kActive);
} }
TEST(CryptAuthKeyBundleTest, AddKey_ReplaceKeyWithSameHandle) { TEST(DeviceSyncCryptAuthKeyBundleTest, AddKey_ReplaceKeyWithSameHandle) {
CryptAuthKeyBundle bundle(CryptAuthKeyBundle::Name::kUserKeyPair); CryptAuthKeyBundle bundle(CryptAuthKeyBundle::Name::kUserKeyPair);
CryptAuthKey symmetric_key(kFakeSymmetricKey, CryptAuthKey::Status::kActive, CryptAuthKey symmetric_key(kFakeSymmetricKey, CryptAuthKey::Status::kActive,
cryptauthv2::KeyType::RAW256, "same-handle"); cryptauthv2::KeyType::RAW256, "same-handle");
...@@ -110,7 +110,7 @@ TEST(CryptAuthKeyBundleTest, AddKey_ReplaceKeyWithSameHandle) { ...@@ -110,7 +110,7 @@ TEST(CryptAuthKeyBundleTest, AddKey_ReplaceKeyWithSameHandle) {
asymmetric_key); asymmetric_key);
} }
TEST(CryptAuthKeyBundleTest, GetActiveKey_DoesNotExist) { TEST(DeviceSyncCryptAuthKeyBundleTest, GetActiveKey_DoesNotExist) {
CryptAuthKeyBundle bundle(CryptAuthKeyBundle::Name::kUserKeyPair); CryptAuthKeyBundle bundle(CryptAuthKeyBundle::Name::kUserKeyPair);
EXPECT_FALSE(bundle.GetActiveKey()); EXPECT_FALSE(bundle.GetActiveKey());
...@@ -121,7 +121,7 @@ TEST(CryptAuthKeyBundleTest, GetActiveKey_DoesNotExist) { ...@@ -121,7 +121,7 @@ TEST(CryptAuthKeyBundleTest, GetActiveKey_DoesNotExist) {
EXPECT_FALSE(bundle.GetActiveKey()); EXPECT_FALSE(bundle.GetActiveKey());
} }
TEST(CryptAuthKeyBundleTest, GetActiveKey_Exists) { TEST(DeviceSyncCryptAuthKeyBundleTest, GetActiveKey_Exists) {
CryptAuthKeyBundle bundle(CryptAuthKeyBundle::Name::kUserKeyPair); CryptAuthKeyBundle bundle(CryptAuthKeyBundle::Name::kUserKeyPair);
CryptAuthKey symmetric_key(kFakeSymmetricKey, CryptAuthKey::Status::kInactive, CryptAuthKey symmetric_key(kFakeSymmetricKey, CryptAuthKey::Status::kInactive,
cryptauthv2::KeyType::RAW256, cryptauthv2::KeyType::RAW256,
...@@ -136,7 +136,7 @@ TEST(CryptAuthKeyBundleTest, GetActiveKey_Exists) { ...@@ -136,7 +136,7 @@ TEST(CryptAuthKeyBundleTest, GetActiveKey_Exists) {
EXPECT_EQ(*bundle.GetActiveKey(), asymmetric_key); EXPECT_EQ(*bundle.GetActiveKey(), asymmetric_key);
} }
TEST(CryptAuthKeyBundleTest, SetActiveKey_InactiveToActive) { TEST(DeviceSyncCryptAuthKeyBundleTest, SetActiveKey_InactiveToActive) {
CryptAuthKeyBundle bundle(CryptAuthKeyBundle::Name::kUserKeyPair); CryptAuthKeyBundle bundle(CryptAuthKeyBundle::Name::kUserKeyPair);
CryptAuthKey symmetric_key(kFakeSymmetricKey, CryptAuthKey::Status::kInactive, CryptAuthKey symmetric_key(kFakeSymmetricKey, CryptAuthKey::Status::kInactive,
cryptauthv2::KeyType::RAW256, cryptauthv2::KeyType::RAW256,
...@@ -158,7 +158,7 @@ TEST(CryptAuthKeyBundleTest, SetActiveKey_InactiveToActive) { ...@@ -158,7 +158,7 @@ TEST(CryptAuthKeyBundleTest, SetActiveKey_InactiveToActive) {
CryptAuthKey::Status::kInactive); CryptAuthKey::Status::kInactive);
} }
TEST(CryptAuthKeyBundleTest, SetActiveKey_ActiveToActive) { TEST(DeviceSyncCryptAuthKeyBundleTest, SetActiveKey_ActiveToActive) {
CryptAuthKeyBundle bundle(CryptAuthKeyBundle::Name::kUserKeyPair); CryptAuthKeyBundle bundle(CryptAuthKeyBundle::Name::kUserKeyPair);
CryptAuthKey symmetric_key(kFakeSymmetricKey, CryptAuthKey::Status::kInactive, CryptAuthKey symmetric_key(kFakeSymmetricKey, CryptAuthKey::Status::kInactive,
cryptauthv2::KeyType::RAW256, cryptauthv2::KeyType::RAW256,
...@@ -180,7 +180,7 @@ TEST(CryptAuthKeyBundleTest, SetActiveKey_ActiveToActive) { ...@@ -180,7 +180,7 @@ TEST(CryptAuthKeyBundleTest, SetActiveKey_ActiveToActive) {
CryptAuthKey::Status::kActive); CryptAuthKey::Status::kActive);
} }
TEST(CryptAuthKeyBundleTest, DeactivateKeys) { TEST(DeviceSyncCryptAuthKeyBundleTest, DeactivateKeys) {
CryptAuthKeyBundle bundle(CryptAuthKeyBundle::Name::kUserKeyPair); CryptAuthKeyBundle bundle(CryptAuthKeyBundle::Name::kUserKeyPair);
CryptAuthKey symmetric_key(kFakeSymmetricKey, CryptAuthKey::Status::kInactive, CryptAuthKey symmetric_key(kFakeSymmetricKey, CryptAuthKey::Status::kInactive,
cryptauthv2::KeyType::RAW256, cryptauthv2::KeyType::RAW256,
...@@ -202,7 +202,7 @@ TEST(CryptAuthKeyBundleTest, DeactivateKeys) { ...@@ -202,7 +202,7 @@ TEST(CryptAuthKeyBundleTest, DeactivateKeys) {
CryptAuthKey::Status::kInactive); CryptAuthKey::Status::kInactive);
} }
TEST(CryptAuthKeyBundleTest, DeleteKey) { TEST(DeviceSyncCryptAuthKeyBundleTest, DeleteKey) {
CryptAuthKeyBundle bundle(CryptAuthKeyBundle::Name::kUserKeyPair); CryptAuthKeyBundle bundle(CryptAuthKeyBundle::Name::kUserKeyPair);
CryptAuthKey symmetric_key(kFakeSymmetricKey, CryptAuthKey::Status::kInactive, CryptAuthKey symmetric_key(kFakeSymmetricKey, CryptAuthKey::Status::kInactive,
cryptauthv2::KeyType::RAW256, cryptauthv2::KeyType::RAW256,
...@@ -214,7 +214,7 @@ TEST(CryptAuthKeyBundleTest, DeleteKey) { ...@@ -214,7 +214,7 @@ TEST(CryptAuthKeyBundleTest, DeleteKey) {
EXPECT_TRUE(bundle.handle_to_key_map().empty()); EXPECT_TRUE(bundle.handle_to_key_map().empty());
} }
TEST(CryptAuthKeyBundleTest, ToAndFromDictionary_Trivial) { TEST(DeviceSyncCryptAuthKeyBundleTest, ToAndFromDictionary_Trivial) {
CryptAuthKeyBundle bundle(CryptAuthKeyBundle::Name::kUserKeyPair); CryptAuthKeyBundle bundle(CryptAuthKeyBundle::Name::kUserKeyPair);
base::Optional<CryptAuthKeyBundle> bundle_from_dict = base::Optional<CryptAuthKeyBundle> bundle_from_dict =
CryptAuthKeyBundle::FromDictionary(bundle.AsDictionary()); CryptAuthKeyBundle::FromDictionary(bundle.AsDictionary());
...@@ -222,7 +222,7 @@ TEST(CryptAuthKeyBundleTest, ToAndFromDictionary_Trivial) { ...@@ -222,7 +222,7 @@ TEST(CryptAuthKeyBundleTest, ToAndFromDictionary_Trivial) {
EXPECT_EQ(*bundle_from_dict, bundle); EXPECT_EQ(*bundle_from_dict, bundle);
} }
TEST(CryptAuthKeyBundleTest, ToAndFromDictionary) { TEST(DeviceSyncCryptAuthKeyBundleTest, ToAndFromDictionary) {
CryptAuthKeyBundle bundle(CryptAuthKeyBundle::Name::kUserKeyPair); CryptAuthKeyBundle bundle(CryptAuthKeyBundle::Name::kUserKeyPair);
CryptAuthKey symmetric_key(kFakeSymmetricKey, CryptAuthKey::Status::kInactive, CryptAuthKey symmetric_key(kFakeSymmetricKey, CryptAuthKey::Status::kInactive,
cryptauthv2::KeyType::RAW256, cryptauthv2::KeyType::RAW256,
......
...@@ -72,10 +72,10 @@ class FakeSecureMessageDelegateFactory ...@@ -72,10 +72,10 @@ class FakeSecureMessageDelegateFactory
} // namespace } // namespace
class CryptAuthKeyCreatorImplTest : public testing::Test { class DeviceSyncCryptAuthKeyCreatorImplTest : public testing::Test {
protected: protected:
CryptAuthKeyCreatorImplTest() = default; DeviceSyncCryptAuthKeyCreatorImplTest() = default;
~CryptAuthKeyCreatorImplTest() override = default; ~DeviceSyncCryptAuthKeyCreatorImplTest() override = default;
void SetUp() override { void SetUp() override {
fake_secure_message_delegate_factory_ = fake_secure_message_delegate_factory_ =
...@@ -116,10 +116,10 @@ class CryptAuthKeyCreatorImplTest : public testing::Test { ...@@ -116,10 +116,10 @@ class CryptAuthKeyCreatorImplTest : public testing::Test {
std::unique_ptr<CryptAuthKeyCreator> key_creator_; std::unique_ptr<CryptAuthKeyCreator> key_creator_;
DISALLOW_COPY_AND_ASSIGN(CryptAuthKeyCreatorImplTest); DISALLOW_COPY_AND_ASSIGN(DeviceSyncCryptAuthKeyCreatorImplTest);
}; };
TEST_F(CryptAuthKeyCreatorImplTest, AsymmetricKeyCreation) { TEST_F(DeviceSyncCryptAuthKeyCreatorImplTest, AsymmetricKeyCreation) {
base::flat_map<CryptAuthKeyBundle::Name, CryptAuthKeyCreator::CreateKeyData> base::flat_map<CryptAuthKeyBundle::Name, CryptAuthKeyCreator::CreateKeyData>
keys_to_create = { keys_to_create = {
{CryptAuthKeyBundle::Name::kUserKeyPair, {CryptAuthKeyBundle::Name::kUserKeyPair,
...@@ -145,7 +145,7 @@ TEST_F(CryptAuthKeyCreatorImplTest, AsymmetricKeyCreation) { ...@@ -145,7 +145,7 @@ TEST_F(CryptAuthKeyCreatorImplTest, AsymmetricKeyCreation) {
base::nullopt /* expected_client_ephemeral_dh */)); base::nullopt /* expected_client_ephemeral_dh */));
} }
TEST_F(CryptAuthKeyCreatorImplTest, SymmetricKeyCreation) { TEST_F(DeviceSyncCryptAuthKeyCreatorImplTest, SymmetricKeyCreation) {
base::flat_map<CryptAuthKeyBundle::Name, CryptAuthKeyCreator::CreateKeyData> base::flat_map<CryptAuthKeyBundle::Name, CryptAuthKeyCreator::CreateKeyData>
keys_to_create = { keys_to_create = {
{CryptAuthKeyBundle::Name::kUserKeyPair, {CryptAuthKeyBundle::Name::kUserKeyPair,
......
...@@ -71,10 +71,10 @@ class FakeSecureMessageDelegateFactory ...@@ -71,10 +71,10 @@ class FakeSecureMessageDelegateFactory
} // namespace } // namespace
class CryptAuthKeyProofComputerImplTest : public testing::Test { class DeviceSyncCryptAuthKeyProofComputerImplTest : public testing::Test {
protected: protected:
CryptAuthKeyProofComputerImplTest() = default; DeviceSyncCryptAuthKeyProofComputerImplTest() = default;
~CryptAuthKeyProofComputerImplTest() override = default; ~DeviceSyncCryptAuthKeyProofComputerImplTest() override = default;
void SetUp() override { void SetUp() override {
fake_secure_message_delegate_factory_ = fake_secure_message_delegate_factory_ =
...@@ -143,10 +143,11 @@ class CryptAuthKeyProofComputerImplTest : public testing::Test { ...@@ -143,10 +143,11 @@ class CryptAuthKeyProofComputerImplTest : public testing::Test {
std::unique_ptr<CryptAuthKeyProofComputer> key_proof_computer_; std::unique_ptr<CryptAuthKeyProofComputer> key_proof_computer_;
DISALLOW_COPY_AND_ASSIGN(CryptAuthKeyProofComputerImplTest); DISALLOW_COPY_AND_ASSIGN(DeviceSyncCryptAuthKeyProofComputerImplTest);
}; };
TEST_F(CryptAuthKeyProofComputerImplTest, SuccessfulKeyProofComputation) { TEST_F(DeviceSyncCryptAuthKeyProofComputerImplTest,
SuccessfulKeyProofComputation) {
std::vector<std::pair<CryptAuthKey, std::string>> key_payload_pairs = { std::vector<std::pair<CryptAuthKey, std::string>> key_payload_pairs = {
{CryptAuthKey(kFakePublicKeyMaterial, kFakePrivateKeyMaterial, {CryptAuthKey(kFakePublicKeyMaterial, kFakePrivateKeyMaterial,
CryptAuthKey::Status::kActive, cryptauthv2::KeyType::P256), CryptAuthKey::Status::kActive, cryptauthv2::KeyType::P256),
......
...@@ -13,11 +13,11 @@ namespace chromeos { ...@@ -13,11 +13,11 @@ namespace chromeos {
namespace device_sync { namespace device_sync {
class CryptAuthKeyRegistryImplTest : public testing::Test { class DeviceSyncCryptAuthKeyRegistryImplTest : public testing::Test {
protected: protected:
CryptAuthKeyRegistryImplTest() = default; DeviceSyncCryptAuthKeyRegistryImplTest() = default;
~CryptAuthKeyRegistryImplTest() override = default; ~DeviceSyncCryptAuthKeyRegistryImplTest() override = default;
void SetUp() override { void SetUp() override {
CryptAuthKeyRegistryImpl::RegisterPrefs(pref_service_.registry()); CryptAuthKeyRegistryImpl::RegisterPrefs(pref_service_.registry());
...@@ -42,10 +42,10 @@ class CryptAuthKeyRegistryImplTest : public testing::Test { ...@@ -42,10 +42,10 @@ class CryptAuthKeyRegistryImplTest : public testing::Test {
std::unique_ptr<CryptAuthKeyRegistry> key_registry_; std::unique_ptr<CryptAuthKeyRegistry> key_registry_;
DISALLOW_COPY_AND_ASSIGN(CryptAuthKeyRegistryImplTest); DISALLOW_COPY_AND_ASSIGN(DeviceSyncCryptAuthKeyRegistryImplTest);
}; };
TEST_F(CryptAuthKeyRegistryImplTest, GetActiveKey_NoActiveKey) { TEST_F(DeviceSyncCryptAuthKeyRegistryImplTest, GetActiveKey_NoActiveKey) {
CryptAuthKey sym_key("symmetric-key", CryptAuthKey::Status::kInactive, CryptAuthKey sym_key("symmetric-key", CryptAuthKey::Status::kInactive,
cryptauthv2::KeyType::RAW256, "sym-handle"); cryptauthv2::KeyType::RAW256, "sym-handle");
key_registry()->AddEnrolledKey(CryptAuthKeyBundle::Name::kUserKeyPair, key_registry()->AddEnrolledKey(CryptAuthKeyBundle::Name::kUserKeyPair,
...@@ -55,7 +55,7 @@ TEST_F(CryptAuthKeyRegistryImplTest, GetActiveKey_NoActiveKey) { ...@@ -55,7 +55,7 @@ TEST_F(CryptAuthKeyRegistryImplTest, GetActiveKey_NoActiveKey) {
key_registry()->GetActiveKey(CryptAuthKeyBundle::Name::kUserKeyPair)); key_registry()->GetActiveKey(CryptAuthKeyBundle::Name::kUserKeyPair));
} }
TEST_F(CryptAuthKeyRegistryImplTest, GetActiveKey) { TEST_F(DeviceSyncCryptAuthKeyRegistryImplTest, GetActiveKey) {
CryptAuthKey sym_key("symmetric-key", CryptAuthKey::Status::kInactive, CryptAuthKey sym_key("symmetric-key", CryptAuthKey::Status::kInactive,
cryptauthv2::KeyType::RAW256, "sym-handle"); cryptauthv2::KeyType::RAW256, "sym-handle");
CryptAuthKey asym_key("public-key", "private-key", CryptAuthKey asym_key("public-key", "private-key",
...@@ -72,7 +72,7 @@ TEST_F(CryptAuthKeyRegistryImplTest, GetActiveKey) { ...@@ -72,7 +72,7 @@ TEST_F(CryptAuthKeyRegistryImplTest, GetActiveKey) {
EXPECT_EQ(asym_key, *key); EXPECT_EQ(asym_key, *key);
} }
TEST_F(CryptAuthKeyRegistryImplTest, AddKey) { TEST_F(DeviceSyncCryptAuthKeyRegistryImplTest, AddKey) {
CryptAuthKey sym_key("symmetric-key", CryptAuthKey::Status::kActive, CryptAuthKey sym_key("symmetric-key", CryptAuthKey::Status::kActive,
cryptauthv2::KeyType::RAW256, "sym-handle"); cryptauthv2::KeyType::RAW256, "sym-handle");
key_registry()->AddEnrolledKey(CryptAuthKeyBundle::Name::kUserKeyPair, key_registry()->AddEnrolledKey(CryptAuthKeyBundle::Name::kUserKeyPair,
...@@ -117,7 +117,7 @@ TEST_F(CryptAuthKeyRegistryImplTest, AddKey) { ...@@ -117,7 +117,7 @@ TEST_F(CryptAuthKeyRegistryImplTest, AddKey) {
VerifyPrefValue(expected_dict); VerifyPrefValue(expected_dict);
} }
TEST_F(CryptAuthKeyRegistryImplTest, SetActiveKey) { TEST_F(DeviceSyncCryptAuthKeyRegistryImplTest, SetActiveKey) {
CryptAuthKey sym_key("symmetric-key", CryptAuthKey::Status::kInactive, CryptAuthKey sym_key("symmetric-key", CryptAuthKey::Status::kInactive,
cryptauthv2::KeyType::RAW256, "sym-handle"); cryptauthv2::KeyType::RAW256, "sym-handle");
CryptAuthKey asym_key("public-key", "private-key", CryptAuthKey asym_key("public-key", "private-key",
...@@ -149,7 +149,7 @@ TEST_F(CryptAuthKeyRegistryImplTest, SetActiveKey) { ...@@ -149,7 +149,7 @@ TEST_F(CryptAuthKeyRegistryImplTest, SetActiveKey) {
VerifyPrefValue(expected_dict); VerifyPrefValue(expected_dict);
} }
TEST_F(CryptAuthKeyRegistryImplTest, DeactivateKeys) { TEST_F(DeviceSyncCryptAuthKeyRegistryImplTest, DeactivateKeys) {
CryptAuthKey sym_key("symmetric-key", CryptAuthKey::Status::kInactive, CryptAuthKey sym_key("symmetric-key", CryptAuthKey::Status::kInactive,
cryptauthv2::KeyType::RAW256, "sym-handle"); cryptauthv2::KeyType::RAW256, "sym-handle");
CryptAuthKey asym_key("public-key", "private-key", CryptAuthKey asym_key("public-key", "private-key",
...@@ -176,7 +176,7 @@ TEST_F(CryptAuthKeyRegistryImplTest, DeactivateKeys) { ...@@ -176,7 +176,7 @@ TEST_F(CryptAuthKeyRegistryImplTest, DeactivateKeys) {
VerifyPrefValue(expected_dict); VerifyPrefValue(expected_dict);
} }
TEST_F(CryptAuthKeyRegistryImplTest, DeleteKey) { TEST_F(DeviceSyncCryptAuthKeyRegistryImplTest, DeleteKey) {
CryptAuthKey sym_key("symmetric-key", CryptAuthKey::Status::kInactive, CryptAuthKey sym_key("symmetric-key", CryptAuthKey::Status::kInactive,
cryptauthv2::KeyType::RAW256, "sym-handle"); cryptauthv2::KeyType::RAW256, "sym-handle");
CryptAuthKey asym_key("public-key", "private-key", CryptAuthKey asym_key("public-key", "private-key",
...@@ -208,7 +208,7 @@ TEST_F(CryptAuthKeyRegistryImplTest, DeleteKey) { ...@@ -208,7 +208,7 @@ TEST_F(CryptAuthKeyRegistryImplTest, DeleteKey) {
VerifyPrefValue(expected_dict); VerifyPrefValue(expected_dict);
} }
TEST_F(CryptAuthKeyRegistryImplTest, SetKeyDirective) { TEST_F(DeviceSyncCryptAuthKeyRegistryImplTest, SetKeyDirective) {
CryptAuthKey sym_key("symmetric-key", CryptAuthKey::Status::kInactive, CryptAuthKey sym_key("symmetric-key", CryptAuthKey::Status::kInactive,
cryptauthv2::KeyType::RAW256, "sym-handle"); cryptauthv2::KeyType::RAW256, "sym-handle");
key_registry()->AddEnrolledKey(CryptAuthKeyBundle::Name::kUserKeyPair, key_registry()->AddEnrolledKey(CryptAuthKeyBundle::Name::kUserKeyPair,
...@@ -237,7 +237,8 @@ TEST_F(CryptAuthKeyRegistryImplTest, SetKeyDirective) { ...@@ -237,7 +237,8 @@ TEST_F(CryptAuthKeyRegistryImplTest, SetKeyDirective) {
VerifyPrefValue(expected_dict); VerifyPrefValue(expected_dict);
} }
TEST_F(CryptAuthKeyRegistryImplTest, ConstructorPopulatesBundlesUsingPref) { TEST_F(DeviceSyncCryptAuthKeyRegistryImplTest,
ConstructorPopulatesBundlesUsingPref) {
CryptAuthKey sym_key("symmetric-key", CryptAuthKey::Status::kInactive, CryptAuthKey sym_key("symmetric-key", CryptAuthKey::Status::kInactive,
cryptauthv2::KeyType::RAW256, "sym-handle"); cryptauthv2::KeyType::RAW256, "sym-handle");
key_registry()->AddEnrolledKey(CryptAuthKeyBundle::Name::kUserKeyPair, key_registry()->AddEnrolledKey(CryptAuthKeyBundle::Name::kUserKeyPair,
......
...@@ -25,7 +25,7 @@ const char kFakePrivateKeyBase64[] = "ZmFrZS1wcml2YXRlLWtleQ=="; ...@@ -25,7 +25,7 @@ const char kFakePrivateKeyBase64[] = "ZmFrZS1wcml2YXRlLWtleQ==";
} // namespace } // namespace
TEST(CryptAuthKeyTest, CreateSymmetricKey) { TEST(DeviceSyncCryptAuthKeyTest, CreateSymmetricKey) {
CryptAuthKey key(kFakeSymmetricKey, CryptAuthKey::Status::kActive, CryptAuthKey key(kFakeSymmetricKey, CryptAuthKey::Status::kActive,
cryptauthv2::KeyType::RAW256); cryptauthv2::KeyType::RAW256);
...@@ -42,7 +42,7 @@ TEST(CryptAuthKeyTest, CreateSymmetricKey) { ...@@ -42,7 +42,7 @@ TEST(CryptAuthKeyTest, CreateSymmetricKey) {
EXPECT_EQ(key_given_handle.handle(), kFakeHandle); EXPECT_EQ(key_given_handle.handle(), kFakeHandle);
} }
TEST(CryptAuthKeyTest, CreateAsymmetricKey) { TEST(DeviceSyncCryptAuthKeyTest, CreateAsymmetricKey) {
CryptAuthKey key(kFakePublicKey, kFakePrivateKey, CryptAuthKey key(kFakePublicKey, kFakePrivateKey,
CryptAuthKey::Status::kActive, cryptauthv2::KeyType::P256); CryptAuthKey::Status::kActive, cryptauthv2::KeyType::P256);
...@@ -60,7 +60,7 @@ TEST(CryptAuthKeyTest, CreateAsymmetricKey) { ...@@ -60,7 +60,7 @@ TEST(CryptAuthKeyTest, CreateAsymmetricKey) {
EXPECT_EQ(key_given_handle.handle(), kFakeHandle); EXPECT_EQ(key_given_handle.handle(), kFakeHandle);
} }
TEST(CryptAuthKeyTest, SymmetricKeyAsDictionary) { TEST(DeviceSyncCryptAuthKeyTest, SymmetricKeyAsDictionary) {
CryptAuthKey symmetric_key(kFakeSymmetricKey, CryptAuthKey::Status::kActive, CryptAuthKey symmetric_key(kFakeSymmetricKey, CryptAuthKey::Status::kActive,
cryptauthv2::KeyType::RAW256, kFakeHandle); cryptauthv2::KeyType::RAW256, kFakeHandle);
...@@ -73,7 +73,7 @@ TEST(CryptAuthKeyTest, SymmetricKeyAsDictionary) { ...@@ -73,7 +73,7 @@ TEST(CryptAuthKeyTest, SymmetricKeyAsDictionary) {
EXPECT_EQ(symmetric_key.AsSymmetricKeyDictionary(), dict); EXPECT_EQ(symmetric_key.AsSymmetricKeyDictionary(), dict);
} }
TEST(CryptAuthKeyTest, AsymmetricKeyAsDictionary) { TEST(DeviceSyncCryptAuthKeyTest, AsymmetricKeyAsDictionary) {
CryptAuthKey asymmetric_key(kFakePublicKey, kFakePrivateKey, CryptAuthKey asymmetric_key(kFakePublicKey, kFakePrivateKey,
CryptAuthKey::Status::kActive, CryptAuthKey::Status::kActive,
cryptauthv2::KeyType::P256, kFakeHandle); cryptauthv2::KeyType::P256, kFakeHandle);
...@@ -88,7 +88,7 @@ TEST(CryptAuthKeyTest, AsymmetricKeyAsDictionary) { ...@@ -88,7 +88,7 @@ TEST(CryptAuthKeyTest, AsymmetricKeyAsDictionary) {
EXPECT_EQ(asymmetric_key.AsAsymmetricKeyDictionary(), dict); EXPECT_EQ(asymmetric_key.AsAsymmetricKeyDictionary(), dict);
} }
TEST(CryptAuthKeyTest, SymmetricKeyFromDictionary) { TEST(DeviceSyncCryptAuthKeyTest, SymmetricKeyFromDictionary) {
base::Value dict(base::Value::Type::DICTIONARY); base::Value dict(base::Value::Type::DICTIONARY);
dict.SetKey("handle", base::Value(kFakeHandle)); dict.SetKey("handle", base::Value(kFakeHandle));
dict.SetKey("status", base::Value(CryptAuthKey::Status::kActive)); dict.SetKey("status", base::Value(CryptAuthKey::Status::kActive));
...@@ -101,7 +101,7 @@ TEST(CryptAuthKeyTest, SymmetricKeyFromDictionary) { ...@@ -101,7 +101,7 @@ TEST(CryptAuthKeyTest, SymmetricKeyFromDictionary) {
cryptauthv2::KeyType::RAW256, kFakeHandle)); cryptauthv2::KeyType::RAW256, kFakeHandle));
} }
TEST(CryptAuthKeyTest, AsymmetricKeyFromDictionary) { TEST(DeviceSyncCryptAuthKeyTest, AsymmetricKeyFromDictionary) {
base::Value dict(base::Value::Type::DICTIONARY); base::Value dict(base::Value::Type::DICTIONARY);
dict.SetKey("handle", base::Value(kFakeHandle)); dict.SetKey("handle", base::Value(kFakeHandle));
dict.SetKey("status", base::Value(CryptAuthKey::Status::kActive)); dict.SetKey("status", base::Value(CryptAuthKey::Status::kActive));
...@@ -116,7 +116,7 @@ TEST(CryptAuthKeyTest, AsymmetricKeyFromDictionary) { ...@@ -116,7 +116,7 @@ TEST(CryptAuthKeyTest, AsymmetricKeyFromDictionary) {
cryptauthv2::KeyType::P256, kFakeHandle)); cryptauthv2::KeyType::P256, kFakeHandle));
} }
TEST(CryptAuthKeyTest, KeyFromDictionary_MissingHandle) { TEST(DeviceSyncCryptAuthKeyTest, KeyFromDictionary_MissingHandle) {
base::Value dict(base::Value::Type::DICTIONARY); base::Value dict(base::Value::Type::DICTIONARY);
dict.SetKey("status", base::Value(CryptAuthKey::Status::kActive)); dict.SetKey("status", base::Value(CryptAuthKey::Status::kActive));
dict.SetKey("type", base::Value(cryptauthv2::KeyType::RAW256)); dict.SetKey("type", base::Value(cryptauthv2::KeyType::RAW256));
...@@ -125,7 +125,7 @@ TEST(CryptAuthKeyTest, KeyFromDictionary_MissingHandle) { ...@@ -125,7 +125,7 @@ TEST(CryptAuthKeyTest, KeyFromDictionary_MissingHandle) {
EXPECT_FALSE(CryptAuthKey::FromDictionary(dict)); EXPECT_FALSE(CryptAuthKey::FromDictionary(dict));
} }
TEST(CryptAuthKeyTest, KeyFromDictionary_MissingStatus) { TEST(DeviceSyncCryptAuthKeyTest, KeyFromDictionary_MissingStatus) {
base::Value dict(base::Value::Type::DICTIONARY); base::Value dict(base::Value::Type::DICTIONARY);
dict.SetKey("handle", base::Value(kFakeHandle)); dict.SetKey("handle", base::Value(kFakeHandle));
dict.SetKey("type", base::Value(cryptauthv2::KeyType::RAW256)); dict.SetKey("type", base::Value(cryptauthv2::KeyType::RAW256));
...@@ -134,7 +134,7 @@ TEST(CryptAuthKeyTest, KeyFromDictionary_MissingStatus) { ...@@ -134,7 +134,7 @@ TEST(CryptAuthKeyTest, KeyFromDictionary_MissingStatus) {
EXPECT_FALSE(CryptAuthKey::FromDictionary(dict)); EXPECT_FALSE(CryptAuthKey::FromDictionary(dict));
} }
TEST(CryptAuthKeyTest, KeyFromDictionary_MissingType) { TEST(DeviceSyncCryptAuthKeyTest, KeyFromDictionary_MissingType) {
base::Value dict(base::Value::Type::DICTIONARY); base::Value dict(base::Value::Type::DICTIONARY);
dict.SetKey("handle", base::Value(kFakeHandle)); dict.SetKey("handle", base::Value(kFakeHandle));
dict.SetKey("status", base::Value(CryptAuthKey::Status::kActive)); dict.SetKey("status", base::Value(CryptAuthKey::Status::kActive));
...@@ -143,7 +143,8 @@ TEST(CryptAuthKeyTest, KeyFromDictionary_MissingType) { ...@@ -143,7 +143,8 @@ TEST(CryptAuthKeyTest, KeyFromDictionary_MissingType) {
EXPECT_FALSE(CryptAuthKey::FromDictionary(dict)); EXPECT_FALSE(CryptAuthKey::FromDictionary(dict));
} }
TEST(CryptAuthKeyTest, SymmetricKeyFromDictionary_MissingSymmetricKey) { TEST(DeviceSyncCryptAuthKeyTest,
SymmetricKeyFromDictionary_MissingSymmetricKey) {
base::Value dict(base::Value::Type::DICTIONARY); base::Value dict(base::Value::Type::DICTIONARY);
dict.SetKey("handle", base::Value(kFakeHandle)); dict.SetKey("handle", base::Value(kFakeHandle));
dict.SetKey("status", base::Value(CryptAuthKey::Status::kActive)); dict.SetKey("status", base::Value(CryptAuthKey::Status::kActive));
...@@ -152,7 +153,7 @@ TEST(CryptAuthKeyTest, SymmetricKeyFromDictionary_MissingSymmetricKey) { ...@@ -152,7 +153,7 @@ TEST(CryptAuthKeyTest, SymmetricKeyFromDictionary_MissingSymmetricKey) {
EXPECT_FALSE(CryptAuthKey::FromDictionary(dict)); EXPECT_FALSE(CryptAuthKey::FromDictionary(dict));
} }
TEST(CryptAuthKeyTest, AsymmetricKeyFromDictionary_MissingPublicKey) { TEST(DeviceSyncCryptAuthKeyTest, AsymmetricKeyFromDictionary_MissingPublicKey) {
base::Value dict(base::Value::Type::DICTIONARY); base::Value dict(base::Value::Type::DICTIONARY);
dict.SetKey("handle", base::Value(kFakeHandle)); dict.SetKey("handle", base::Value(kFakeHandle));
dict.SetKey("status", base::Value(CryptAuthKey::Status::kActive)); dict.SetKey("status", base::Value(CryptAuthKey::Status::kActive));
...@@ -162,7 +163,8 @@ TEST(CryptAuthKeyTest, AsymmetricKeyFromDictionary_MissingPublicKey) { ...@@ -162,7 +163,8 @@ TEST(CryptAuthKeyTest, AsymmetricKeyFromDictionary_MissingPublicKey) {
EXPECT_FALSE(CryptAuthKey::FromDictionary(dict)); EXPECT_FALSE(CryptAuthKey::FromDictionary(dict));
} }
TEST(CryptAuthKeyTest, AsymmetricKeyFromDictionary_MissingPrivateKey) { TEST(DeviceSyncCryptAuthKeyTest,
AsymmetricKeyFromDictionary_MissingPrivateKey) {
base::Value dict(base::Value::Type::DICTIONARY); base::Value dict(base::Value::Type::DICTIONARY);
dict.SetKey("handle", base::Value(kFakeHandle)); dict.SetKey("handle", base::Value(kFakeHandle));
dict.SetKey("status", base::Value(CryptAuthKey::Status::kActive)); dict.SetKey("status", base::Value(CryptAuthKey::Status::kActive));
...@@ -172,7 +174,7 @@ TEST(CryptAuthKeyTest, AsymmetricKeyFromDictionary_MissingPrivateKey) { ...@@ -172,7 +174,7 @@ TEST(CryptAuthKeyTest, AsymmetricKeyFromDictionary_MissingPrivateKey) {
EXPECT_FALSE(CryptAuthKey::FromDictionary(dict)); EXPECT_FALSE(CryptAuthKey::FromDictionary(dict));
} }
TEST(CryptAuthKeyTest, Equality) { TEST(DeviceSyncCryptAuthKeyTest, Equality) {
CryptAuthKey symmetric_key(kFakeSymmetricKey, CryptAuthKey::Status::kActive, CryptAuthKey symmetric_key(kFakeSymmetricKey, CryptAuthKey::Status::kActive,
cryptauthv2::KeyType::RAW256); cryptauthv2::KeyType::RAW256);
CryptAuthKey asymmetric_key(kFakePublicKey, kFakePrivateKey, CryptAuthKey asymmetric_key(kFakePublicKey, kFakePrivateKey,
...@@ -187,7 +189,7 @@ TEST(CryptAuthKeyTest, Equality) { ...@@ -187,7 +189,7 @@ TEST(CryptAuthKeyTest, Equality) {
cryptauthv2::KeyType::P256)); cryptauthv2::KeyType::P256));
} }
TEST(CryptAuthKeyTest, NotEquality) { TEST(DeviceSyncCryptAuthKeyTest, NotEquality) {
CryptAuthKey symmetric_key(kFakeSymmetricKey, CryptAuthKey::Status::kActive, CryptAuthKey symmetric_key(kFakeSymmetricKey, CryptAuthKey::Status::kActive,
cryptauthv2::KeyType::RAW256); cryptauthv2::KeyType::RAW256);
CryptAuthKey asymmetric_key(kFakePublicKey, kFakePrivateKey, CryptAuthKey asymmetric_key(kFakePublicKey, kFakePrivateKey,
......
...@@ -347,11 +347,11 @@ SyncKeysResponse BuildSyncKeysResponse( ...@@ -347,11 +347,11 @@ SyncKeysResponse BuildSyncKeysResponse(
} // namespace } // namespace
class CryptAuthV2EnrollerImplTest class DeviceSyncCryptAuthV2EnrollerImplTest
: public testing::Test, : public testing::Test,
public MockCryptAuthClientFactory::Observer { public MockCryptAuthClientFactory::Observer {
protected: protected:
CryptAuthV2EnrollerImplTest() DeviceSyncCryptAuthV2EnrollerImplTest()
: client_factory_(std::make_unique<MockCryptAuthClientFactory>( : client_factory_(std::make_unique<MockCryptAuthClientFactory>(
MockCryptAuthClientFactory::MockType::MAKE_NICE_MOCKS)), MockCryptAuthClientFactory::MockType::MAKE_NICE_MOCKS)),
fake_cryptauth_key_creator_factory_( fake_cryptauth_key_creator_factory_(
...@@ -365,7 +365,7 @@ class CryptAuthV2EnrollerImplTest ...@@ -365,7 +365,7 @@ class CryptAuthV2EnrollerImplTest
client_factory_->AddObserver(this); client_factory_->AddObserver(this);
} }
~CryptAuthV2EnrollerImplTest() override { ~DeviceSyncCryptAuthV2EnrollerImplTest() override {
client_factory_->RemoveObserver(this); client_factory_->RemoveObserver(this);
} }
...@@ -392,11 +392,12 @@ class CryptAuthV2EnrollerImplTest ...@@ -392,11 +392,12 @@ class CryptAuthV2EnrollerImplTest
// MockCryptAuthClientFactory::Observer: // MockCryptAuthClientFactory::Observer:
void OnCryptAuthClientCreated(MockCryptAuthClient* client) override { void OnCryptAuthClientCreated(MockCryptAuthClient* client) override {
ON_CALL(*client, SyncKeys(testing::_, testing::_, testing::_)) ON_CALL(*client, SyncKeys(testing::_, testing::_, testing::_))
.WillByDefault(Invoke(this, &CryptAuthV2EnrollerImplTest::OnSyncKeys)); .WillByDefault(
Invoke(this, &DeviceSyncCryptAuthV2EnrollerImplTest::OnSyncKeys));
ON_CALL(*client, EnrollKeys(testing::_, testing::_, testing::_)) ON_CALL(*client, EnrollKeys(testing::_, testing::_, testing::_))
.WillByDefault( .WillByDefault(
Invoke(this, &CryptAuthV2EnrollerImplTest::OnEnrollKeys)); Invoke(this, &DeviceSyncCryptAuthV2EnrollerImplTest::OnEnrollKeys));
ON_CALL(*client, GetAccessTokenUsed()) ON_CALL(*client, GetAccessTokenUsed())
.WillByDefault(testing::Return(kAccessTokenUsed)); .WillByDefault(testing::Return(kAccessTokenUsed));
...@@ -408,8 +409,9 @@ class CryptAuthV2EnrollerImplTest ...@@ -408,8 +409,9 @@ class CryptAuthV2EnrollerImplTest
client_directive_policy_reference) { client_directive_policy_reference) {
enroller()->Enroll( enroller()->Enroll(
client_metadata, client_app_metadata, client_directive_policy_reference, client_metadata, client_app_metadata, client_directive_policy_reference,
base::BindOnce(&CryptAuthV2EnrollerImplTest::OnEnrollmentComplete, base::BindOnce(
base::Unretained(this))); &DeviceSyncCryptAuthV2EnrollerImplTest::OnEnrollmentComplete,
base::Unretained(this)));
} }
void OnSyncKeys(const SyncKeysRequest& request, void OnSyncKeys(const SyncKeysRequest& request,
...@@ -554,10 +556,10 @@ class CryptAuthV2EnrollerImplTest ...@@ -554,10 +556,10 @@ class CryptAuthV2EnrollerImplTest
std::unique_ptr<CryptAuthV2Enroller> enroller_; std::unique_ptr<CryptAuthV2Enroller> enroller_;
DISALLOW_COPY_AND_ASSIGN(CryptAuthV2EnrollerImplTest); DISALLOW_COPY_AND_ASSIGN(DeviceSyncCryptAuthV2EnrollerImplTest);
}; };
TEST_F(CryptAuthV2EnrollerImplTest, SuccessfulEnrollment) { TEST_F(DeviceSyncCryptAuthV2EnrollerImplTest, SuccessfulEnrollment) {
// Seed key registry. // Seed key registry.
key_registry()->AddEnrolledKey(CryptAuthKeyBundle::Name::kUserKeyPair, key_registry()->AddEnrolledKey(CryptAuthKeyBundle::Name::kUserKeyPair,
kOldActiveAsymmetricKey); kOldActiveAsymmetricKey);
...@@ -660,7 +662,8 @@ TEST_F(CryptAuthV2EnrollerImplTest, SuccessfulEnrollment) { ...@@ -660,7 +662,8 @@ TEST_F(CryptAuthV2EnrollerImplTest, SuccessfulEnrollment) {
*key_registry()->GetKeyBundle(bundle_name)); *key_registry()->GetKeyBundle(bundle_name));
} }
TEST_F(CryptAuthV2EnrollerImplTest, SuccessfulEnrollment_NoKeysCreated) { TEST_F(DeviceSyncCryptAuthV2EnrollerImplTest,
SuccessfulEnrollment_NoKeysCreated) {
key_registry()->AddEnrolledKey(CryptAuthKeyBundle::Name::kUserKeyPair, key_registry()->AddEnrolledKey(CryptAuthKeyBundle::Name::kUserKeyPair,
kOldActiveAsymmetricKey); kOldActiveAsymmetricKey);
key_registry()->AddEnrolledKey(CryptAuthKeyBundle::Name::kUserKeyPair, key_registry()->AddEnrolledKey(CryptAuthKeyBundle::Name::kUserKeyPair,
...@@ -696,7 +699,7 @@ TEST_F(CryptAuthV2EnrollerImplTest, SuccessfulEnrollment_NoKeysCreated) { ...@@ -696,7 +699,7 @@ TEST_F(CryptAuthV2EnrollerImplTest, SuccessfulEnrollment_NoKeysCreated) {
enrollment_result()); enrollment_result());
} }
TEST_F(CryptAuthV2EnrollerImplTest, Failure_ServerOverloaded) { TEST_F(DeviceSyncCryptAuthV2EnrollerImplTest, Failure_ServerOverloaded) {
CallEnroll(GetSampleClientMetadata(), GetSampleClientAppMetadata(), CallEnroll(GetSampleClientMetadata(), GetSampleClientAppMetadata(),
GetSamplePreviousClientDirectivePolicyReference()); GetSamplePreviousClientDirectivePolicyReference());
...@@ -711,7 +714,7 @@ TEST_F(CryptAuthV2EnrollerImplTest, Failure_ServerOverloaded) { ...@@ -711,7 +714,7 @@ TEST_F(CryptAuthV2EnrollerImplTest, Failure_ServerOverloaded) {
enrollment_result()); enrollment_result());
} }
TEST_F(CryptAuthV2EnrollerImplTest, Failure_MissingSessionId) { TEST_F(DeviceSyncCryptAuthV2EnrollerImplTest, Failure_MissingSessionId) {
CallEnroll(GetSampleClientMetadata(), GetSampleClientAppMetadata(), CallEnroll(GetSampleClientMetadata(), GetSampleClientAppMetadata(),
GetSamplePreviousClientDirectivePolicyReference()); GetSamplePreviousClientDirectivePolicyReference());
...@@ -727,7 +730,7 @@ TEST_F(CryptAuthV2EnrollerImplTest, Failure_MissingSessionId) { ...@@ -727,7 +730,7 @@ TEST_F(CryptAuthV2EnrollerImplTest, Failure_MissingSessionId) {
enrollment_result()); enrollment_result());
} }
TEST_F(CryptAuthV2EnrollerImplTest, Failure_MissingClientDirective) { TEST_F(DeviceSyncCryptAuthV2EnrollerImplTest, Failure_MissingClientDirective) {
CallEnroll(GetSampleClientMetadata(), GetSampleClientAppMetadata(), CallEnroll(GetSampleClientMetadata(), GetSampleClientAppMetadata(),
GetSamplePreviousClientDirectivePolicyReference()); GetSamplePreviousClientDirectivePolicyReference());
...@@ -743,7 +746,8 @@ TEST_F(CryptAuthV2EnrollerImplTest, Failure_MissingClientDirective) { ...@@ -743,7 +746,8 @@ TEST_F(CryptAuthV2EnrollerImplTest, Failure_MissingClientDirective) {
enrollment_result()); enrollment_result());
} }
TEST_F(CryptAuthV2EnrollerImplTest, Failure_InvalidSyncSingleKeyResponsesSize) { TEST_F(DeviceSyncCryptAuthV2EnrollerImplTest,
Failure_InvalidSyncSingleKeyResponsesSize) {
CallEnroll(GetSampleClientMetadata(), GetSampleClientAppMetadata(), CallEnroll(GetSampleClientMetadata(), GetSampleClientAppMetadata(),
GetSamplePreviousClientDirectivePolicyReference()); GetSamplePreviousClientDirectivePolicyReference());
...@@ -759,7 +763,7 @@ TEST_F(CryptAuthV2EnrollerImplTest, Failure_InvalidSyncSingleKeyResponsesSize) { ...@@ -759,7 +763,7 @@ TEST_F(CryptAuthV2EnrollerImplTest, Failure_InvalidSyncSingleKeyResponsesSize) {
enrollment_result()); enrollment_result());
} }
TEST_F(CryptAuthV2EnrollerImplTest, Failure_InvalidKeyActions_Size) { TEST_F(DeviceSyncCryptAuthV2EnrollerImplTest, Failure_InvalidKeyActions_Size) {
CallEnroll(GetSampleClientMetadata(), GetSampleClientAppMetadata(), CallEnroll(GetSampleClientMetadata(), GetSampleClientAppMetadata(),
GetSamplePreviousClientDirectivePolicyReference()); GetSamplePreviousClientDirectivePolicyReference());
...@@ -778,7 +782,8 @@ TEST_F(CryptAuthV2EnrollerImplTest, Failure_InvalidKeyActions_Size) { ...@@ -778,7 +782,8 @@ TEST_F(CryptAuthV2EnrollerImplTest, Failure_InvalidKeyActions_Size) {
enrollment_result()); enrollment_result());
} }
TEST_F(CryptAuthV2EnrollerImplTest, Failure_InvalidKeyActions_NoActiveKey) { TEST_F(DeviceSyncCryptAuthV2EnrollerImplTest,
Failure_InvalidKeyActions_NoActiveKey) {
key_registry()->AddEnrolledKey(CryptAuthKeyBundle::Name::kUserKeyPair, key_registry()->AddEnrolledKey(CryptAuthKeyBundle::Name::kUserKeyPair,
kOldActiveAsymmetricKey); kOldActiveAsymmetricKey);
...@@ -803,7 +808,7 @@ TEST_F(CryptAuthV2EnrollerImplTest, Failure_InvalidKeyActions_NoActiveKey) { ...@@ -803,7 +808,7 @@ TEST_F(CryptAuthV2EnrollerImplTest, Failure_InvalidKeyActions_NoActiveKey) {
enrollment_result()); enrollment_result());
} }
TEST_F(CryptAuthV2EnrollerImplTest, TEST_F(DeviceSyncCryptAuthV2EnrollerImplTest,
Failure_InvalidKeyCreationInstructions_UnsupportedKeyType) { Failure_InvalidKeyCreationInstructions_UnsupportedKeyType) {
CallEnroll(GetSampleClientMetadata(), GetSampleClientAppMetadata(), CallEnroll(GetSampleClientMetadata(), GetSampleClientAppMetadata(),
GetSamplePreviousClientDirectivePolicyReference()); GetSamplePreviousClientDirectivePolicyReference());
...@@ -824,7 +829,7 @@ TEST_F(CryptAuthV2EnrollerImplTest, ...@@ -824,7 +829,7 @@ TEST_F(CryptAuthV2EnrollerImplTest,
enrollment_result()); enrollment_result());
} }
TEST_F(CryptAuthV2EnrollerImplTest, TEST_F(DeviceSyncCryptAuthV2EnrollerImplTest,
Failure_InvalidKeyCreationInstructions_NoServerDiffieHellman) { Failure_InvalidKeyCreationInstructions_NoServerDiffieHellman) {
CallEnroll(GetSampleClientMetadata(), GetSampleClientAppMetadata(), CallEnroll(GetSampleClientMetadata(), GetSampleClientAppMetadata(),
GetSamplePreviousClientDirectivePolicyReference()); GetSamplePreviousClientDirectivePolicyReference());
...@@ -847,7 +852,7 @@ TEST_F(CryptAuthV2EnrollerImplTest, ...@@ -847,7 +852,7 @@ TEST_F(CryptAuthV2EnrollerImplTest,
enrollment_result()); enrollment_result());
} }
TEST_F(CryptAuthV2EnrollerImplTest, Failure_SyncKeysApiCall) { TEST_F(DeviceSyncCryptAuthV2EnrollerImplTest, Failure_SyncKeysApiCall) {
CallEnroll(GetSampleClientMetadata(), GetSampleClientAppMetadata(), CallEnroll(GetSampleClientMetadata(), GetSampleClientAppMetadata(),
GetSamplePreviousClientDirectivePolicyReference()); GetSamplePreviousClientDirectivePolicyReference());
...@@ -860,7 +865,7 @@ TEST_F(CryptAuthV2EnrollerImplTest, Failure_SyncKeysApiCall) { ...@@ -860,7 +865,7 @@ TEST_F(CryptAuthV2EnrollerImplTest, Failure_SyncKeysApiCall) {
enrollment_result()); enrollment_result());
} }
TEST_F(CryptAuthV2EnrollerImplTest, Failure_EnrollKeysApiCall) { TEST_F(DeviceSyncCryptAuthV2EnrollerImplTest, Failure_EnrollKeysApiCall) {
CallEnroll(GetSampleClientMetadata(), GetSampleClientAppMetadata(), CallEnroll(GetSampleClientMetadata(), GetSampleClientAppMetadata(),
GetSamplePreviousClientDirectivePolicyReference()); GetSamplePreviousClientDirectivePolicyReference());
...@@ -889,7 +894,7 @@ TEST_F(CryptAuthV2EnrollerImplTest, Failure_EnrollKeysApiCall) { ...@@ -889,7 +894,7 @@ TEST_F(CryptAuthV2EnrollerImplTest, Failure_EnrollKeysApiCall) {
enrollment_result()); enrollment_result());
} }
TEST_F(CryptAuthV2EnrollerImplTest, TEST_F(DeviceSyncCryptAuthV2EnrollerImplTest,
Failure_Timeout_WaitingForSyncKeysResponse) { Failure_Timeout_WaitingForSyncKeysResponse) {
CallEnroll(GetSampleClientMetadata(), GetSampleClientAppMetadata(), CallEnroll(GetSampleClientMetadata(), GetSampleClientAppMetadata(),
GetSamplePreviousClientDirectivePolicyReference()); GetSamplePreviousClientDirectivePolicyReference());
...@@ -905,7 +910,8 @@ TEST_F(CryptAuthV2EnrollerImplTest, ...@@ -905,7 +910,8 @@ TEST_F(CryptAuthV2EnrollerImplTest,
enrollment_result()); enrollment_result());
} }
TEST_F(CryptAuthV2EnrollerImplTest, Failure_Timeout_WaitingForKeyCreation) { TEST_F(DeviceSyncCryptAuthV2EnrollerImplTest,
Failure_Timeout_WaitingForKeyCreation) {
CallEnroll(GetSampleClientMetadata(), GetSampleClientAppMetadata(), CallEnroll(GetSampleClientMetadata(), GetSampleClientAppMetadata(),
GetSamplePreviousClientDirectivePolicyReference()); GetSamplePreviousClientDirectivePolicyReference());
...@@ -928,7 +934,7 @@ TEST_F(CryptAuthV2EnrollerImplTest, Failure_Timeout_WaitingForKeyCreation) { ...@@ -928,7 +934,7 @@ TEST_F(CryptAuthV2EnrollerImplTest, Failure_Timeout_WaitingForKeyCreation) {
enrollment_result()); enrollment_result());
} }
TEST_F(CryptAuthV2EnrollerImplTest, TEST_F(DeviceSyncCryptAuthV2EnrollerImplTest,
Failure_Timeout_WaitingForKeyProofComputation) { Failure_Timeout_WaitingForKeyProofComputation) {
CallEnroll(GetSampleClientMetadata(), GetSampleClientAppMetadata(), CallEnroll(GetSampleClientMetadata(), GetSampleClientAppMetadata(),
GetSamplePreviousClientDirectivePolicyReference()); GetSamplePreviousClientDirectivePolicyReference());
...@@ -960,7 +966,7 @@ TEST_F(CryptAuthV2EnrollerImplTest, ...@@ -960,7 +966,7 @@ TEST_F(CryptAuthV2EnrollerImplTest,
enrollment_result()); enrollment_result());
} }
TEST_F(CryptAuthV2EnrollerImplTest, TEST_F(DeviceSyncCryptAuthV2EnrollerImplTest,
Failure_Timeout_WaitingForEnrollKeysResponse) { Failure_Timeout_WaitingForEnrollKeysResponse) {
CallEnroll(GetSampleClientMetadata(), GetSampleClientAppMetadata(), CallEnroll(GetSampleClientMetadata(), GetSampleClientAppMetadata(),
GetSamplePreviousClientDirectivePolicyReference()); GetSamplePreviousClientDirectivePolicyReference());
......
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