From f45fe7b7e3916d36d017b4ec5b50588fbf517d86 Mon Sep 17 00:00:00 2001 From: Francis Dupont Date: Thu, 3 Jan 2019 19:59:52 +0100 Subject: [PATCH] [381-bad-config-crashes-ca-or-d2-servers-even-with-c] Added a not regression unit test --- src/lib/process/tests/log_parser_unittests.cc | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) 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. -- 2.47.3