| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/synchronization/waitable_event.h" | 8 #include "base/synchronization/waitable_event.h" |
| 9 #include "remoting/host/dns_blackhole_checker.h" | 9 #include "remoting/host/dns_blackhole_checker.h" |
| 10 #include "remoting/host/policy_hack/fake_policy_watcher.h" | 10 #include "remoting/host/policy_hack/fake_policy_watcher.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 } | 22 } |
| 23 | 23 |
| 24 virtual void SetUp() OVERRIDE { | 24 virtual void SetUp() OVERRIDE { |
| 25 message_loop_proxy_ = base::MessageLoopProxy::current(); | 25 message_loop_proxy_ = base::MessageLoopProxy::current(); |
| 26 policy_callback_ = base::Bind(&MockPolicyCallback::OnPolicyUpdate, | 26 policy_callback_ = base::Bind(&MockPolicyCallback::OnPolicyUpdate, |
| 27 base::Unretained(&mock_policy_callback_)); | 27 base::Unretained(&mock_policy_callback_)); |
| 28 policy_watcher_.reset(new FakePolicyWatcher(message_loop_proxy_)); | 28 policy_watcher_.reset(new FakePolicyWatcher(message_loop_proxy_)); |
| 29 nat_true_.SetBoolean(PolicyWatcher::kNatPolicyName, true); | 29 nat_true_.SetBoolean(PolicyWatcher::kNatPolicyName, true); |
| 30 nat_false_.SetBoolean(PolicyWatcher::kNatPolicyName, false); | 30 nat_false_.SetBoolean(PolicyWatcher::kNatPolicyName, false); |
| 31 nat_one_.SetInteger(PolicyWatcher::kNatPolicyName, 1); | 31 nat_one_.SetInteger(PolicyWatcher::kNatPolicyName, 1); |
| 32 domain_empty_.SetString(PolicyWatcher::kHostDomainPolicyName, ""); | 32 domain_empty_.SetString(PolicyWatcher::kHostDomainPolicyName, |
| 33 std::string()); |
| 33 domain_full_.SetString(PolicyWatcher::kHostDomainPolicyName, kHostDomain); | 34 domain_full_.SetString(PolicyWatcher::kHostDomainPolicyName, kHostDomain); |
| 34 SetDefaults(nat_true_others_default_); | 35 SetDefaults(nat_true_others_default_); |
| 35 nat_true_others_default_.SetBoolean(PolicyWatcher::kNatPolicyName, true); | 36 nat_true_others_default_.SetBoolean(PolicyWatcher::kNatPolicyName, true); |
| 36 SetDefaults(nat_false_others_default_); | 37 SetDefaults(nat_false_others_default_); |
| 37 nat_false_others_default_.SetBoolean(PolicyWatcher::kNatPolicyName, false); | 38 nat_false_others_default_.SetBoolean(PolicyWatcher::kNatPolicyName, false); |
| 38 SetDefaults(domain_empty_others_default_); | 39 SetDefaults(domain_empty_others_default_); |
| 39 domain_empty_others_default_.SetString(PolicyWatcher::kHostDomainPolicyName, | 40 domain_empty_others_default_.SetString(PolicyWatcher::kHostDomainPolicyName, |
| 40 ""); | 41 std::string()); |
| 41 SetDefaults(domain_full_others_default_); | 42 SetDefaults(domain_full_others_default_); |
| 42 domain_full_others_default_.SetString(PolicyWatcher::kHostDomainPolicyName, | 43 domain_full_others_default_.SetString(PolicyWatcher::kHostDomainPolicyName, |
| 43 kHostDomain); | 44 kHostDomain); |
| 44 nat_true_domain_empty_.SetBoolean(PolicyWatcher::kNatPolicyName, true); | 45 nat_true_domain_empty_.SetBoolean(PolicyWatcher::kNatPolicyName, true); |
| 45 nat_true_domain_empty_.SetString(PolicyWatcher::kHostDomainPolicyName, ""); | 46 nat_true_domain_empty_.SetString(PolicyWatcher::kHostDomainPolicyName, |
| 47 std::string()); |
| 46 nat_true_domain_full_.SetBoolean(PolicyWatcher::kNatPolicyName, true); | 48 nat_true_domain_full_.SetBoolean(PolicyWatcher::kNatPolicyName, true); |
| 47 nat_true_domain_full_.SetString(PolicyWatcher::kHostDomainPolicyName, | 49 nat_true_domain_full_.SetString(PolicyWatcher::kHostDomainPolicyName, |
| 48 kHostDomain); | 50 kHostDomain); |
| 49 nat_false_domain_empty_.SetBoolean(PolicyWatcher::kNatPolicyName, false); | 51 nat_false_domain_empty_.SetBoolean(PolicyWatcher::kNatPolicyName, false); |
| 50 nat_false_domain_empty_.SetString(PolicyWatcher::kHostDomainPolicyName, ""); | 52 nat_false_domain_empty_.SetString(PolicyWatcher::kHostDomainPolicyName, |
| 53 std::string()); |
| 51 nat_false_domain_full_.SetBoolean(PolicyWatcher::kNatPolicyName, false); | 54 nat_false_domain_full_.SetBoolean(PolicyWatcher::kNatPolicyName, false); |
| 52 nat_false_domain_full_.SetString(PolicyWatcher::kHostDomainPolicyName, | 55 nat_false_domain_full_.SetString(PolicyWatcher::kHostDomainPolicyName, |
| 53 kHostDomain); | 56 kHostDomain); |
| 54 SetDefaults(nat_true_domain_empty_others_default_); | 57 SetDefaults(nat_true_domain_empty_others_default_); |
| 55 nat_true_domain_empty_others_default_.SetBoolean( | 58 nat_true_domain_empty_others_default_.SetBoolean( |
| 56 PolicyWatcher::kNatPolicyName, true); | 59 PolicyWatcher::kNatPolicyName, true); |
| 57 nat_true_domain_empty_others_default_.SetString( | 60 nat_true_domain_empty_others_default_.SetString( |
| 58 PolicyWatcher::kHostDomainPolicyName, ""); | 61 PolicyWatcher::kHostDomainPolicyName, std::string()); |
| 59 unknown_policies_.SetString("UnknownPolicyOne", ""); | 62 unknown_policies_.SetString("UnknownPolicyOne", std::string()); |
| 60 unknown_policies_.SetString("UnknownPolicyTwo", ""); | 63 unknown_policies_.SetString("UnknownPolicyTwo", std::string()); |
| 61 | 64 |
| 62 const char kOverrideNatTraversalToFalse[] = | 65 const char kOverrideNatTraversalToFalse[] = |
| 63 "{ \"RemoteAccessHostFirewallTraversal\": false }"; | 66 "{ \"RemoteAccessHostFirewallTraversal\": false }"; |
| 64 nat_true_and_overridden_.SetBoolean(PolicyWatcher::kNatPolicyName, true); | 67 nat_true_and_overridden_.SetBoolean(PolicyWatcher::kNatPolicyName, true); |
| 65 nat_true_and_overridden_.SetString( | 68 nat_true_and_overridden_.SetString( |
| 66 PolicyWatcher::kHostDebugOverridePoliciesName, | 69 PolicyWatcher::kHostDebugOverridePoliciesName, |
| 67 kOverrideNatTraversalToFalse); | 70 kOverrideNatTraversalToFalse); |
| 68 #if !defined(NDEBUG) | 71 #if !defined(NDEBUG) |
| 69 SetDefaults(nat_false_overridden_others_default_); | 72 SetDefaults(nat_false_overridden_others_default_); |
| 70 nat_false_overridden_others_default_.SetBoolean( | 73 nat_false_overridden_others_default_.SetBoolean( |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 base::DictionaryValue nat_false_domain_full_; | 113 base::DictionaryValue nat_false_domain_full_; |
| 111 base::DictionaryValue nat_true_domain_empty_others_default_; | 114 base::DictionaryValue nat_true_domain_empty_others_default_; |
| 112 base::DictionaryValue unknown_policies_; | 115 base::DictionaryValue unknown_policies_; |
| 113 base::DictionaryValue nat_true_and_overridden_; | 116 base::DictionaryValue nat_true_and_overridden_; |
| 114 base::DictionaryValue nat_false_overridden_others_default_; | 117 base::DictionaryValue nat_false_overridden_others_default_; |
| 115 | 118 |
| 116 private: | 119 private: |
| 117 void SetDefaults(base::DictionaryValue& dict) { | 120 void SetDefaults(base::DictionaryValue& dict) { |
| 118 dict.SetBoolean(PolicyWatcher::kNatPolicyName, true); | 121 dict.SetBoolean(PolicyWatcher::kNatPolicyName, true); |
| 119 dict.SetBoolean(PolicyWatcher::kHostRequireTwoFactorPolicyName, false); | 122 dict.SetBoolean(PolicyWatcher::kHostRequireTwoFactorPolicyName, false); |
| 120 dict.SetString(PolicyWatcher::kHostDomainPolicyName, ""); | 123 dict.SetString(PolicyWatcher::kHostDomainPolicyName, std::string()); |
| 121 dict.SetBoolean(PolicyWatcher::kHostMatchUsernamePolicyName, false); | 124 dict.SetBoolean(PolicyWatcher::kHostMatchUsernamePolicyName, false); |
| 122 dict.SetString(PolicyWatcher::kHostTalkGadgetPrefixPolicyName, | 125 dict.SetString(PolicyWatcher::kHostTalkGadgetPrefixPolicyName, |
| 123 kDefaultHostTalkGadgetPrefix); | 126 kDefaultHostTalkGadgetPrefix); |
| 124 dict.SetBoolean(PolicyWatcher::kHostRequireCurtainPolicyName, false); | 127 dict.SetBoolean(PolicyWatcher::kHostRequireCurtainPolicyName, false); |
| 125 dict.SetString(PolicyWatcher::kHostTokenUrlPolicyName, ""); | 128 dict.SetString(PolicyWatcher::kHostTokenUrlPolicyName, std::string()); |
| 126 dict.SetString(PolicyWatcher::kHostTokenValidationUrlPolicyName, ""); | 129 dict.SetString(PolicyWatcher::kHostTokenValidationUrlPolicyName, |
| 130 std::string()); |
| 127 #if !defined(NDEBUG) | 131 #if !defined(NDEBUG) |
| 128 dict.SetString(PolicyWatcher::kHostDebugOverridePoliciesName, ""); | 132 dict.SetString(PolicyWatcher::kHostDebugOverridePoliciesName, ""); |
| 129 #endif | 133 #endif |
| 130 } | 134 } |
| 131 }; | 135 }; |
| 132 | 136 |
| 133 const char* PolicyWatcherTest::kHostDomain = "google.com"; | 137 const char* PolicyWatcherTest::kHostDomain = "google.com"; |
| 134 | 138 |
| 135 MATCHER_P(IsPolicies, dict, "") { | 139 MATCHER_P(IsPolicies, dict, "") { |
| 136 return arg->Equals(dict); | 140 return arg->Equals(dict); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 OnPolicyUpdatePtr(IsPolicies(&nat_true_others_default_))); | 303 OnPolicyUpdatePtr(IsPolicies(&nat_true_others_default_))); |
| 300 #endif | 304 #endif |
| 301 | 305 |
| 302 StartWatching(); | 306 StartWatching(); |
| 303 policy_watcher_->SetPolicies(&nat_true_and_overridden_); | 307 policy_watcher_->SetPolicies(&nat_true_and_overridden_); |
| 304 StopWatching(); | 308 StopWatching(); |
| 305 } | 309 } |
| 306 | 310 |
| 307 } // namespace policy_hack | 311 } // namespace policy_hack |
| 308 } // namespace remoting | 312 } // namespace remoting |
| OLD | NEW |