| 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..2c8ba54721ef8226f8578cba0de2752b530d841f 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,8 +237,8 @@ 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();
|
| }
|
|
|
| @@ -247,17 +247,16 @@ TEST_F(AttestationFlowTest, GetMachineCertificateAlreadyEnrolled) {
|
| async_caller.SetUp(true, cryptohome::MOUNT_ERROR_NONE);
|
| EXPECT_CALL(async_caller,
|
| AsyncTpmAttestationCreateCertRequest(
|
| - _, PROFILE_ENTERPRISE_MACHINE_CERTIFICATE, "", "", _))
|
| + _, PROFILE_ENTERPRISE_MACHINE_CERTIFICATE,
|
| + cryptohome::Identification(EmptyAccountId()), "", _))
|
| .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,
|
| - _))
|
| + EXPECT_CALL(async_caller, AsyncTpmAttestationFinishCertRequest(
|
| + fake_cert_response, KEY_DEVICE,
|
| + cryptohome::Identification(EmptyAccountId()),
|
| + kEnterpriseMachineKey, _))
|
| .Times(1);
|
|
|
| chromeos::MockCryptohomeClient client;
|
| @@ -281,8 +280,8 @@ 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();
|
| }
|
|
|
| @@ -291,7 +290,8 @@ TEST_F(AttestationFlowTest, GetCertificate_FailCreateCertRequest) {
|
| async_caller.SetUp(false, cryptohome::MOUNT_ERROR_NONE);
|
| EXPECT_CALL(async_caller,
|
| AsyncTpmAttestationCreateCertRequest(
|
| - _, PROFILE_ENTERPRISE_USER_CERTIFICATE, "", "", _))
|
| + _, PROFILE_ENTERPRISE_USER_CERTIFICATE,
|
| + cryptohome::Identification(EmptyAccountId()), "", _))
|
| .Times(1);
|
|
|
| chromeos::MockCryptohomeClient client;
|
| @@ -310,8 +310,8 @@ 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();
|
| }
|
|
|
| @@ -320,7 +320,8 @@ TEST_F(AttestationFlowTest, GetCertificate_CertRequestRejected) {
|
| async_caller.SetUp(true, cryptohome::MOUNT_ERROR_NONE);
|
| EXPECT_CALL(async_caller,
|
| AsyncTpmAttestationCreateCertRequest(
|
| - _, PROFILE_ENTERPRISE_USER_CERTIFICATE, "", "", _))
|
| + _, PROFILE_ENTERPRISE_USER_CERTIFICATE,
|
| + cryptohome::Identification(EmptyAccountId()), "", _))
|
| .Times(1);
|
|
|
| chromeos::MockCryptohomeClient client;
|
| @@ -342,8 +343,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,8 +368,8 @@ 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();
|
| }
|
|
|
| @@ -377,17 +378,16 @@ TEST_F(AttestationFlowTest, GetCertificate_CheckExisting) {
|
| async_caller.SetUp(true, cryptohome::MOUNT_ERROR_NONE);
|
| EXPECT_CALL(async_caller,
|
| AsyncTpmAttestationCreateCertRequest(
|
| - _, PROFILE_ENTERPRISE_USER_CERTIFICATE, "", "", _))
|
| + _, PROFILE_ENTERPRISE_USER_CERTIFICATE,
|
| + cryptohome::Identification(EmptyAccountId()), "", _))
|
| .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,
|
| - _))
|
| + EXPECT_CALL(async_caller, AsyncTpmAttestationFinishCertRequest(
|
| + fake_cert_response, KEY_USER,
|
| + cryptohome::Identification(EmptyAccountId()),
|
| + kEnterpriseUserKey, _))
|
| .Times(1);
|
|
|
| chromeos::MockCryptohomeClient client;
|
| @@ -414,8 +414,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();
|
| }
|
|
|
| @@ -430,7 +430,9 @@ TEST_F(AttestationFlowTest, GetCertificate_AlreadyExists) {
|
| TpmAttestationDoesKeyExist(KEY_USER, "", kEnterpriseUserKey, _))
|
| .WillRepeatedly(WithArgs<3>(Invoke(DBusCallbackTrue)));
|
| EXPECT_CALL(client,
|
| - TpmAttestationGetCertificate(KEY_USER, "", kEnterpriseUserKey, _))
|
| + TpmAttestationGetCertificate(
|
| + KEY_USER, cryptohome::Identification(EmptyAccountId()).id(),
|
| + kEnterpriseUserKey, _))
|
| .WillRepeatedly(WithArgs<3>(Invoke(FakeDBusData("fake_cert"))));
|
|
|
| // We're not expecting any server calls in this case; StrictMock will verify.
|
| @@ -445,8 +447,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 +482,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();
|
| }
|
|
|
|
|