diff options
Diffstat (limited to 'chromeos')
-rw-r--r-- | chromeos/cryptohome/async_method_caller.cc | 18 | ||||
-rw-r--r-- | chromeos/cryptohome/async_method_caller.h | 7 | ||||
-rw-r--r-- | chromeos/cryptohome/mock_async_method_caller.cc | 11 | ||||
-rw-r--r-- | chromeos/cryptohome/mock_async_method_caller.h | 5 |
4 files changed, 41 insertions, 0 deletions
diff --git a/chromeos/cryptohome/async_method_caller.cc b/chromeos/cryptohome/async_method_caller.cc index aa25658..4de4f76 100644 --- a/chromeos/cryptohome/async_method_caller.cc +++ b/chromeos/cryptohome/async_method_caller.cc @@ -131,6 +131,24 @@ class AsyncMethodCallerImpl : public AsyncMethodCaller { "Couldn't initiate async attestation finish cert request.")); } + virtual void AsyncGetSanitizedUsername( + const std::string& user, + const DataCallback& callback) OVERRIDE { + DBusThreadManager::Get()->GetCryptohomeClient()-> + GetSanitizedUsername(user, + base::Bind( + &AsyncMethodCallerImpl::GetSanitizedUsernameCallback, + weak_ptr_factory_.GetWeakPtr(), + callback)); + } + + virtual void GetSanitizedUsernameCallback( + const DataCallback& callback, + const chromeos::DBusMethodCallStatus call_status, + const std::string& result) { + callback.Run(true, result); + } + private: struct CallbackElement { CallbackElement() {} diff --git a/chromeos/cryptohome/async_method_caller.h b/chromeos/cryptohome/async_method_caller.h index c6956ff..78ff687 100644 --- a/chromeos/cryptohome/async_method_caller.h +++ b/chromeos/cryptohome/async_method_caller.h @@ -110,6 +110,13 @@ class CHROMEOS_EXPORT AsyncMethodCaller { const std::string& pca_response, const DataCallback& callback) = 0; + // Asks cryptohome to asynchronously retrieve a string associated with given + // |user| that would be used in mount path instead of |user|. + // On success the data is sent to |callback|. + virtual void AsyncGetSanitizedUsername( + const std::string& user, + const DataCallback& callback) = 0; + // Creates the global AsyncMethodCaller instance. static void Initialize(); diff --git a/chromeos/cryptohome/mock_async_method_caller.cc b/chromeos/cryptohome/mock_async_method_caller.cc index ce02bd3..e17da7f 100644 --- a/chromeos/cryptohome/mock_async_method_caller.cc +++ b/chromeos/cryptohome/mock_async_method_caller.cc @@ -13,6 +13,7 @@ namespace cryptohome { const char MockAsyncMethodCaller::kFakeAttestationEnrollRequest[] = "enrollreq"; const char MockAsyncMethodCaller::kFakeAttestationCertRequest[] = "certreq"; const char MockAsyncMethodCaller::kFakeAttestationCert[] = "cert"; +const char MockAsyncMethodCaller::kFakeSanitizedUsername[] = "01234567890ABC"; MockAsyncMethodCaller::MockAsyncMethodCaller() : success_(false), return_code_(cryptohome::MOUNT_ERROR_NONE) { @@ -53,6 +54,11 @@ void MockAsyncMethodCaller::SetUp(bool success, MountError return_code) { .WillByDefault( WithArgs<1>(Invoke(this, &MockAsyncMethodCaller::FakeFinishCertRequest))); + ON_CALL(*this, AsyncGetSanitizedUsername(_, _)) + .WillByDefault( + WithArgs<1>(Invoke(this, + &MockAsyncMethodCaller:: + FakeGetSanitizedUsername))); } void MockAsyncMethodCaller::DoCallback(Callback callback) { @@ -74,4 +80,9 @@ void MockAsyncMethodCaller::FakeFinishCertRequest( callback.Run(success_, kFakeAttestationCert); } +void MockAsyncMethodCaller::FakeGetSanitizedUsername( + const DataCallback& callback) { + callback.Run(success_, kFakeSanitizedUsername); +} + } // namespace cryptohome diff --git a/chromeos/cryptohome/mock_async_method_caller.h b/chromeos/cryptohome/mock_async_method_caller.h index 2e8d352..62df8e4 100644 --- a/chromeos/cryptohome/mock_async_method_caller.h +++ b/chromeos/cryptohome/mock_async_method_caller.h @@ -19,6 +19,7 @@ class MockAsyncMethodCaller : public AsyncMethodCaller { static const char kFakeAttestationEnrollRequest[]; static const char kFakeAttestationCertRequest[]; static const char kFakeAttestationCert[]; + static const char kFakeSanitizedUsername[]; MockAsyncMethodCaller(); virtual ~MockAsyncMethodCaller(); @@ -48,6 +49,9 @@ class MockAsyncMethodCaller : public AsyncMethodCaller { MOCK_METHOD2(AsyncTpmAttestationFinishCertRequest, void(const std::string& pca_response, const DataCallback& callback)); + MOCK_METHOD2(AsyncGetSanitizedUsername, + void(const std::string& user, + const DataCallback& callback)); private: bool success_; @@ -58,6 +62,7 @@ class MockAsyncMethodCaller : public AsyncMethodCaller { void FakeCreateEnrollRequest(const DataCallback& callback); void FakeCreateCertRequest(const DataCallback& callback); void FakeFinishCertRequest(const DataCallback& callback); + void FakeGetSanitizedUsername(const DataCallback& callback); DISALLOW_COPY_AND_ASSIGN(MockAsyncMethodCaller); }; |