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

Unified Diff: remoting/host/policy_hack/policy_watcher_unittest.cc

Issue 209323002: New policies: enable/disable relay; port range (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed android build. Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/host/policy_hack/policy_watcher.cc ('k') | remoting/host/remoting_me2me_host.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/policy_hack/policy_watcher_unittest.cc
diff --git a/remoting/host/policy_hack/policy_watcher_unittest.cc b/remoting/host/policy_hack/policy_watcher_unittest.cc
index 729a7bbad06620a00147a7070a9cf56b0a320c2d..0ed1a55d3cdbe8961e23c52142381cc9ecb514f4 100644
--- a/remoting/host/policy_hack/policy_watcher_unittest.cc
+++ b/remoting/host/policy_hack/policy_watcher_unittest.cc
@@ -75,6 +75,13 @@ class PolicyWatcherTest : public testing::Test {
true);
gnubby_auth_false_.SetBoolean(PolicyWatcher::kHostAllowGnubbyAuthPolicyName,
false);
+ relay_true_.SetBoolean(PolicyWatcher::kRelayPolicyName, true);
+ relay_false_.SetBoolean(PolicyWatcher::kRelayPolicyName, false);
+ port_range_full_.SetString(PolicyWatcher::kUdpPortRangePolicyName,
+ kPortRange);
+ port_range_empty_.SetString(PolicyWatcher::kUdpPortRangePolicyName,
+ std::string());
+
#if !defined(NDEBUG)
SetDefaults(nat_false_overridden_others_default_);
nat_false_overridden_others_default_.SetBoolean(
@@ -99,6 +106,7 @@ class PolicyWatcherTest : public testing::Test {
}
static const char* kHostDomain;
+ static const char* kPortRange;
base::MessageLoop message_loop_;
scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
MockPolicyCallback mock_policy_callback_;
@@ -126,10 +134,16 @@ class PolicyWatcherTest : public testing::Test {
base::DictionaryValue pairing_false_;
base::DictionaryValue gnubby_auth_true_;
base::DictionaryValue gnubby_auth_false_;
+ base::DictionaryValue relay_true_;
+ base::DictionaryValue relay_false_;
+ base::DictionaryValue port_range_full_;
+ base::DictionaryValue port_range_empty_;
private:
void SetDefaults(base::DictionaryValue& dict) {
dict.SetBoolean(PolicyWatcher::kNatPolicyName, true);
+ dict.SetBoolean(PolicyWatcher::kRelayPolicyName, true);
+ dict.SetString(PolicyWatcher::kUdpPortRangePolicyName, "");
dict.SetBoolean(PolicyWatcher::kHostRequireTwoFactorPolicyName, false);
dict.SetString(PolicyWatcher::kHostDomainPolicyName, std::string());
dict.SetBoolean(PolicyWatcher::kHostMatchUsernamePolicyName, false);
@@ -150,6 +164,7 @@ class PolicyWatcherTest : public testing::Test {
};
const char* PolicyWatcherTest::kHostDomain = "google.com";
+const char* PolicyWatcherTest::kPortRange = "12400-12409";
MATCHER_P(IsPolicies, dict, "") {
return arg->Equals(dict);
@@ -355,5 +370,37 @@ TEST_F(PolicyWatcherTest, GnubbyAuth) {
StopWatching();
}
+TEST_F(PolicyWatcherTest, Relay) {
+ testing::InSequence sequence;
+ EXPECT_CALL(mock_policy_callback_,
+ OnPolicyUpdatePtr(IsPolicies(&nat_true_others_default_)));
+ EXPECT_CALL(mock_policy_callback_,
+ OnPolicyUpdatePtr(IsPolicies(&relay_false_)));
+ EXPECT_CALL(mock_policy_callback_,
+ OnPolicyUpdatePtr(IsPolicies(&relay_true_)));
+
+ StartWatching();
+ policy_watcher_->SetPolicies(&empty_);
+ policy_watcher_->SetPolicies(&relay_false_);
+ policy_watcher_->SetPolicies(&relay_true_);
+ StopWatching();
+}
+
+TEST_F(PolicyWatcherTest, UdpPortRange) {
+ testing::InSequence sequence;
+ EXPECT_CALL(mock_policy_callback_,
+ OnPolicyUpdatePtr(IsPolicies(&nat_true_others_default_)));
+ EXPECT_CALL(mock_policy_callback_,
+ OnPolicyUpdatePtr(IsPolicies(&port_range_full_)));
+ EXPECT_CALL(mock_policy_callback_,
+ OnPolicyUpdatePtr(IsPolicies(&port_range_empty_)));
+
+ StartWatching();
+ policy_watcher_->SetPolicies(&empty_);
+ policy_watcher_->SetPolicies(&port_range_full_);
+ policy_watcher_->SetPolicies(&port_range_empty_);
+ StopWatching();
+}
+
} // namespace policy_hack
} // namespace remoting
« no previous file with comments | « remoting/host/policy_hack/policy_watcher.cc ('k') | remoting/host/remoting_me2me_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698