Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(282)

Side by Side Diff: remoting/host/policy_watcher_unittest.cc

Issue 2847853003: Remove policy watching from It2MeHost. (Closed)
Patch Set: Fix unit tests Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "remoting/host/policy_watcher.h" 5 #include "remoting/host/policy_watcher.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/json/json_writer.h" 8 #include "base/json/json_writer.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 // Simulate a policy file/registry/preference update. 232 // Simulate a policy file/registry/preference update.
233 policy_loader_->SetPolicies(policy_bundle); 233 policy_loader_->SetPolicies(policy_bundle);
234 policy_loader_->PostReloadOnBackgroundThread(true /* force reload asap */); 234 policy_loader_->PostReloadOnBackgroundThread(true /* force reload asap */);
235 base::RunLoop().RunUntilIdle(); 235 base::RunLoop().RunUntilIdle();
236 } 236 }
237 237
238 const policy::Schema* GetPolicySchema() { 238 const policy::Schema* GetPolicySchema() {
239 return policy_watcher_->GetPolicySchema(); 239 return policy_watcher_->GetPolicySchema();
240 } 240 }
241 241
242 // TODO(jamiewalch): Update this to use PolicyWatcher::GetDefaultValues()
242 const base::DictionaryValue& GetDefaultValues() { 243 const base::DictionaryValue& GetDefaultValues() {
243 return *(policy_watcher_->default_values_); 244 return *(policy_watcher_->default_values_);
244 } 245 }
245 246
246 MOCK_METHOD0(PostPolicyWatcherShutdown, void()); 247 MOCK_METHOD0(PostPolicyWatcherShutdown, void());
247 248
248 static const char* kHostDomain; 249 static const char* kHostDomain;
249 static const char* kClientDomain; 250 static const char* kClientDomain;
250 static const char* kPortRange; 251 static const char* kPortRange;
251 base::MessageLoop message_loop_; 252 base::MessageLoop message_loop_;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 base::DictionaryValue third_party_auth_partial_; 294 base::DictionaryValue third_party_auth_partial_;
294 base::DictionaryValue third_party_auth_cert_empty_; 295 base::DictionaryValue third_party_auth_cert_empty_;
295 base::DictionaryValue remote_assistance_uiaccess_true_; 296 base::DictionaryValue remote_assistance_uiaccess_true_;
296 base::DictionaryValue remote_assistance_uiaccess_false_; 297 base::DictionaryValue remote_assistance_uiaccess_false_;
297 base::DictionaryValue deprecated_policies_; 298 base::DictionaryValue deprecated_policies_;
298 base::DictionaryValue deprecated_policies_expected_; 299 base::DictionaryValue deprecated_policies_expected_;
299 base::DictionaryValue deprecated_and_new_policies_; 300 base::DictionaryValue deprecated_and_new_policies_;
300 base::DictionaryValue deprecated_and_new_policies_expected_; 301 base::DictionaryValue deprecated_and_new_policies_expected_;
301 base::DictionaryValue deprecated_empty_strings_; 302 base::DictionaryValue deprecated_empty_strings_;
302 303
303 private:
rkjnsn 2017/05/03 21:31:47 Is this change related? It doesn't look like you u
Jamie 2017/05/03 23:41:10 You're right; I was using it in an earlier iterati
304 void SetDefaults(base::DictionaryValue& dict) { 304 void SetDefaults(base::DictionaryValue& dict) {
305 dict.SetBoolean(key::kRemoteAccessHostFirewallTraversal, true); 305 dict.SetBoolean(key::kRemoteAccessHostFirewallTraversal, true);
306 dict.SetBoolean(key::kRemoteAccessHostAllowRelayedConnection, true); 306 dict.SetBoolean(key::kRemoteAccessHostAllowRelayedConnection, true);
307 dict.SetString(key::kRemoteAccessHostUdpPortRange, ""); 307 dict.SetString(key::kRemoteAccessHostUdpPortRange, "");
308 dict.Set(key::kRemoteAccessHostClientDomainList, 308 dict.Set(key::kRemoteAccessHostClientDomainList,
309 base::MakeUnique<base::ListValue>()); 309 base::MakeUnique<base::ListValue>());
310 dict.Set(key::kRemoteAccessHostDomainList, 310 dict.Set(key::kRemoteAccessHostDomainList,
311 base::MakeUnique<base::ListValue>()); 311 base::MakeUnique<base::ListValue>());
312 dict.SetBoolean(key::kRemoteAccessHostMatchUsername, false); 312 dict.SetBoolean(key::kRemoteAccessHostMatchUsername, false);
313 dict.SetString(key::kRemoteAccessHostTalkGadgetPrefix, 313 dict.SetString(key::kRemoteAccessHostTalkGadgetPrefix,
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 StartWatching(); 762 StartWatching();
763 } 763 }
764 764
765 TEST_F(PolicyWatcherTest, DeprecatedEmpty) { 765 TEST_F(PolicyWatcherTest, DeprecatedEmpty) {
766 EXPECT_CALL(mock_policy_callback_, 766 EXPECT_CALL(mock_policy_callback_,
767 OnPolicyUpdatePtr(IsPolicies(&GetDefaultValues()))); 767 OnPolicyUpdatePtr(IsPolicies(&GetDefaultValues())));
768 SetPolicies(deprecated_empty_strings_); 768 SetPolicies(deprecated_empty_strings_);
769 StartWatching(); 769 StartWatching();
770 } 770 }
771 771
772 TEST_F(PolicyWatcherTest, GetCurrentPolicies) {
773 testing::InSequence sequence;
774 EXPECT_CALL(mock_policy_callback_,
775 OnPolicyUpdatePtr(IsPolicies(&nat_true_others_default_)));
776 EXPECT_CALL(mock_policy_callback_,
777 OnPolicyUpdatePtr(IsPolicies(&nat_false_)));
778
779 StartWatching();
780 SetPolicies(nat_false_);
781 std::unique_ptr<base::DictionaryValue> current_policies =
782 policy_watcher_->GetCurrentPolicies();
783 ASSERT_TRUE(*current_policies == nat_false_others_default_);
784 }
785
772 } // namespace remoting 786 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698