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

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

Issue 138753005: Add gnubby authentication to remoting host (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 11 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 (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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
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); 71 pairing_true_.SetBoolean(PolicyWatcher::kHostAllowClientPairing, true);
72 pairing_false_.SetBoolean(PolicyWatcher::kHostAllowClientPairing, false); 72 pairing_false_.SetBoolean(PolicyWatcher::kHostAllowClientPairing, false);
73 gnubby_auth_true_.SetBoolean(PolicyWatcher::kHostAllowGnubbyAuthPolicyName,
74 true);
75 gnubby_auth_false_.SetBoolean(PolicyWatcher::kHostAllowGnubbyAuthPolicyName,
76 false);
73 #if !defined(NDEBUG) 77 #if !defined(NDEBUG)
74 SetDefaults(nat_false_overridden_others_default_); 78 SetDefaults(nat_false_overridden_others_default_);
75 nat_false_overridden_others_default_.SetBoolean( 79 nat_false_overridden_others_default_.SetBoolean(
76 PolicyWatcher::kNatPolicyName, false); 80 PolicyWatcher::kNatPolicyName, false);
77 nat_false_overridden_others_default_.SetString( 81 nat_false_overridden_others_default_.SetString(
78 PolicyWatcher::kHostDebugOverridePoliciesName, 82 PolicyWatcher::kHostDebugOverridePoliciesName,
79 kOverrideNatTraversalToFalse); 83 kOverrideNatTraversalToFalse);
80 #endif 84 #endif
81 } 85 }
82 86
(...skipping 29 matching lines...) Expand all
112 base::DictionaryValue nat_true_domain_empty_; 116 base::DictionaryValue nat_true_domain_empty_;
113 base::DictionaryValue nat_true_domain_full_; 117 base::DictionaryValue nat_true_domain_full_;
114 base::DictionaryValue nat_false_domain_empty_; 118 base::DictionaryValue nat_false_domain_empty_;
115 base::DictionaryValue nat_false_domain_full_; 119 base::DictionaryValue nat_false_domain_full_;
116 base::DictionaryValue nat_true_domain_empty_others_default_; 120 base::DictionaryValue nat_true_domain_empty_others_default_;
117 base::DictionaryValue unknown_policies_; 121 base::DictionaryValue unknown_policies_;
118 base::DictionaryValue nat_true_and_overridden_; 122 base::DictionaryValue nat_true_and_overridden_;
119 base::DictionaryValue nat_false_overridden_others_default_; 123 base::DictionaryValue nat_false_overridden_others_default_;
120 base::DictionaryValue pairing_true_; 124 base::DictionaryValue pairing_true_;
121 base::DictionaryValue pairing_false_; 125 base::DictionaryValue pairing_false_;
126 base::DictionaryValue gnubby_auth_true_;
127 base::DictionaryValue gnubby_auth_false_;
122 128
123 private: 129 private:
124 void SetDefaults(base::DictionaryValue& dict) { 130 void SetDefaults(base::DictionaryValue& dict) {
125 dict.SetBoolean(PolicyWatcher::kNatPolicyName, true); 131 dict.SetBoolean(PolicyWatcher::kNatPolicyName, true);
126 dict.SetBoolean(PolicyWatcher::kHostRequireTwoFactorPolicyName, false); 132 dict.SetBoolean(PolicyWatcher::kHostRequireTwoFactorPolicyName, false);
127 dict.SetString(PolicyWatcher::kHostDomainPolicyName, std::string()); 133 dict.SetString(PolicyWatcher::kHostDomainPolicyName, std::string());
128 dict.SetBoolean(PolicyWatcher::kHostMatchUsernamePolicyName, false); 134 dict.SetBoolean(PolicyWatcher::kHostMatchUsernamePolicyName, false);
129 dict.SetString(PolicyWatcher::kHostTalkGadgetPrefixPolicyName, 135 dict.SetString(PolicyWatcher::kHostTalkGadgetPrefixPolicyName,
130 kDefaultHostTalkGadgetPrefix); 136 kDefaultHostTalkGadgetPrefix);
131 dict.SetBoolean(PolicyWatcher::kHostRequireCurtainPolicyName, false); 137 dict.SetBoolean(PolicyWatcher::kHostRequireCurtainPolicyName, false);
132 dict.SetString(PolicyWatcher::kHostTokenUrlPolicyName, std::string()); 138 dict.SetString(PolicyWatcher::kHostTokenUrlPolicyName, std::string());
133 dict.SetString(PolicyWatcher::kHostTokenValidationUrlPolicyName, 139 dict.SetString(PolicyWatcher::kHostTokenValidationUrlPolicyName,
134 std::string()); 140 std::string());
135 dict.SetBoolean(PolicyWatcher::kHostAllowClientPairing, true); 141 dict.SetBoolean(PolicyWatcher::kHostAllowClientPairing, true);
142 dict.SetBoolean(PolicyWatcher::kHostAllowGnubbyAuthPolicyName, false);
136 #if !defined(NDEBUG) 143 #if !defined(NDEBUG)
137 dict.SetString(PolicyWatcher::kHostDebugOverridePoliciesName, ""); 144 dict.SetString(PolicyWatcher::kHostDebugOverridePoliciesName, "");
138 #endif 145 #endif
139 } 146 }
140 }; 147 };
141 148
142 const char* PolicyWatcherTest::kHostDomain = "google.com"; 149 const char* PolicyWatcherTest::kHostDomain = "google.com";
143 150
144 MATCHER_P(IsPolicies, dict, "") { 151 MATCHER_P(IsPolicies, dict, "") {
145 return arg->Equals(dict); 152 return arg->Equals(dict);
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 EXPECT_CALL(mock_policy_callback_, 329 EXPECT_CALL(mock_policy_callback_,
323 OnPolicyUpdatePtr(IsPolicies(&pairing_true_))); 330 OnPolicyUpdatePtr(IsPolicies(&pairing_true_)));
324 331
325 StartWatching(); 332 StartWatching();
326 policy_watcher_->SetPolicies(&empty_); 333 policy_watcher_->SetPolicies(&empty_);
327 policy_watcher_->SetPolicies(&pairing_false_); 334 policy_watcher_->SetPolicies(&pairing_false_);
328 policy_watcher_->SetPolicies(&pairing_true_); 335 policy_watcher_->SetPolicies(&pairing_true_);
329 StopWatching(); 336 StopWatching();
330 } 337 }
331 338
339 TEST_F(PolicyWatcherTest, GnubbyAuth) {
340 testing::InSequence sequence;
341 EXPECT_CALL(mock_policy_callback_,
342 OnPolicyUpdatePtr(IsPolicies(&nat_true_others_default_)));
343 EXPECT_CALL(mock_policy_callback_,
344 OnPolicyUpdatePtr(IsPolicies(&gnubby_auth_true_)));
345 EXPECT_CALL(mock_policy_callback_,
346 OnPolicyUpdatePtr(IsPolicies(&gnubby_auth_false_)));
347
348 StartWatching();
349 policy_watcher_->SetPolicies(&empty_);
350 policy_watcher_->SetPolicies(&gnubby_auth_true_);
351 policy_watcher_->SetPolicies(&gnubby_auth_false_);
352 StopWatching();
353 }
354
332 } // namespace policy_hack 355 } // namespace policy_hack
333 } // namespace remoting 356 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698