Commit 19742f21 authored by Francis Dupont's avatar Francis Dupont
Browse files

[master] Merged trac4291 (empty option vs csv-format)

parents b2e7801e a288f27e
// Copyright (C) 2012-2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2012-2016 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
......@@ -228,9 +228,12 @@ OptionDefinition::optionFactory(Option::Universe u, uint16_t type,
OptionBuffer buf;
if (!array_type_ && type_ != OPT_RECORD_TYPE) {
if (values.empty()) {
isc_throw(InvalidOptionValue, "no option value specified");
if (type_ != OPT_EMPTY_TYPE) {
isc_throw(InvalidOptionValue, "no option value specified");
}
} else {
writeToBuffer(util::str::trim(values[0]), type_, buf);
}
writeToBuffer(util::str::trim(values[0]), type_, buf);
} else if (array_type_ && type_ != OPT_RECORD_TYPE) {
for (size_t i = 0; i < values.size(); ++i) {
writeToBuffer(util::str::trim(values[i]), type_, buf);
......
// Copyright (C) 2012-2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2012-2016 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
......@@ -932,6 +932,26 @@ TEST_F(ParseConfigTest, emptyOptionData) {
ASSERT_EQ(0, opt->getAddresses().size());
}
// This test verifies an option data without suboptions is supported
TEST_F(ParseConfigTest, optionDataNoSubOpion) {
// Configuration string.
const std::string config =
"{ \"option-data\": [ {"
" \"name\": \"vendor-encapsulated-options\""
" } ]"
"}";
// The default universe is V6. We need to change it to use dhcp4 option
// space.
parser_context_->universe_ = Option::V4;
int rcode = 0;
ASSERT_NO_THROW(rcode = parseConfiguration(config));
EXPECT_EQ(0, rcode);
const OptionPtr opt = getOptionPtr("dhcp4", DHO_VENDOR_ENCAPSULATED_OPTIONS);
ASSERT_TRUE(opt);
ASSERT_EQ(0, opt->getOptions().size());
}
/// The next set of tests check basic operation of the HooksLibrariesParser.
//
// Convenience function to set a configuration of zero or more hooks
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment