| 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/message_loop.h" | 7 #include "base/message_loop/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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 PolicyWatcher::kHostDomainPolicyName, std::string()); | 61 PolicyWatcher::kHostDomainPolicyName, std::string()); |
| 62 unknown_policies_.SetString("UnknownPolicyOne", std::string()); | 62 unknown_policies_.SetString("UnknownPolicyOne", std::string()); |
| 63 unknown_policies_.SetString("UnknownPolicyTwo", std::string()); | 63 unknown_policies_.SetString("UnknownPolicyTwo", std::string()); |
| 64 | 64 |
| 65 const char kOverrideNatTraversalToFalse[] = | 65 const char kOverrideNatTraversalToFalse[] = |
| 66 "{ \"RemoteAccessHostFirewallTraversal\": false }"; | 66 "{ \"RemoteAccessHostFirewallTraversal\": false }"; |
| 67 nat_true_and_overridden_.SetBoolean(PolicyWatcher::kNatPolicyName, true); | 67 nat_true_and_overridden_.SetBoolean(PolicyWatcher::kNatPolicyName, true); |
| 68 nat_true_and_overridden_.SetString( | 68 nat_true_and_overridden_.SetString( |
| 69 PolicyWatcher::kHostDebugOverridePoliciesName, | 69 PolicyWatcher::kHostDebugOverridePoliciesName, |
| 70 kOverrideNatTraversalToFalse); | 70 kOverrideNatTraversalToFalse); |
| 71 pairing_true_.SetBoolean(PolicyWatcher::kHostAllowClientPairing, true); |
| 72 pairing_false_.SetBoolean(PolicyWatcher::kHostAllowClientPairing, false); |
| 71 #if !defined(NDEBUG) | 73 #if !defined(NDEBUG) |
| 72 SetDefaults(nat_false_overridden_others_default_); | 74 SetDefaults(nat_false_overridden_others_default_); |
| 73 nat_false_overridden_others_default_.SetBoolean( | 75 nat_false_overridden_others_default_.SetBoolean( |
| 74 PolicyWatcher::kNatPolicyName, false); | 76 PolicyWatcher::kNatPolicyName, false); |
| 75 nat_false_overridden_others_default_.SetString( | 77 nat_false_overridden_others_default_.SetString( |
| 76 PolicyWatcher::kHostDebugOverridePoliciesName, | 78 PolicyWatcher::kHostDebugOverridePoliciesName, |
| 77 kOverrideNatTraversalToFalse); | 79 kOverrideNatTraversalToFalse); |
| 78 #endif | 80 #endif |
| 79 } | 81 } |
| 80 | 82 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 108 base::DictionaryValue domain_empty_others_default_; | 110 base::DictionaryValue domain_empty_others_default_; |
| 109 base::DictionaryValue domain_full_others_default_; | 111 base::DictionaryValue domain_full_others_default_; |
| 110 base::DictionaryValue nat_true_domain_empty_; | 112 base::DictionaryValue nat_true_domain_empty_; |
| 111 base::DictionaryValue nat_true_domain_full_; | 113 base::DictionaryValue nat_true_domain_full_; |
| 112 base::DictionaryValue nat_false_domain_empty_; | 114 base::DictionaryValue nat_false_domain_empty_; |
| 113 base::DictionaryValue nat_false_domain_full_; | 115 base::DictionaryValue nat_false_domain_full_; |
| 114 base::DictionaryValue nat_true_domain_empty_others_default_; | 116 base::DictionaryValue nat_true_domain_empty_others_default_; |
| 115 base::DictionaryValue unknown_policies_; | 117 base::DictionaryValue unknown_policies_; |
| 116 base::DictionaryValue nat_true_and_overridden_; | 118 base::DictionaryValue nat_true_and_overridden_; |
| 117 base::DictionaryValue nat_false_overridden_others_default_; | 119 base::DictionaryValue nat_false_overridden_others_default_; |
| 120 base::DictionaryValue pairing_true_; |
| 121 base::DictionaryValue pairing_false_; |
| 118 | 122 |
| 119 private: | 123 private: |
| 120 void SetDefaults(base::DictionaryValue& dict) { | 124 void SetDefaults(base::DictionaryValue& dict) { |
| 121 dict.SetBoolean(PolicyWatcher::kNatPolicyName, true); | 125 dict.SetBoolean(PolicyWatcher::kNatPolicyName, true); |
| 122 dict.SetBoolean(PolicyWatcher::kHostRequireTwoFactorPolicyName, false); | 126 dict.SetBoolean(PolicyWatcher::kHostRequireTwoFactorPolicyName, false); |
| 123 dict.SetString(PolicyWatcher::kHostDomainPolicyName, std::string()); | 127 dict.SetString(PolicyWatcher::kHostDomainPolicyName, std::string()); |
| 124 dict.SetBoolean(PolicyWatcher::kHostMatchUsernamePolicyName, false); | 128 dict.SetBoolean(PolicyWatcher::kHostMatchUsernamePolicyName, false); |
| 125 dict.SetString(PolicyWatcher::kHostTalkGadgetPrefixPolicyName, | 129 dict.SetString(PolicyWatcher::kHostTalkGadgetPrefixPolicyName, |
| 126 kDefaultHostTalkGadgetPrefix); | 130 kDefaultHostTalkGadgetPrefix); |
| 127 dict.SetBoolean(PolicyWatcher::kHostRequireCurtainPolicyName, false); | 131 dict.SetBoolean(PolicyWatcher::kHostRequireCurtainPolicyName, false); |
| 128 dict.SetString(PolicyWatcher::kHostTokenUrlPolicyName, std::string()); | 132 dict.SetString(PolicyWatcher::kHostTokenUrlPolicyName, std::string()); |
| 129 dict.SetString(PolicyWatcher::kHostTokenValidationUrlPolicyName, | 133 dict.SetString(PolicyWatcher::kHostTokenValidationUrlPolicyName, |
| 130 std::string()); | 134 std::string()); |
| 135 dict.SetBoolean(PolicyWatcher::kHostAllowClientPairing, true); |
| 131 #if !defined(NDEBUG) | 136 #if !defined(NDEBUG) |
| 132 dict.SetString(PolicyWatcher::kHostDebugOverridePoliciesName, ""); | 137 dict.SetString(PolicyWatcher::kHostDebugOverridePoliciesName, ""); |
| 133 #endif | 138 #endif |
| 134 } | 139 } |
| 135 }; | 140 }; |
| 136 | 141 |
| 137 const char* PolicyWatcherTest::kHostDomain = "google.com"; | 142 const char* PolicyWatcherTest::kHostDomain = "google.com"; |
| 138 | 143 |
| 139 MATCHER_P(IsPolicies, dict, "") { | 144 MATCHER_P(IsPolicies, dict, "") { |
| 140 return arg->Equals(dict); | 145 return arg->Equals(dict); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 #else | 306 #else |
| 302 EXPECT_CALL(mock_policy_callback_, | 307 EXPECT_CALL(mock_policy_callback_, |
| 303 OnPolicyUpdatePtr(IsPolicies(&nat_true_others_default_))); | 308 OnPolicyUpdatePtr(IsPolicies(&nat_true_others_default_))); |
| 304 #endif | 309 #endif |
| 305 | 310 |
| 306 StartWatching(); | 311 StartWatching(); |
| 307 policy_watcher_->SetPolicies(&nat_true_and_overridden_); | 312 policy_watcher_->SetPolicies(&nat_true_and_overridden_); |
| 308 StopWatching(); | 313 StopWatching(); |
| 309 } | 314 } |
| 310 | 315 |
| 316 TEST_F(PolicyWatcherTest, PairingFalseThenTrue) { |
| 317 testing::InSequence sequence; |
| 318 EXPECT_CALL(mock_policy_callback_, |
| 319 OnPolicyUpdatePtr(IsPolicies(&nat_true_others_default_))); |
| 320 EXPECT_CALL(mock_policy_callback_, |
| 321 OnPolicyUpdatePtr(IsPolicies(&pairing_false_))); |
| 322 EXPECT_CALL(mock_policy_callback_, |
| 323 OnPolicyUpdatePtr(IsPolicies(&pairing_true_))); |
| 324 |
| 325 StartWatching(); |
| 326 policy_watcher_->SetPolicies(&empty_); |
| 327 policy_watcher_->SetPolicies(&pairing_false_); |
| 328 policy_watcher_->SetPolicies(&pairing_true_); |
| 329 StopWatching(); |
| 330 } |
| 331 |
| 311 } // namespace policy_hack | 332 } // namespace policy_hack |
| 312 } // namespace remoting | 333 } // namespace remoting |
| OLD | NEW |