| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos.h" | 5 #include "chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 | 47 |
| 48 ACTION_P2(SendSanitizedUsername, call_status, sanitized_username) { | 48 ACTION_P2(SendSanitizedUsername, call_status, sanitized_username) { |
| 49 base::MessageLoop::current()->PostTask( | 49 base::MessageLoop::current()->PostTask( |
| 50 FROM_HERE, base::Bind(arg1, call_status, sanitized_username)); | 50 FROM_HERE, base::Bind(arg1, call_status, sanitized_username)); |
| 51 } | 51 } |
| 52 | 52 |
| 53 class UserCloudPolicyStoreChromeOSTest : public testing::Test { | 53 class UserCloudPolicyStoreChromeOSTest : public testing::Test { |
| 54 protected: | 54 protected: |
| 55 UserCloudPolicyStoreChromeOSTest() {} | 55 UserCloudPolicyStoreChromeOSTest() {} |
| 56 | 56 |
| 57 virtual void SetUp() OVERRIDE { | 57 virtual void SetUp() override { |
| 58 EXPECT_CALL(cryptohome_client_, | 58 EXPECT_CALL(cryptohome_client_, |
| 59 GetSanitizedUsername(PolicyBuilder::kFakeUsername, _)) | 59 GetSanitizedUsername(PolicyBuilder::kFakeUsername, _)) |
| 60 .Times(AnyNumber()) | 60 .Times(AnyNumber()) |
| 61 .WillRepeatedly( | 61 .WillRepeatedly( |
| 62 SendSanitizedUsername(chromeos::DBUS_METHOD_CALL_SUCCESS, | 62 SendSanitizedUsername(chromeos::DBUS_METHOD_CALL_SUCCESS, |
| 63 kSanitizedUsername)); | 63 kSanitizedUsername)); |
| 64 | 64 |
| 65 ASSERT_TRUE(tmp_dir_.CreateUniqueTempDir()); | 65 ASSERT_TRUE(tmp_dir_.CreateUniqueTempDir()); |
| 66 store_.reset(new UserCloudPolicyStoreChromeOS(&cryptohome_client_, | 66 store_.reset(new UserCloudPolicyStoreChromeOS(&cryptohome_client_, |
| 67 &session_manager_client_, | 67 &session_manager_client_, |
| 68 loop_.message_loop_proxy(), | 68 loop_.message_loop_proxy(), |
| 69 PolicyBuilder::kFakeUsername, | 69 PolicyBuilder::kFakeUsername, |
| 70 user_policy_dir(), | 70 user_policy_dir(), |
| 71 token_file(), | 71 token_file(), |
| 72 policy_file())); | 72 policy_file())); |
| 73 store_->AddObserver(&observer_); | 73 store_->AddObserver(&observer_); |
| 74 | 74 |
| 75 // Install the initial public key, so that by default the validation of | 75 // Install the initial public key, so that by default the validation of |
| 76 // the stored/loaded policy blob succeeds. | 76 // the stored/loaded policy blob succeeds. |
| 77 std::vector<uint8> public_key; | 77 std::vector<uint8> public_key; |
| 78 ASSERT_TRUE(policy_.GetSigningKey()->ExportPublicKey(&public_key)); | 78 ASSERT_TRUE(policy_.GetSigningKey()->ExportPublicKey(&public_key)); |
| 79 StoreUserPolicyKey(public_key); | 79 StoreUserPolicyKey(public_key); |
| 80 | 80 |
| 81 policy_.payload().mutable_homepagelocation()->set_value(kDefaultHomepage); | 81 policy_.payload().mutable_homepagelocation()->set_value(kDefaultHomepage); |
| 82 policy_.Build(); | 82 policy_.Build(); |
| 83 } | 83 } |
| 84 | 84 |
| 85 virtual void TearDown() OVERRIDE { | 85 virtual void TearDown() override { |
| 86 store_->RemoveObserver(&observer_); | 86 store_->RemoveObserver(&observer_); |
| 87 store_.reset(); | 87 store_.reset(); |
| 88 RunUntilIdle(); | 88 RunUntilIdle(); |
| 89 } | 89 } |
| 90 | 90 |
| 91 // Install an expectation on |observer_| for an error code. | 91 // Install an expectation on |observer_| for an error code. |
| 92 void ExpectError(CloudPolicyStore::Status error) { | 92 void ExpectError(CloudPolicyStore::Status error) { |
| 93 EXPECT_CALL(observer_, | 93 EXPECT_CALL(observer_, |
| 94 OnStoreError(AllOf(Eq(store_.get()), | 94 OnStoreError(AllOf(Eq(store_.get()), |
| 95 Property(&CloudPolicyStore::status, | 95 Property(&CloudPolicyStore::status, |
| (...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 Mock::VerifyAndClearExpectations(&cryptohome_client_); | 670 Mock::VerifyAndClearExpectations(&cryptohome_client_); |
| 671 | 671 |
| 672 EXPECT_FALSE(store_->policy()); | 672 EXPECT_FALSE(store_->policy()); |
| 673 EXPECT_TRUE(store_->policy_map().empty()); | 673 EXPECT_TRUE(store_->policy_map().empty()); |
| 674 EXPECT_EQ(CloudPolicyStore::STATUS_VALIDATION_ERROR, store_->status()); | 674 EXPECT_EQ(CloudPolicyStore::STATUS_VALIDATION_ERROR, store_->status()); |
| 675 } | 675 } |
| 676 | 676 |
| 677 } // namespace | 677 } // namespace |
| 678 | 678 |
| 679 } // namespace policy | 679 } // namespace policy |
| OLD | NEW |