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/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
10 #include "remoting/host/dns_blackhole_checker.h" | 10 #include "remoting/host/dns_blackhole_checker.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 unknown_policies_.SetString("UnknownPolicyTwo", std::string()); | 64 unknown_policies_.SetString("UnknownPolicyTwo", std::string()); |
65 | 65 |
66 const char kOverrideNatTraversalToFalse[] = | 66 const char kOverrideNatTraversalToFalse[] = |
67 "{ \"RemoteAccessHostFirewallTraversal\": false }"; | 67 "{ \"RemoteAccessHostFirewallTraversal\": false }"; |
68 nat_true_and_overridden_.SetBoolean(PolicyWatcher::kNatPolicyName, true); | 68 nat_true_and_overridden_.SetBoolean(PolicyWatcher::kNatPolicyName, true); |
69 nat_true_and_overridden_.SetString( | 69 nat_true_and_overridden_.SetString( |
70 PolicyWatcher::kHostDebugOverridePoliciesName, | 70 PolicyWatcher::kHostDebugOverridePoliciesName, |
71 kOverrideNatTraversalToFalse); | 71 kOverrideNatTraversalToFalse); |
72 pairing_true_.SetBoolean(PolicyWatcher::kHostAllowClientPairing, true); | 72 pairing_true_.SetBoolean(PolicyWatcher::kHostAllowClientPairing, true); |
73 pairing_false_.SetBoolean(PolicyWatcher::kHostAllowClientPairing, false); | 73 pairing_false_.SetBoolean(PolicyWatcher::kHostAllowClientPairing, false); |
| 74 gnubby_auth_true_.SetBoolean(PolicyWatcher::kHostAllowGnubbyAuthPolicyName, |
| 75 true); |
| 76 gnubby_auth_false_.SetBoolean(PolicyWatcher::kHostAllowGnubbyAuthPolicyName, |
| 77 false); |
74 #if !defined(NDEBUG) | 78 #if !defined(NDEBUG) |
75 SetDefaults(nat_false_overridden_others_default_); | 79 SetDefaults(nat_false_overridden_others_default_); |
76 nat_false_overridden_others_default_.SetBoolean( | 80 nat_false_overridden_others_default_.SetBoolean( |
77 PolicyWatcher::kNatPolicyName, false); | 81 PolicyWatcher::kNatPolicyName, false); |
78 nat_false_overridden_others_default_.SetString( | 82 nat_false_overridden_others_default_.SetString( |
79 PolicyWatcher::kHostDebugOverridePoliciesName, | 83 PolicyWatcher::kHostDebugOverridePoliciesName, |
80 kOverrideNatTraversalToFalse); | 84 kOverrideNatTraversalToFalse); |
81 #endif | 85 #endif |
82 } | 86 } |
83 | 87 |
(...skipping 29 matching lines...) Expand all Loading... |
113 base::DictionaryValue nat_true_domain_empty_; | 117 base::DictionaryValue nat_true_domain_empty_; |
114 base::DictionaryValue nat_true_domain_full_; | 118 base::DictionaryValue nat_true_domain_full_; |
115 base::DictionaryValue nat_false_domain_empty_; | 119 base::DictionaryValue nat_false_domain_empty_; |
116 base::DictionaryValue nat_false_domain_full_; | 120 base::DictionaryValue nat_false_domain_full_; |
117 base::DictionaryValue nat_true_domain_empty_others_default_; | 121 base::DictionaryValue nat_true_domain_empty_others_default_; |
118 base::DictionaryValue unknown_policies_; | 122 base::DictionaryValue unknown_policies_; |
119 base::DictionaryValue nat_true_and_overridden_; | 123 base::DictionaryValue nat_true_and_overridden_; |
120 base::DictionaryValue nat_false_overridden_others_default_; | 124 base::DictionaryValue nat_false_overridden_others_default_; |
121 base::DictionaryValue pairing_true_; | 125 base::DictionaryValue pairing_true_; |
122 base::DictionaryValue pairing_false_; | 126 base::DictionaryValue pairing_false_; |
| 127 base::DictionaryValue gnubby_auth_true_; |
| 128 base::DictionaryValue gnubby_auth_false_; |
123 | 129 |
124 private: | 130 private: |
125 void SetDefaults(base::DictionaryValue& dict) { | 131 void SetDefaults(base::DictionaryValue& dict) { |
126 dict.SetBoolean(PolicyWatcher::kNatPolicyName, true); | 132 dict.SetBoolean(PolicyWatcher::kNatPolicyName, true); |
127 dict.SetBoolean(PolicyWatcher::kHostRequireTwoFactorPolicyName, false); | 133 dict.SetBoolean(PolicyWatcher::kHostRequireTwoFactorPolicyName, false); |
128 dict.SetString(PolicyWatcher::kHostDomainPolicyName, std::string()); | 134 dict.SetString(PolicyWatcher::kHostDomainPolicyName, std::string()); |
129 dict.SetBoolean(PolicyWatcher::kHostMatchUsernamePolicyName, false); | 135 dict.SetBoolean(PolicyWatcher::kHostMatchUsernamePolicyName, false); |
130 dict.SetString(PolicyWatcher::kHostTalkGadgetPrefixPolicyName, | 136 dict.SetString(PolicyWatcher::kHostTalkGadgetPrefixPolicyName, |
131 kDefaultHostTalkGadgetPrefix); | 137 kDefaultHostTalkGadgetPrefix); |
132 dict.SetBoolean(PolicyWatcher::kHostRequireCurtainPolicyName, false); | 138 dict.SetBoolean(PolicyWatcher::kHostRequireCurtainPolicyName, false); |
133 dict.SetString(PolicyWatcher::kHostTokenUrlPolicyName, std::string()); | 139 dict.SetString(PolicyWatcher::kHostTokenUrlPolicyName, std::string()); |
134 dict.SetString(PolicyWatcher::kHostTokenValidationUrlPolicyName, | 140 dict.SetString(PolicyWatcher::kHostTokenValidationUrlPolicyName, |
135 std::string()); | 141 std::string()); |
136 dict.SetString(PolicyWatcher::kHostTokenValidationCertIssuerPolicyName, | 142 dict.SetString(PolicyWatcher::kHostTokenValidationCertIssuerPolicyName, |
137 std::string()); | 143 std::string()); |
138 dict.SetBoolean(PolicyWatcher::kHostAllowClientPairing, true); | 144 dict.SetBoolean(PolicyWatcher::kHostAllowClientPairing, true); |
| 145 dict.SetBoolean(PolicyWatcher::kHostAllowGnubbyAuthPolicyName, true); |
139 #if !defined(NDEBUG) | 146 #if !defined(NDEBUG) |
140 dict.SetString(PolicyWatcher::kHostDebugOverridePoliciesName, ""); | 147 dict.SetString(PolicyWatcher::kHostDebugOverridePoliciesName, ""); |
141 #endif | 148 #endif |
142 } | 149 } |
143 }; | 150 }; |
144 | 151 |
145 const char* PolicyWatcherTest::kHostDomain = "google.com"; | 152 const char* PolicyWatcherTest::kHostDomain = "google.com"; |
146 | 153 |
147 MATCHER_P(IsPolicies, dict, "") { | 154 MATCHER_P(IsPolicies, dict, "") { |
148 return arg->Equals(dict); | 155 return arg->Equals(dict); |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 EXPECT_CALL(mock_policy_callback_, | 332 EXPECT_CALL(mock_policy_callback_, |
326 OnPolicyUpdatePtr(IsPolicies(&pairing_true_))); | 333 OnPolicyUpdatePtr(IsPolicies(&pairing_true_))); |
327 | 334 |
328 StartWatching(); | 335 StartWatching(); |
329 policy_watcher_->SetPolicies(&empty_); | 336 policy_watcher_->SetPolicies(&empty_); |
330 policy_watcher_->SetPolicies(&pairing_false_); | 337 policy_watcher_->SetPolicies(&pairing_false_); |
331 policy_watcher_->SetPolicies(&pairing_true_); | 338 policy_watcher_->SetPolicies(&pairing_true_); |
332 StopWatching(); | 339 StopWatching(); |
333 } | 340 } |
334 | 341 |
| 342 TEST_F(PolicyWatcherTest, GnubbyAuth) { |
| 343 testing::InSequence sequence; |
| 344 EXPECT_CALL(mock_policy_callback_, |
| 345 OnPolicyUpdatePtr(IsPolicies(&nat_true_others_default_))); |
| 346 EXPECT_CALL(mock_policy_callback_, |
| 347 OnPolicyUpdatePtr(IsPolicies(&gnubby_auth_false_))); |
| 348 EXPECT_CALL(mock_policy_callback_, |
| 349 OnPolicyUpdatePtr(IsPolicies(&gnubby_auth_true_))); |
| 350 |
| 351 StartWatching(); |
| 352 policy_watcher_->SetPolicies(&empty_); |
| 353 policy_watcher_->SetPolicies(&gnubby_auth_false_); |
| 354 policy_watcher_->SetPolicies(&gnubby_auth_true_); |
| 355 StopWatching(); |
| 356 } |
| 357 |
335 } // namespace policy_hack | 358 } // namespace policy_hack |
336 } // namespace remoting | 359 } // namespace remoting |
OLD | NEW |