@@ -369,4 +369,188 @@ TEST_F(TranslatorOptionDataListTestv6, optionsSameCodeAndSpace) {
369369 expectEqWithDiff (options->get (1 ), got->get (3 ));
370370}
371371
372+ // This test verifies that multiple options with empty option data can be
373+ // configured for v4.
374+ TEST_F (TranslatorOptionDataListTestv4, emptyData) {
375+ string const xpath (" /kea-dhcp4-server:config" );
376+
377+ // Set two options with empty data.
378+ ElementPtr const options (Element::fromJSON (R"( [
379+ {
380+ "code": 100,
381+ "space": "dns",
382+ "csv-format": false,
383+ "data": "",
384+ "always-send": false,
385+ "never-send": false
386+ },
387+ {
388+ "code": 101,
389+ "space": "dns",
390+ "csv-format": false,
391+ "data": "",
392+ "always-send": false,
393+ "never-send": false
394+ }
395+ ])" ));
396+ EXPECT_NO_THROW_LOG (translator_->setOptionDataList (xpath, options));
397+
398+ // Get them back.
399+ ConstElementPtr got;
400+ EXPECT_NO_THROW_LOG (got = translator_->getOptionDataListFromAbsoluteXpath (xpath));
401+ ASSERT_TRUE (got);
402+ EXPECT_EQ (2 , got->size ());
403+
404+ // Expect no "data" whatsoever. This is the same as empty "data" to the Kea DHCP server.
405+ ElementPtr const expected (Element::fromJSON (R"( [
406+ {
407+ "code": 100,
408+ "space": "dns",
409+ "csv-format": false,
410+ "always-send": false,
411+ "never-send": false
412+ },
413+ {
414+ "code": 101,
415+ "space": "dns",
416+ "csv-format": false,
417+ "always-send": false,
418+ "never-send": false
419+ }
420+ ])" ));
421+ expectEqWithDiff (expected, got);
422+ }
423+
424+ // This test verifies that multiple options with all keys and empty option data can be
425+ // configured for v4.
426+ TEST_F (TranslatorOptionDataListTestv4, emptyDataKeysOnly) {
427+ string const xpath (" /kea-dhcp4-server:config" );
428+
429+ // Set two options with empty data.
430+ ElementPtr const options (Element::fromJSON (R"( [
431+ {
432+ "code": 100,
433+ "space": "dns",
434+ "data": ""
435+ },
436+ {
437+ "code": 101,
438+ "space": "dns",
439+ "data": ""
440+ }
441+ ])" ));
442+ EXPECT_NO_THROW_LOG (translator_->setOptionDataList (xpath, options));
443+
444+ // Get them back.
445+ ConstElementPtr got;
446+ EXPECT_NO_THROW_LOG (got = translator_->getOptionDataListFromAbsoluteXpath (xpath));
447+ ASSERT_TRUE (got);
448+ EXPECT_EQ (2 , got->size ());
449+
450+ // Expect no "data" whatsoever. This is the same as empty "data" to the Kea DHCP server.
451+ ElementPtr const expected (Element::fromJSON (R"( [
452+ {
453+ "code": 100,
454+ "space": "dns"
455+ },
456+ {
457+ "code": 101,
458+ "space": "dns"
459+ }
460+ ])" ));
461+ expectEqWithDiff (expected, got);
462+ }
463+
464+ // This test verifies that multiple options with empty option data can be
465+ // configured for v6.
466+ TEST_F (TranslatorOptionDataListTestv6, emptyData) {
467+ string const xpath (" /kea-dhcp6-server:config" );
468+
469+ // Set two options with empty data.
470+ ElementPtr const options (Element::fromJSON (R"( [
471+ {
472+ "code": 100,
473+ "space": "dns",
474+ "csv-format": false,
475+ "data": "",
476+ "always-send": false,
477+ "never-send": false
478+ },
479+ {
480+ "code": 101,
481+ "space": "dns",
482+ "csv-format": false,
483+ "data": "",
484+ "always-send": false,
485+ "never-send": false
486+ }
487+ ])" ));
488+ EXPECT_NO_THROW_LOG (translator_->setOptionDataList (xpath, options));
489+
490+ // Get them back.
491+ ConstElementPtr got;
492+ EXPECT_NO_THROW_LOG (got = translator_->getOptionDataListFromAbsoluteXpath (xpath));
493+ ASSERT_TRUE (got);
494+ EXPECT_EQ (2 , got->size ());
495+
496+ // Expect no "data" whatsoever. This is the same as empty "data" to the Kea DHCP server.
497+ ElementPtr const expected (Element::fromJSON (R"( [
498+ {
499+ "code": 100,
500+ "space": "dns",
501+ "csv-format": false,
502+ "always-send": false,
503+ "never-send": false
504+ },
505+ {
506+ "code": 101,
507+ "space": "dns",
508+ "csv-format": false,
509+ "always-send": false,
510+ "never-send": false
511+ }
512+ ])" ));
513+ expectEqWithDiff (expected, got);
514+ }
515+
516+ // This test verifies that multiple options with all keys and empty option data can be
517+ // configured for v6.
518+ TEST_F (TranslatorOptionDataListTestv6, emptyDataKeysOnly) {
519+ string const xpath (" /kea-dhcp6-server:config" );
520+
521+ // Set two options with empty data.
522+ ElementPtr const options (Element::fromJSON (R"( [
523+ {
524+ "code": 100,
525+ "space": "dns",
526+ "data": ""
527+ },
528+ {
529+ "code": 101,
530+ "space": "dns",
531+ "data": ""
532+ }
533+ ])" ));
534+ EXPECT_NO_THROW_LOG (translator_->setOptionDataList (xpath, options));
535+
536+ // Get them back.
537+ ConstElementPtr got;
538+ EXPECT_NO_THROW_LOG (got = translator_->getOptionDataListFromAbsoluteXpath (xpath));
539+ ASSERT_TRUE (got);
540+ EXPECT_EQ (2 , got->size ());
541+
542+ // Expect no "data" whatsoever. This is the same as empty "data" to the Kea DHCP server.
543+ ElementPtr const expected (Element::fromJSON (R"( [
544+ {
545+ "code": 100,
546+ "space": "dns"
547+ },
548+ {
549+ "code": 101,
550+ "space": "dns"
551+ }
552+ ])" ));
553+ expectEqWithDiff (expected, got);
554+ }
555+
372556} // namespace
0 commit comments