Commit d53cfb6e authored by Maksim Moskvitin's avatar Maksim Moskvitin Committed by Commit Bot

[TrustedVault] Rename RegisterDevice -> RegisterAuthenticationFactor

This CL renames a method in TrustedVaultConnection, to reflect that
there will be authentication factors other than device key.

Bug: 1113598
Change-Id: Ieb84296feac97844fb78bd09f7e3a645bca54fbe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2437378Reviewed-by: default avatarMikel Astiz <mastiz@chromium.org>
Commit-Queue: Maksim Moskvitin <mmoskvitin@google.com>
Cr-Commit-Position: refs/heads/master@{#813185}
parent 6813de41
...@@ -251,7 +251,7 @@ void StandaloneTrustedVaultBackend::MaybeRegisterDevice( ...@@ -251,7 +251,7 @@ void StandaloneTrustedVaultBackend::MaybeRegisterDevice(
// Cancel existing callbacks passed to |connection_| to ensure there is only // Cancel existing callbacks passed to |connection_| to ensure there is only
// one ongoing request. // one ongoing request.
AbandonConnectionRequest(); AbandonConnectionRequest();
connection_->RegisterDevice( connection_->RegisterAuthenticationFactor(
*primary_account_, last_key_bytes, *primary_account_, last_key_bytes,
per_user_vault->last_vault_key_version(), key_pair->public_key(), per_user_vault->last_vault_key_version(), key_pair->public_key(),
base::BindOnce(&StandaloneTrustedVaultBackend::OnDeviceRegistered, base::BindOnce(&StandaloneTrustedVaultBackend::OnDeviceRegistered,
......
...@@ -50,12 +50,12 @@ class MockTrustedVaultConnection : public TrustedVaultConnection { ...@@ -50,12 +50,12 @@ class MockTrustedVaultConnection : public TrustedVaultConnection {
MockTrustedVaultConnection() = default; MockTrustedVaultConnection() = default;
~MockTrustedVaultConnection() override = default; ~MockTrustedVaultConnection() override = default;
MOCK_METHOD5(RegisterDevice, MOCK_METHOD5(RegisterAuthenticationFactor,
void(const CoreAccountInfo&, void(const CoreAccountInfo&,
const std::vector<uint8_t>&, const std::vector<uint8_t>&,
int, int,
const SecureBoxPublicKey&, const SecureBoxPublicKey&,
RegisterDeviceCallback)); RegisterAuthenticationFactorCallback));
MOCK_METHOD5(DownloadKeys, MOCK_METHOD5(DownloadKeys,
void(const CoreAccountInfo&, void(const CoreAccountInfo&,
const std::vector<uint8_t>&, const std::vector<uint8_t>&,
...@@ -99,14 +99,17 @@ class StandaloneTrustedVaultBackendTest : public testing::Test { ...@@ -99,14 +99,17 @@ class StandaloneTrustedVaultBackendTest : public testing::Test {
CoreAccountInfo account_info) { CoreAccountInfo account_info) {
DCHECK(!vault_keys.empty()); DCHECK(!vault_keys.empty());
backend_->StoreKeys(account_info.gaia, vault_keys, last_vault_key_version); backend_->StoreKeys(account_info.gaia, vault_keys, last_vault_key_version);
TrustedVaultConnection::RegisterDeviceCallback device_registration_callback; TrustedVaultConnection::RegisterAuthenticationFactorCallback
device_registration_callback;
EXPECT_CALL(*connection_, EXPECT_CALL(*connection_, RegisterAuthenticationFactor(
RegisterDevice(Eq(account_info), Eq(vault_keys.back()), Eq(account_info), Eq(vault_keys.back()),
Eq(last_vault_key_version), _, _)) Eq(last_vault_key_version), _, _))
.WillOnce([&](const CoreAccountInfo&, const std::vector<uint8_t>&, int, .WillOnce(
[&](const CoreAccountInfo&, const std::vector<uint8_t>&, int,
const SecureBoxPublicKey& device_public_key, const SecureBoxPublicKey& device_public_key,
TrustedVaultConnection::RegisterDeviceCallback callback) { TrustedVaultConnection::RegisterAuthenticationFactorCallback
callback) {
device_registration_callback = std::move(callback); device_registration_callback = std::move(callback);
}); });
// Setting the primary account will trigger device registration. // Setting the primary account will trigger device registration.
...@@ -277,13 +280,16 @@ TEST_F(StandaloneTrustedVaultBackendTest, ShouldRegisterDevice) { ...@@ -277,13 +280,16 @@ TEST_F(StandaloneTrustedVaultBackendTest, ShouldRegisterDevice) {
backend()->StoreKeys(account_info.gaia, {kVaultKey}, kLastKeyVersion); backend()->StoreKeys(account_info.gaia, {kVaultKey}, kLastKeyVersion);
TrustedVaultConnection::RegisterDeviceCallback device_registration_callback; TrustedVaultConnection::RegisterAuthenticationFactorCallback
device_registration_callback;
std::vector<uint8_t> serialized_public_device_key; std::vector<uint8_t> serialized_public_device_key;
EXPECT_CALL(*connection(), RegisterDevice(Eq(account_info), Eq(kVaultKey), EXPECT_CALL(*connection(),
RegisterAuthenticationFactor(Eq(account_info), Eq(kVaultKey),
Eq(kLastKeyVersion), _, _)) Eq(kLastKeyVersion), _, _))
.WillOnce([&](const CoreAccountInfo&, const std::vector<uint8_t>&, int, .WillOnce([&](const CoreAccountInfo&, const std::vector<uint8_t>&, int,
const SecureBoxPublicKey& device_public_key, const SecureBoxPublicKey& device_public_key,
TrustedVaultConnection::RegisterDeviceCallback callback) { TrustedVaultConnection::RegisterAuthenticationFactorCallback
callback) {
serialized_public_device_key = device_public_key.ExportToBytes(); serialized_public_device_key = device_public_key.ExportToBytes();
device_registration_callback = std::move(callback); device_registration_callback = std::move(callback);
}); });
......
...@@ -31,7 +31,7 @@ enum class TrustedVaultRequestStatus { ...@@ -31,7 +31,7 @@ enum class TrustedVaultRequestStatus {
// vault backend sequence. // vault backend sequence.
class TrustedVaultConnection { class TrustedVaultConnection {
public: public:
using RegisterDeviceCallback = using RegisterAuthenticationFactorCallback =
base::OnceCallback<void(TrustedVaultRequestStatus)>; base::OnceCallback<void(TrustedVaultRequestStatus)>;
using DownloadKeysCallback = using DownloadKeysCallback =
base::OnceCallback<void(TrustedVaultRequestStatus, base::OnceCallback<void(TrustedVaultRequestStatus,
...@@ -44,14 +44,15 @@ class TrustedVaultConnection { ...@@ -44,14 +44,15 @@ class TrustedVaultConnection {
delete; delete;
virtual ~TrustedVaultConnection() = default; virtual ~TrustedVaultConnection() = default;
// Asynchronously attempts to register the device on the trusted vault server // Asynchronously attempts to register the authentication factor on the
// to allow further DownloadKeys(). Calls |callback| upon completion. // trusted vault server to allow further vault server API calls using this
virtual void RegisterDevice( // authentication factor. Calls |callback| upon completion.
virtual void RegisterAuthenticationFactor(
const CoreAccountInfo& account_info, const CoreAccountInfo& account_info,
const std::vector<uint8_t>& last_trusted_vault_key, const std::vector<uint8_t>& last_trusted_vault_key,
int last_trusted_vault_key_version, int last_trusted_vault_key_version,
const SecureBoxPublicKey& device_public_key, const SecureBoxPublicKey& authentication_factor_public_key,
RegisterDeviceCallback callback) = 0; RegisterAuthenticationFactorCallback callback) = 0;
// Asynchronously attempts to download new vault keys from the trusted vault // Asynchronously attempts to download new vault keys from the trusted vault
// server. // server.
......
...@@ -16,12 +16,12 @@ TrustedVaultConnectionImpl::TrustedVaultConnectionImpl( ...@@ -16,12 +16,12 @@ TrustedVaultConnectionImpl::TrustedVaultConnectionImpl(
NOTIMPLEMENTED(); NOTIMPLEMENTED();
} }
void TrustedVaultConnectionImpl::RegisterDevice( void TrustedVaultConnectionImpl::RegisterAuthenticationFactor(
const CoreAccountInfo& account_info, const CoreAccountInfo& account_info,
const std::vector<uint8_t>& last_trusted_vault_key, const std::vector<uint8_t>& last_trusted_vault_key,
int last_trusted_vault_key_version, int last_trusted_vault_key_version,
const SecureBoxPublicKey& device_key_pair, const SecureBoxPublicKey& authentication_factor_public_key,
RegisterDeviceCallback callback) { RegisterAuthenticationFactorCallback callback) {
NOTIMPLEMENTED(); NOTIMPLEMENTED();
} }
......
...@@ -32,11 +32,12 @@ class TrustedVaultConnectionImpl : public TrustedVaultConnection { ...@@ -32,11 +32,12 @@ class TrustedVaultConnectionImpl : public TrustedVaultConnection {
const TrustedVaultConnectionImpl& other) = delete; const TrustedVaultConnectionImpl& other) = delete;
~TrustedVaultConnectionImpl() override = default; ~TrustedVaultConnectionImpl() override = default;
void RegisterDevice(const CoreAccountInfo& account_info, void RegisterAuthenticationFactor(
const CoreAccountInfo& account_info,
const std::vector<uint8_t>& last_trusted_vault_key, const std::vector<uint8_t>& last_trusted_vault_key,
int last_trusted_vault_key_version, int last_trusted_vault_key_version,
const SecureBoxPublicKey& device_key_pair, const SecureBoxPublicKey& authentication_factor_public_key,
RegisterDeviceCallback callback) override; RegisterAuthenticationFactorCallback callback) override;
void DownloadKeys(const CoreAccountInfo& account_info, void DownloadKeys(const CoreAccountInfo& account_info,
const std::vector<uint8_t>& last_trusted_vault_key, const std::vector<uint8_t>& last_trusted_vault_key,
......
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