Index: chromeos/attestation/attestation_flow_unittest.cc |
diff --git a/chromeos/attestation/attestation_flow_unittest.cc b/chromeos/attestation/attestation_flow_unittest.cc |
index 99b98bd35d409f025c01c1ec2b618ab705a1e716..2e121846b61c1fa1d10c6a602e09a351be4dfea5 100644 |
--- a/chromeos/attestation/attestation_flow_unittest.cc |
+++ b/chromeos/attestation/attestation_flow_unittest.cc |
@@ -8,8 +8,10 @@ |
#include "base/memory/scoped_ptr.h" |
#include "base/run_loop.h" |
#include "chromeos/attestation/mock_attestation_flow.h" |
+#include "chromeos/cryptohome/cryptohome_parameters.h" |
#include "chromeos/cryptohome/mock_async_method_caller.h" |
#include "chromeos/dbus/mock_cryptohome_client.h" |
+#include "components/signin/core/account_id/account_id.h" |
#include "testing/gmock/include/gmock/gmock.h" |
#include "testing/gtest/include/gtest/gtest.h" |
@@ -105,13 +107,13 @@ TEST_F(AttestationFlowTest, GetCertificate) { |
.Times(1) |
.InSequence(flow_order); |
- EXPECT_CALL( |
- async_caller, |
- AsyncTpmAttestationCreateCertRequest(_, |
- PROFILE_ENTERPRISE_USER_CERTIFICATE, |
- "fake@test.com", "fake_origin", _)) |
- .Times(1) |
- .InSequence(flow_order); |
+ const AccountId account_id = AccountId::FromUserEmail("fake@test.com"); |
+ EXPECT_CALL(async_caller, |
+ AsyncTpmAttestationCreateCertRequest( |
+ _, PROFILE_ENTERPRISE_USER_CERTIFICATE, |
+ cryptohome::Identification(account_id), "fake_origin", _)) |
+ .Times(1) |
+ .InSequence(flow_order); |
EXPECT_CALL(*proxy, SendCertificateRequest( |
cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest, |
@@ -121,12 +123,10 @@ TEST_F(AttestationFlowTest, GetCertificate) { |
std::string fake_cert_response = |
cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest; |
fake_cert_response += "_response"; |
- EXPECT_CALL(async_caller, |
- AsyncTpmAttestationFinishCertRequest(fake_cert_response, |
- KEY_USER, |
- "fake@test.com", |
- kEnterpriseUserKey, |
- _)) |
+ EXPECT_CALL(async_caller, AsyncTpmAttestationFinishCertRequest( |
+ fake_cert_response, KEY_USER, |
+ cryptohome::Identification(account_id), |
+ kEnterpriseUserKey, _)) |
.Times(1) |
.InSequence(flow_order); |
@@ -142,7 +142,7 @@ TEST_F(AttestationFlowTest, GetCertificate) { |
scoped_ptr<ServerProxy> proxy_interface(proxy.release()); |
AttestationFlow flow(&async_caller, &client, std::move(proxy_interface)); |
- flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, "fake@test.com", |
+ flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, account_id, |
"fake_origin", true, mock_callback); |
Run(); |
} |
@@ -170,8 +170,8 @@ TEST_F(AttestationFlowTest, GetCertificate_NoEK) { |
scoped_ptr<ServerProxy> proxy_interface(proxy.release()); |
AttestationFlow flow(&async_caller, &client, std::move(proxy_interface)); |
- flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, "", "", true, |
- mock_callback); |
+ flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, EmptyAccountId(), "", |
+ true, mock_callback); |
Run(); |
} |
@@ -201,8 +201,8 @@ TEST_F(AttestationFlowTest, GetCertificate_EKRejected) { |
scoped_ptr<ServerProxy> proxy_interface(proxy.release()); |
AttestationFlow flow(&async_caller, &client, std::move(proxy_interface)); |
- flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, "", "", true, |
- mock_callback); |
+ flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, EmptyAccountId(), "", |
+ true, mock_callback); |
Run(); |
} |
@@ -237,27 +237,25 @@ TEST_F(AttestationFlowTest, GetCertificate_FailEnroll) { |
scoped_ptr<ServerProxy> proxy_interface(proxy.release()); |
AttestationFlow flow(&async_caller, &client, std::move(proxy_interface)); |
- flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, "", "", true, |
- mock_callback); |
+ flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, EmptyAccountId(), "", |
+ true, mock_callback); |
Run(); |
} |
TEST_F(AttestationFlowTest, GetMachineCertificateAlreadyEnrolled) { |
StrictMock<cryptohome::MockAsyncMethodCaller> async_caller; |
async_caller.SetUp(true, cryptohome::MOUNT_ERROR_NONE); |
- EXPECT_CALL(async_caller, |
- AsyncTpmAttestationCreateCertRequest( |
- _, PROFILE_ENTERPRISE_MACHINE_CERTIFICATE, "", "", _)) |
+ EXPECT_CALL(async_caller, AsyncTpmAttestationCreateCertRequest( |
+ _, PROFILE_ENTERPRISE_MACHINE_CERTIFICATE, |
+ cryptohome::Identification(), "", _)) |
.Times(1); |
std::string fake_cert_response = |
cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest; |
fake_cert_response += "_response"; |
EXPECT_CALL(async_caller, |
- AsyncTpmAttestationFinishCertRequest(fake_cert_response, |
- KEY_DEVICE, |
- "", |
- kEnterpriseMachineKey, |
- _)) |
+ AsyncTpmAttestationFinishCertRequest( |
+ fake_cert_response, KEY_DEVICE, cryptohome::Identification(), |
+ kEnterpriseMachineKey, _)) |
.Times(1); |
chromeos::MockCryptohomeClient client; |
@@ -281,17 +279,17 @@ TEST_F(AttestationFlowTest, GetMachineCertificateAlreadyEnrolled) { |
scoped_ptr<ServerProxy> proxy_interface(proxy.release()); |
AttestationFlow flow(&async_caller, &client, std::move(proxy_interface)); |
- flow.GetCertificate(PROFILE_ENTERPRISE_MACHINE_CERTIFICATE, "", "", true, |
- mock_callback); |
+ flow.GetCertificate(PROFILE_ENTERPRISE_MACHINE_CERTIFICATE, EmptyAccountId(), |
+ "", true, mock_callback); |
Run(); |
} |
TEST_F(AttestationFlowTest, GetCertificate_FailCreateCertRequest) { |
StrictMock<cryptohome::MockAsyncMethodCaller> async_caller; |
async_caller.SetUp(false, cryptohome::MOUNT_ERROR_NONE); |
- EXPECT_CALL(async_caller, |
- AsyncTpmAttestationCreateCertRequest( |
- _, PROFILE_ENTERPRISE_USER_CERTIFICATE, "", "", _)) |
+ EXPECT_CALL(async_caller, AsyncTpmAttestationCreateCertRequest( |
+ _, PROFILE_ENTERPRISE_USER_CERTIFICATE, |
+ cryptohome::Identification(), "", _)) |
.Times(1); |
chromeos::MockCryptohomeClient client; |
@@ -310,17 +308,17 @@ TEST_F(AttestationFlowTest, GetCertificate_FailCreateCertRequest) { |
scoped_ptr<ServerProxy> proxy_interface(proxy.release()); |
AttestationFlow flow(&async_caller, &client, std::move(proxy_interface)); |
- flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, "", "", true, |
- mock_callback); |
+ flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, EmptyAccountId(), "", |
+ true, mock_callback); |
Run(); |
} |
TEST_F(AttestationFlowTest, GetCertificate_CertRequestRejected) { |
StrictMock<cryptohome::MockAsyncMethodCaller> async_caller; |
async_caller.SetUp(true, cryptohome::MOUNT_ERROR_NONE); |
- EXPECT_CALL(async_caller, |
- AsyncTpmAttestationCreateCertRequest( |
- _, PROFILE_ENTERPRISE_USER_CERTIFICATE, "", "", _)) |
+ EXPECT_CALL(async_caller, AsyncTpmAttestationCreateCertRequest( |
+ _, PROFILE_ENTERPRISE_USER_CERTIFICATE, |
+ cryptohome::Identification(), "", _)) |
.Times(1); |
chromeos::MockCryptohomeClient client; |
@@ -342,8 +340,8 @@ TEST_F(AttestationFlowTest, GetCertificate_CertRequestRejected) { |
scoped_ptr<ServerProxy> proxy_interface(proxy.release()); |
AttestationFlow flow(&async_caller, &client, std::move(proxy_interface)); |
- flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, "", "", true, |
- mock_callback); |
+ flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, EmptyAccountId(), "", |
+ true, mock_callback); |
Run(); |
} |
@@ -367,34 +365,33 @@ TEST_F(AttestationFlowTest, GetCertificate_FailIsEnrolled) { |
scoped_ptr<ServerProxy> proxy_interface(proxy.release()); |
AttestationFlow flow(&async_caller, &client, std::move(proxy_interface)); |
- flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, "", "", true, |
- mock_callback); |
+ flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, EmptyAccountId(), "", |
+ true, mock_callback); |
Run(); |
} |
TEST_F(AttestationFlowTest, GetCertificate_CheckExisting) { |
StrictMock<cryptohome::MockAsyncMethodCaller> async_caller; |
async_caller.SetUp(true, cryptohome::MOUNT_ERROR_NONE); |
- EXPECT_CALL(async_caller, |
- AsyncTpmAttestationCreateCertRequest( |
- _, PROFILE_ENTERPRISE_USER_CERTIFICATE, "", "", _)) |
+ EXPECT_CALL(async_caller, AsyncTpmAttestationCreateCertRequest( |
+ _, PROFILE_ENTERPRISE_USER_CERTIFICATE, |
+ cryptohome::Identification(), "", _)) |
.Times(1); |
std::string fake_cert_response = |
cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest; |
fake_cert_response += "_response"; |
EXPECT_CALL(async_caller, |
- AsyncTpmAttestationFinishCertRequest(fake_cert_response, |
- KEY_USER, |
- "", |
- kEnterpriseUserKey, |
- _)) |
+ AsyncTpmAttestationFinishCertRequest(fake_cert_response, KEY_USER, |
+ cryptohome::Identification(), |
+ kEnterpriseUserKey, _)) |
.Times(1); |
chromeos::MockCryptohomeClient client; |
EXPECT_CALL(client, TpmAttestationIsEnrolled(_)) |
.WillRepeatedly(Invoke(DBusCallbackTrue)); |
EXPECT_CALL(client, |
- TpmAttestationDoesKeyExist(KEY_USER, "", kEnterpriseUserKey, _)) |
+ TpmAttestationDoesKeyExist(KEY_USER, cryptohome::Identification(), |
+ kEnterpriseUserKey, _)) |
.WillRepeatedly(WithArgs<3>(Invoke(DBusCallbackFalse))); |
scoped_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>()); |
@@ -414,8 +411,8 @@ TEST_F(AttestationFlowTest, GetCertificate_CheckExisting) { |
scoped_ptr<ServerProxy> proxy_interface(proxy.release()); |
AttestationFlow flow(&async_caller, &client, std::move(proxy_interface)); |
- flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, "", "", false, |
- mock_callback); |
+ flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, EmptyAccountId(), "", |
+ false, mock_callback); |
Run(); |
} |
@@ -427,10 +424,12 @@ TEST_F(AttestationFlowTest, GetCertificate_AlreadyExists) { |
EXPECT_CALL(client, TpmAttestationIsEnrolled(_)) |
.WillRepeatedly(Invoke(DBusCallbackTrue)); |
EXPECT_CALL(client, |
- TpmAttestationDoesKeyExist(KEY_USER, "", kEnterpriseUserKey, _)) |
+ TpmAttestationDoesKeyExist(KEY_USER, cryptohome::Identification(), |
+ kEnterpriseUserKey, _)) |
.WillRepeatedly(WithArgs<3>(Invoke(DBusCallbackTrue))); |
- EXPECT_CALL(client, |
- TpmAttestationGetCertificate(KEY_USER, "", kEnterpriseUserKey, _)) |
+ EXPECT_CALL(client, TpmAttestationGetCertificate(KEY_USER, |
+ cryptohome::Identification(), |
+ kEnterpriseUserKey, _)) |
.WillRepeatedly(WithArgs<3>(Invoke(FakeDBusData("fake_cert")))); |
// We're not expecting any server calls in this case; StrictMock will verify. |
@@ -445,8 +444,8 @@ TEST_F(AttestationFlowTest, GetCertificate_AlreadyExists) { |
scoped_ptr<ServerProxy> proxy_interface(proxy.release()); |
AttestationFlow flow(&async_caller, &client, std::move(proxy_interface)); |
- flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, "", "", false, |
- mock_callback); |
+ flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, EmptyAccountId(), "", |
+ false, mock_callback); |
Run(); |
} |
@@ -480,8 +479,8 @@ TEST_F(AttestationFlowTest, AlternatePCA) { |
scoped_ptr<ServerProxy> proxy_interface(proxy.release()); |
AttestationFlow flow(&async_caller, &client, std::move(proxy_interface)); |
- flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, "", "", true, |
- mock_callback); |
+ flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, EmptyAccountId(), "", |
+ true, mock_callback); |
Run(); |
} |