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

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

Issue 2847853003: Remove policy watching from It2MeHost. (Closed)
Patch Set: Remove pending policies from It2MeNativeMessagingHost and add an accessor to PolicyWatcher. 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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 base::DictionaryValue curtain_false_; 238 base::DictionaryValue curtain_false_;
239 base::DictionaryValue username_true_; 239 base::DictionaryValue username_true_;
240 base::DictionaryValue username_false_; 240 base::DictionaryValue username_false_;
241 base::DictionaryValue talk_gadget_blah_; 241 base::DictionaryValue talk_gadget_blah_;
242 base::DictionaryValue third_party_auth_full_; 242 base::DictionaryValue third_party_auth_full_;
243 base::DictionaryValue third_party_auth_partial_; 243 base::DictionaryValue third_party_auth_partial_;
244 base::DictionaryValue third_party_auth_cert_empty_; 244 base::DictionaryValue third_party_auth_cert_empty_;
245 base::DictionaryValue remote_assistance_uiaccess_true_; 245 base::DictionaryValue remote_assistance_uiaccess_true_;
246 base::DictionaryValue remote_assistance_uiaccess_false_; 246 base::DictionaryValue remote_assistance_uiaccess_false_;
247 247
248 private:
249 void SetDefaults(base::DictionaryValue& dict) { 248 void SetDefaults(base::DictionaryValue& dict) {
250 dict.SetBoolean(key::kRemoteAccessHostFirewallTraversal, true); 249 dict.SetBoolean(key::kRemoteAccessHostFirewallTraversal, true);
251 dict.SetBoolean(key::kRemoteAccessHostAllowRelayedConnection, true); 250 dict.SetBoolean(key::kRemoteAccessHostAllowRelayedConnection, true);
252 dict.SetString(key::kRemoteAccessHostUdpPortRange, ""); 251 dict.SetString(key::kRemoteAccessHostUdpPortRange, "");
253 dict.SetString(key::kRemoteAccessHostClientDomain, std::string()); 252 dict.SetString(key::kRemoteAccessHostClientDomain, std::string());
254 dict.SetString(key::kRemoteAccessHostDomain, std::string()); 253 dict.SetString(key::kRemoteAccessHostDomain, std::string());
255 dict.SetBoolean(key::kRemoteAccessHostMatchUsername, false); 254 dict.SetBoolean(key::kRemoteAccessHostMatchUsername, false);
256 dict.SetString(key::kRemoteAccessHostTalkGadgetPrefix, 255 dict.SetString(key::kRemoteAccessHostTalkGadgetPrefix,
257 kDefaultHostTalkGadgetPrefix); 256 kDefaultHostTalkGadgetPrefix);
258 dict.SetBoolean(key::kRemoteAccessHostRequireCurtain, false); 257 dict.SetBoolean(key::kRemoteAccessHostRequireCurtain, false);
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 EXPECT_EQ(string_schema.type(), base::Value::Type::STRING); 676 EXPECT_EQ(string_schema.type(), base::Value::Type::STRING);
678 677
679 // And check one, random "boolean" policy to see if the type propagated 678 // And check one, random "boolean" policy to see if the type propagated
680 // correctly from policy_templates.json file. 679 // correctly from policy_templates.json file.
681 const policy::Schema boolean_schema = 680 const policy::Schema boolean_schema =
682 schema->GetKnownProperty("RemoteAccessHostRequireCurtain"); 681 schema->GetKnownProperty("RemoteAccessHostRequireCurtain");
683 EXPECT_TRUE(boolean_schema.valid()); 682 EXPECT_TRUE(boolean_schema.valid());
684 EXPECT_EQ(boolean_schema.type(), base::Value::Type::BOOLEAN); 683 EXPECT_EQ(boolean_schema.type(), base::Value::Type::BOOLEAN);
685 } 684 }
686 685
686 TEST_F(PolicyWatcherTest, GetCurrentPolicies) {
687 base::DictionaryValue dummy_domain, dummy_domain_plus_defaults;
688 dummy_domain.SetString(key::kRemoteAccessHostDomain, "dummy");
689 SetDefaults(dummy_domain_plus_defaults);
690 dummy_domain_plus_defaults.SetString(key::kRemoteAccessHostDomain, "dummy");
691
692 testing::InSequence sequence;
693 EXPECT_CALL(mock_policy_callback_,
694 OnPolicyUpdatePtr(IsPolicies(&nat_true_others_default_)));
695 EXPECT_CALL(mock_policy_callback_,
696 OnPolicyUpdatePtr(IsPolicies(&dummy_domain)));
697
698 StartWatching();
699 SetPolicies(dummy_domain);
700 std::unique_ptr<base::DictionaryValue> current_policies =
701 policy_watcher_->GetCurrentPolicies();
702 ASSERT_TRUE(*current_policies == dummy_domain_plus_defaults);
703 }
704
687 } // namespace remoting 705 } // namespace remoting
OLDNEW
« remoting/host/it2me/it2me_host_unittest.cc ('K') | « remoting/host/policy_watcher.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698