From 8b85035f732684e92ee738c071882888ca584191 Mon Sep 17 00:00:00 2001 From: "dkrahn@google.com" Date: Wed, 23 Jan 2013 19:53:41 +0000 Subject: Implemented attestation message flow for Chrome OS. Chrome OS has an attestation service which can interact with a Privacy CA in order to generate an attestation certificate. The AttestationFlow class coordinates this interaction. BUG=chromium-os:37806 TEST=unit Review URL: https://chromiumcodereview.appspot.com/11932004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@178354 0039d316-1c4b-4281-b951-d872f2087c98 --- chromeos/cryptohome/mock_async_method_caller.cc | 34 +++++++++++++++++++++++++ chromeos/cryptohome/mock_async_method_caller.h | 8 ++++++ 2 files changed, 42 insertions(+) (limited to 'chromeos/cryptohome') diff --git a/chromeos/cryptohome/mock_async_method_caller.cc b/chromeos/cryptohome/mock_async_method_caller.cc index eb2203c..ce02bd3 100644 --- a/chromeos/cryptohome/mock_async_method_caller.cc +++ b/chromeos/cryptohome/mock_async_method_caller.cc @@ -10,6 +10,10 @@ using ::testing::_; namespace cryptohome { +const char MockAsyncMethodCaller::kFakeAttestationEnrollRequest[] = "enrollreq"; +const char MockAsyncMethodCaller::kFakeAttestationCertRequest[] = "certreq"; +const char MockAsyncMethodCaller::kFakeAttestationCert[] = "cert"; + MockAsyncMethodCaller::MockAsyncMethodCaller() : success_(false), return_code_(cryptohome::MOUNT_ERROR_NONE) { } @@ -34,10 +38,40 @@ void MockAsyncMethodCaller::SetUp(bool success, MountError return_code) { ON_CALL(*this, AsyncRemove(_, _)) .WillByDefault( WithArgs<1>(Invoke(this, &MockAsyncMethodCaller::DoCallback))); + ON_CALL(*this, AsyncTpmAttestationCreateEnrollRequest(_)) + .WillByDefault( + WithArgs<0>(Invoke(this, + &MockAsyncMethodCaller::FakeCreateEnrollRequest))); + ON_CALL(*this, AsyncTpmAttestationEnroll(_, _)) + .WillByDefault( + WithArgs<1>(Invoke(this, &MockAsyncMethodCaller::DoCallback))); + ON_CALL(*this, AsyncTpmAttestationCreateCertRequest(_, _)) + .WillByDefault( + WithArgs<1>(Invoke(this, + &MockAsyncMethodCaller::FakeCreateCertRequest))); + ON_CALL(*this, AsyncTpmAttestationFinishCertRequest(_, _)) + .WillByDefault( + WithArgs<1>(Invoke(this, + &MockAsyncMethodCaller::FakeFinishCertRequest))); } void MockAsyncMethodCaller::DoCallback(Callback callback) { callback.Run(success_, return_code_); } +void MockAsyncMethodCaller::FakeCreateEnrollRequest( + const DataCallback& callback) { + callback.Run(success_, kFakeAttestationEnrollRequest); +} + +void MockAsyncMethodCaller::FakeCreateCertRequest( + const DataCallback& callback) { + callback.Run(success_, kFakeAttestationCertRequest); +} + +void MockAsyncMethodCaller::FakeFinishCertRequest( + const DataCallback& callback) { + callback.Run(success_, kFakeAttestationCert); +} + } // namespace cryptohome diff --git a/chromeos/cryptohome/mock_async_method_caller.h b/chromeos/cryptohome/mock_async_method_caller.h index 37bc0c44..2e8d352 100644 --- a/chromeos/cryptohome/mock_async_method_caller.h +++ b/chromeos/cryptohome/mock_async_method_caller.h @@ -16,6 +16,10 @@ namespace cryptohome { class MockAsyncMethodCaller : public AsyncMethodCaller { public: + static const char kFakeAttestationEnrollRequest[]; + static const char kFakeAttestationCertRequest[]; + static const char kFakeAttestationCert[]; + MockAsyncMethodCaller(); virtual ~MockAsyncMethodCaller(); @@ -50,6 +54,10 @@ class MockAsyncMethodCaller : public AsyncMethodCaller { MountError return_code_; void DoCallback(Callback callback); + // Default fakes for attestation calls. + void FakeCreateEnrollRequest(const DataCallback& callback); + void FakeCreateCertRequest(const DataCallback& callback); + void FakeFinishCertRequest(const DataCallback& callback); DISALLOW_COPY_AND_ASSIGN(MockAsyncMethodCaller); }; -- cgit v1.1