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

Unified Diff: remoting/host/policy_watcher_unittest.cc

Issue 979823004: Unit tests for misspelled policy names. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/policy_watcher_unittest.cc
diff --git a/remoting/host/policy_watcher_unittest.cc b/remoting/host/policy_watcher_unittest.cc
index 843e4a37af07e6ec9545940415bb67fc45ef153c..98458283f536c83ca829adec985fa76c0f27dc74 100644
--- a/remoting/host/policy_watcher_unittest.cc
+++ b/remoting/host/policy_watcher_unittest.cc
@@ -8,6 +8,7 @@
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/synchronization/waitable_event.h"
+#include "base/test/mock_log.h"
#include "components/policy/core/common/fake_async_policy_loader.h"
#include "policy/policy_constants.h"
#include "remoting/host/dns_blackhole_checker.h"
@@ -439,6 +440,43 @@ TEST_F(PolicyWatcherTest, FilterUnknownPolicies) {
SetPolicies(empty_);
}
+class MisspelledPolicyTest : public PolicyWatcherTest,
+ public ::testing::WithParamInterface<const char*> {
+};
+
+// Verify that a misspelled policy causes a warning written to the log.
+TEST_P(MisspelledPolicyTest, WarningLogged) {
+ const char* misspelled_policy_name = GetParam();
+ base::test::MockLog mock_log;
+
+ ON_CALL(mock_log, Log(testing::_, testing::_, testing::_, testing::_,
+ testing::_)).WillByDefault(testing::Return(true));
+
+ EXPECT_CALL(mock_log,
+ Log(logging::LOG_WARNING, testing::_, testing::_, testing::_,
+ testing::HasSubstr(misspelled_policy_name))).Times(1);
+
+ EXPECT_CALL(mock_policy_callback_,
+ OnPolicyUpdatePtr(IsPolicies(&nat_true_others_default_)));
+
+ base::DictionaryValue misspelled_policies;
+ misspelled_policies.SetString(misspelled_policy_name, "some test value");
+ mock_log.StartCapturingLogs();
+
+ SetPolicies(misspelled_policies);
+ StartWatching();
+
+ mock_log.StopCapturingLogs();
+}
+
+INSTANTIATE_TEST_CASE_P(
+ PolicyWatcherTest,
+ MisspelledPolicyTest,
+ ::testing::Values("RemoteAccessHostDomainX",
+ "XRemoteAccessHostDomain",
+ "RemoteAccessHostdomain",
+ "RemoteAccessHostPolicyForFutureVersion"));
+
TEST_F(PolicyWatcherTest, DebugOverrideNatPolicy) {
#if !defined(NDEBUG)
EXPECT_CALL(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698