]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[381-bad-config-crashes-ca-or-d2-servers-even-with-c] Added a not regression unit... 381-bad-config-crashes-ca-or-d2-servers-even-with-c
authorFrancis Dupont <fdupont@isc.org>
Thu, 3 Jan 2019 18:59:52 +0000 (19:59 +0100)
committerFrancis Dupont <fdupont@isc.org>
Fri, 11 Jan 2019 13:23:43 +0000 (08:23 -0500)
src/lib/process/tests/log_parser_unittests.cc

index b2debe68bbf39ee0590cbdc0e7e9cb947cdfd310..8ee3677de1dec188eccf7fdc88f740a8f32c17d0 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-2019 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -130,6 +130,37 @@ TEST_F(LoggingTest, parsingConsoleOutput) {
     EXPECT_TRUE(storage->getLoggingInfo()[0].destinations_[0].flush_);
 }
 
+// Checks if the LogConfigParser class fails when the configuration
+// lacks a severity entry.
+TEST_F(LoggingTest, parsingNoSeverity) {
+
+    const char* config_txt =
+    "{ \"loggers\": ["
+    "    {"
+    "        \"name\": \"kea\","
+    "        \"output_options\": ["
+    "            {"
+    "                \"output\": \"stdout\","
+    "                \"flush\": true"
+    "            }"
+    "        ],"
+    "        \"debuglevel\": 99"
+    "    }"
+    "]}";
+
+    ConfigPtr storage(new ConfigBase());
+
+    LogConfigParser parser(storage);
+
+    // We need to parse properly formed JSON and then extract
+    // "loggers" element from it. For some reason fromJSON is
+    // throwing at opening square bracket
+    ConstElementPtr config = Element::fromJSON(config_txt);
+    config = config->get("loggers");
+
+    EXPECT_THROW(parser.parseConfiguration(config), BadValue);
+}
+
 // Checks if the LogConfigParser class is able to transform JSON structures
 // into Configuration usable by log4cplus. This test checks for output
 // configured to a file on INFO level.