Commit 8f359120 authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰
Browse files

[3145] Added negative test case for IAADDR option

parent 302a01c6
......@@ -35,6 +35,9 @@ Option6IAAddr::Option6IAAddr(uint16_t type, const isc::asiolink::IOAddress& addr
uint32_t pref, uint32_t valid)
:Option(V6, type), addr_(addr), preferred_(pref),
valid_(valid) {
if (!addr.isV6()) {
isc_throw(isc::BadValue, addr_.toText() << " is not an IPv6 address");
}
}
Option6IAAddr::Option6IAAddr(uint32_t type, OptionBuffer::const_iterator begin,
......
......@@ -33,7 +33,9 @@ public:
/// length of the fixed part of the IAADDR option
static const size_t OPTION6_IAADDR_LEN = 24;
/// @brief Ctor, used for options constructed (during transmission).
/// @brief Constructor, used for options constructed (during transmission).
///
/// @throw BadValue if specified addr is not IPv6
///
/// @param type option type
/// @param addr reference to an address
......@@ -42,7 +44,9 @@ public:
Option6IAAddr(uint16_t type, const isc::asiolink::IOAddress& addr,
uint32_t preferred, uint32_t valid);
/// @brief ctor, used for received options.
/// @brief Constructor, used for received options.
///
/// @throw OutOfRange if specified option is truncated
///
/// @param type option type
/// @param begin iterator to first byte of option data
......
......@@ -106,4 +106,19 @@ TEST_F(Option6IAAddrTest, basic) {
EXPECT_NO_THROW(opt.reset());
}
/// @todo: Write test for (type, addr, pref, valid) constructor
/// See option6_iaprefix_unittest.cc for similar test
// Tests if broken usage causes exception to be thrown
TEST_F(Option6IAAddrTest, negative) {
// Too short. Minimum length is 24
EXPECT_THROW(Option6IAAddr(D6O_IAADDR, buf_.begin(), buf_.begin() + 23),
OutOfRange);
// This option is for IPv6 addresses only
EXPECT_THROW(Option6IAAddr(D6O_IAADDR, isc::asiolink::IOAddress("192.0.2.1"),
1000, 2000), BadValue);
}
}
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