From: Francis Dupont Date: Thu, 3 Jan 2019 18:59:52 +0000 (+0100) Subject: [381-bad-config-crashes-ca-or-d2-servers-even-with-c] Added a not regression unit... X-Git-Tag: 100-implement-test-config-backend-dhcp6_base~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f45fe7b7e3916d36d017b4ec5b50588fbf517d86;p=thirdparty%2Fkea.git [381-bad-config-crashes-ca-or-d2-servers-even-with-c] Added a not regression unit test --- diff --git a/src/lib/process/tests/log_parser_unittests.cc b/src/lib/process/tests/log_parser_unittests.cc index b2debe68bb..8ee3677de1 100644 --- a/src/lib/process/tests/log_parser_unittests.cc +++ b/src/lib/process/tests/log_parser_unittests.cc @@ -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.