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