// Valid test message, contents are unimportant.
const char* test_msg =
"{"
- " \"change_type\" : 0 , "
- " \"forward_change\" : true , "
- " \"reverse_change\" : false , "
+ " \"change-type\" : 0 , "
+ " \"forward-change\" : true , "
+ " \"reverse-change\" : false , "
" \"fqdn\" : \"walah.walah.com\" , "
- " \"ip_address\" : \"192.168.2.1\" , "
+ " \"ip-address\" : \"192.168.2.1\" , "
" \"dhcid\" : \"010203040A7F8E3D\" , "
- " \"lease_expires_on\" : \"20130121132405\" , "
- " \"lease_length\" : 1300 "
+ " \"lease-expires-on\" : \"20130121132405\" , "
+ " \"lease-length\" : 1300 "
"}";
// Start queue manager with known good config.
const char* test_msg =
"{"
- " \"change_type\" : 0 , "
- " \"forward_change\" : true , "
- " \"reverse_change\" : false , "
+ " \"change-type\" : 0 , "
+ " \"forward-change\" : true , "
+ " \"reverse-change\" : false , "
" \"fqdn\" : \"fish.tmark.org\" , "
- " \"ip_address\" : \"192.168.2.1\" , "
+ " \"ip-address\" : \"192.168.2.1\" , "
" \"dhcid\" : \"010203040A7F8E3D\" , "
- " \"lease_expires_on\" : \"20130121132405\" , "
- " \"lease_length\" : 1300 "
+ " \"lease-expires-on\" : \"20130121132405\" , "
+ " \"lease-length\" : 1300 "
"}";
// Manually enqueue a request. This lets us test logic with queue
{
// Valid Add.
"{"
- " \"change_type\" : 0 , "
- " \"forward_change\" : true , "
- " \"reverse_change\" : false , "
+ " \"change-type\" : 0 , "
+ " \"forward-change\" : true , "
+ " \"reverse-change\" : false , "
" \"fqdn\" : \"walah.walah.com\" , "
- " \"ip_address\" : \"192.168.2.1\" , "
+ " \"ip-address\" : \"192.168.2.1\" , "
" \"dhcid\" : \"010203040A7F8E3D\" , "
- " \"lease_expires_on\" : \"20130121132405\" , "
- " \"lease_length\" : 1300 "
+ " \"lease-expires-on\" : \"20130121132405\" , "
+ " \"lease-length\" : 1300 "
"}",
// Valid Remove.
"{"
- " \"change_type\" : 1 , "
- " \"forward_change\" : true , "
- " \"reverse_change\" : false , "
+ " \"change-type\" : 1 , "
+ " \"forward-change\" : true , "
+ " \"reverse-change\" : false , "
" \"fqdn\" : \"walah.walah.com\" , "
- " \"ip_address\" : \"192.168.2.1\" , "
+ " \"ip-address\" : \"192.168.2.1\" , "
" \"dhcid\" : \"010203040A7F8E3D\" , "
- " \"lease_expires_on\" : \"20130121132405\" , "
- " \"lease_length\" : 1300 "
+ " \"lease-expires-on\" : \"20130121132405\" , "
+ " \"lease-length\" : 1300 "
"}",
// Valid Add with IPv6 address
"{"
- " \"change_type\" : 0 , "
- " \"forward_change\" : true , "
- " \"reverse_change\" : false , "
+ " \"change-type\" : 0 , "
+ " \"forward-change\" : true , "
+ " \"reverse-change\" : false , "
" \"fqdn\" : \"walah.walah.com\" , "
- " \"ip_address\" : \"fe80::2acf:e9ff:fe12:e56f\" , "
+ " \"ip-address\" : \"fe80::2acf:e9ff:fe12:e56f\" , "
" \"dhcid\" : \"010203040A7F8E3D\" , "
- " \"lease_expires_on\" : \"20130121132405\" , "
- " \"lease_length\" : 1300 "
+ " \"lease-expires-on\" : \"20130121132405\" , "
+ " \"lease-length\" : 1300 "
"}"
};
void makeCannedNcrs() {
const char* msg_str =
"{"
- " \"change_type\" : 0 , "
- " \"forward_change\" : true , "
- " \"reverse_change\" : false , "
+ " \"change-type\" : 0 , "
+ " \"forward-change\" : true , "
+ " \"reverse-change\" : false , "
" \"fqdn\" : \"my.example.com.\" , "
- " \"ip_address\" : \"192.168.1.2\" , "
+ " \"ip-address\" : \"192.168.1.2\" , "
" \"dhcid\" : \"0102030405060708\" , "
- " \"lease_expires_on\" : \"20130121132405\" , "
- " \"lease_length\" : 1300 "
+ " \"lease-expires-on\" : \"20130121132405\" , "
+ " \"lease-length\" : 1300 "
"}";
const char* dhcids[] = { "111111", "222222", "333333", "444444"};
const char* msg_str =
"{"
- " \"change_type\" : 1 , "
- " \"forward_change\" : true , "
- " \"reverse_change\" : true , "
+ " \"change-type\" : 1 , "
+ " \"forward-change\" : true , "
+ " \"reverse-change\" : true , "
" \"fqdn\" : \"example.com.\" , "
- " \"ip_address\" : \"192.168.2.1\" , "
+ " \"ip-address\" : \"192.168.2.1\" , "
" \"dhcid\" : \"0102030405060708\" , "
- " \"lease_expires_on\" : \"20130121132405\" , "
- " \"lease_length\" : 1300 "
+ " \"lease-expires-on\" : \"20130121132405\" , "
+ " \"lease-length\" : 1300 "
"}";
dhcp_ddns::NameChangeRequestPtr ncr;
const char* msg_str =
"{"
- " \"change_type\" : 0 , "
- " \"forward_change\" : true , "
- " \"reverse_change\" : true , "
+ " \"change-type\" : 0 , "
+ " \"forward-change\" : true , "
+ " \"reverse-change\" : true , "
" \"fqdn\" : \"example.com.\" , "
- " \"ip_address\" : \"192.168.2.1\" , "
+ " \"ip-address\" : \"192.168.2.1\" , "
" \"dhcid\" : \"0102030405060708\" , "
- " \"lease_expires_on\" : \"20130121132405\" , "
- " \"lease_length\" : 1300 "
+ " \"lease-expires-on\" : \"20130121132405\" , "
+ " \"lease-length\" : 1300 "
"}";
dhcp_ddns::NameChangeRequestPtr ncr;
const TSIGKeyInfoPtr& tsig_key_info) {
const char* msg_str =
"{"
- " \"change_type\" : 0 , "
- " \"forward_change\" : true , "
- " \"reverse_change\" : true , "
+ " \"change-type\" : 0 , "
+ " \"forward-change\" : true , "
+ " \"reverse-change\" : true , "
" \"fqdn\" : \"my.forward.example.com.\" , "
- " \"ip_address\" : \"192.168.2.1\" , "
+ " \"ip-address\" : \"192.168.2.1\" , "
" \"dhcid\" : \"0102030405060708\" , "
- " \"lease_expires_on\" : \"20130121132405\" , "
- " \"lease_length\" : 1300 "
+ " \"lease-expires-on\" : \"20130121132405\" , "
+ " \"lease-length\" : 1300 "
"}";
// Create NameChangeRequest from JSON string.
const TSIGKeyInfoPtr& tsig_key_info) {
const char* msg_str =
"{"
- " \"change_type\" : 0 , "
- " \"forward_change\" : true , "
- " \"reverse_change\" : true , "
+ " \"change-type\" : 0 , "
+ " \"forward-change\" : true , "
+ " \"reverse-change\" : true , "
" \"fqdn\" : \"my6.forward.example.com.\" , "
- " \"ip_address\" : \"2001:1::100\" , "
+ " \"ip-address\" : \"2001:1::100\" , "
" \"dhcid\" : \"0102030405060708\" , "
- " \"lease_expires_on\" : \"20130121132405\" , "
- " \"lease_length\" : 1300 "
+ " \"lease-expires-on\" : \"20130121132405\" , "
+ " \"lease-length\" : 1300 "
"}";
// Create NameChangeRequest from JSON string.
const char* msg_str =
"{"
- " \"change_type\" : 0 , "
- " \"forward_change\" : true , "
- " \"reverse_change\" : true , "
+ " \"change-type\" : 0 , "
+ " \"forward-change\" : true , "
+ " \"reverse-change\" : true , "
" \"fqdn\" : \"example.com.\" , "
- " \"ip_address\" : \"192.168.2.1\" , "
+ " \"ip-address\" : \"192.168.2.1\" , "
" \"dhcid\" : \"0102030405060708\" , "
- " \"lease_expires_on\" : \"20130121132405\" , "
- " \"lease_length\" : 1300 "
+ " \"lease-expires-on\" : \"20130121132405\" , "
+ " \"lease-length\" : 1300 "
"}";
dhcp_ddns::NameChangeRequestPtr ncr;
stream <<
"{"
- " \"change_type\" : 0 , "
- " \"forward_change\" : true , "
- " \"reverse_change\" : false , "
+ " \"change-type\" : 0 , "
+ " \"forward-change\" : true , "
+ " \"reverse-change\" : false , "
" \"fqdn\" : \"myhost.example.com.\" , "
- " \"ip_address\" : \"192.168.2.1\" , "
+ " \"ip-address\" : \"192.168.2.1\" , "
" \"dhcid\" : \""
<< std::hex << std::setfill('0') << std::setw(16)
<< dhcid_id_num << "\" , "
- " \"lease_expires_on\" : \"20140121132405\" , "
- " \"lease_length\" : 1300 "
+ " \"lease-expires-on\" : \"20140121132405\" , "
+ " \"lease-length\" : 1300 "
"}";
return (dhcp_ddns::NameChangeRequest::fromJSON(stream.str()));
stream <<
"{"
- " \"change_type\" : 0 , "
- " \"forward_change\" : true , "
- " \"reverse_change\" : false , "
+ " \"change-type\" : 0 , "
+ " \"forward-change\" : true , "
+ " \"reverse-change\" : false , "
" \"fqdn\" : \"myhost.example.com.\" , "
- " \"ip_address\" : \"192.168.2.1\" , "
+ " \"ip-address\" : \"192.168.2.1\" , "
" \"dhcid\" : \""
<< std::hex << std::setfill('0') << std::setw(16)
<< dhcid_id_num << "\" , "
- " \"lease_expires_on\" : \"20140121132405\" , "
- " \"lease_length\" : 1300 "
+ " \"lease-expires-on\" : \"20140121132405\" , "
+ " \"lease-length\" : 1300 "
"}";
return (dhcp_ddns::NameChangeRequest::fromJSON(stream.str()));
and receiving requests used by ISC's DHCP-DDNS (aka D2) service to carry
out DHCP-driven DNS updates. Each request contains the following information:
- - change_type - indicates if this is a request to add or remove DNS entries
- - forward_change - indicates if the forward DNS zone (the one that
+ - change-type - indicates if this is a request to add or remove DNS entries
+ - forward-change - indicates if the forward DNS zone (the one that
contains name to address mappings) should be updated
- - reverse_change - indicates if reverse DNS zone (which contains the
+ - reverse-change - indicates if reverse DNS zone (which contains the
address to name mappings) should be updated
- fqdn - the fully qualified domain name whose DNS entries should be updated
- - ip_address - IP address (v4 or v6) leased to the client with the
+ - ip-address - IP address (v4 or v6) leased to the client with the
given FQDN
- dhcid - DHCID (a form of identification) of the client to whom the IP
address is leased
- - lease_expires_on - timestamp containing the date/time the lease expires
- - lease_length - duration in seconds for which the lease is valid.
+ - lease-expires-on - timestamp containing the date/time the lease expires
+ - lease-length - duration in seconds for which the lease is valid.
These requests are implemented in this library by the class,
isc::dhcp_ddns::NameChangeRequest. This class provides services for
// content is lexically invalid. If the element is NOT found in the
// map, getElement will throw NcrMessageError indicating the missing
// member. Currently there are no optional values.
- element = ncr->getElement("change_type", element_map);
+ element = ncr->getElement("change-type", element_map);
ncr->setChangeType(element);
- element = ncr->getElement("forward_change", element_map);
+ element = ncr->getElement("forward-change", element_map);
ncr->setForwardChange(element);
- element = ncr->getElement("reverse_change", element_map);
+ element = ncr->getElement("reverse-change", element_map);
ncr->setReverseChange(element);
element = ncr->getElement("fqdn", element_map);
ncr->setFqdn(element);
- element = ncr->getElement("ip_address", element_map);
+ element = ncr->getElement("ip-address", element_map);
ncr->setIpAddress(element);
element = ncr->getElement("dhcid", element_map);
ncr->setDhcid(element);
- element = ncr->getElement("lease_expires_on", element_map);
+ element = ncr->getElement("lease-expires-on", element_map);
ncr->setLeaseExpiresOn(element);
- element = ncr->getElement("lease_length", element_map);
+ element = ncr->getElement("lease-length", element_map);
ncr->setLeaseLength(element);
// All members were in the Element set and were correct lexically. Now
// forward.
std::ostringstream stream;
- stream << "{\"change_type\":" << getChangeType() << ","
- << "\"forward_change\":"
+ stream << "{\"change-type\":" << getChangeType() << ","
+ << "\"forward-change\":"
<< (isForwardChange() ? "true" : "false") << ","
- << "\"reverse_change\":"
+ << "\"reverse-change\":"
<< (isReverseChange() ? "true" : "false") << ","
<< "\"fqdn\":\"" << getFqdn() << "\","
- << "\"ip_address\":\"" << getIpAddress() << "\","
+ << "\"ip-address\":\"" << getIpAddress() << "\","
<< "\"dhcid\":\"" << getDhcid().toStr() << "\","
- << "\"lease_expires_on\":\"" << getLeaseExpiresOnStr() << "\","
- << "\"lease_length\":" << getLeaseLength() << "}";
+ << "\"lease-expires-on\":\"" << getLeaseExpiresOnStr() << "\","
+ << "\"lease-length\":" << getLeaseLength() << "}";
return (stream.str());
}
} catch (isc::data::TypeError& ex) {
// We expect a boolean Element type, don't have one.
isc_throw(NcrMessageError,
- "Wrong data type for forward_change: " << ex.what());
+ "Wrong data type for forward-change: " << ex.what());
}
// Good to go, make the assignment.
{
// Valid Add.
"{"
- " \"change_type\" : 0 , "
- " \"forward_change\" : true , "
- " \"reverse_change\" : false , "
+ " \"change-type\" : 0 , "
+ " \"forward-change\" : true , "
+ " \"reverse-change\" : false , "
" \"fqdn\" : \"walah.walah.com\" , "
- " \"ip_address\" : \"192.168.2.1\" , "
+ " \"ip-address\" : \"192.168.2.1\" , "
" \"dhcid\" : \"010203040A7F8E3D\" , "
- " \"lease_expires_on\" : \"20130121132405\" , "
- " \"lease_length\" : 1300 "
+ " \"lease-expires-on\" : \"20130121132405\" , "
+ " \"lease-length\" : 1300 "
"}",
// Valid Remove.
"{"
- " \"change_type\" : 1 , "
- " \"forward_change\" : true , "
- " \"reverse_change\" : false , "
+ " \"change-type\" : 1 , "
+ " \"forward-change\" : true , "
+ " \"reverse-change\" : false , "
" \"fqdn\" : \"walah.walah.com\" , "
- " \"ip_address\" : \"192.168.2.1\" , "
+ " \"ip-address\" : \"192.168.2.1\" , "
" \"dhcid\" : \"010203040A7F8E3D\" , "
- " \"lease_expires_on\" : \"20130121132405\" , "
- " \"lease_length\" : 1300 "
+ " \"lease-expires-on\" : \"20130121132405\" , "
+ " \"lease-length\" : 1300 "
"}",
// Valid Add with IPv6 address
"{"
- " \"change_type\" : 0 , "
- " \"forward_change\" : true , "
- " \"reverse_change\" : false , "
+ " \"change-type\" : 0 , "
+ " \"forward-change\" : true , "
+ " \"reverse-change\" : false , "
" \"fqdn\" : \"walah.walah.com\" , "
- " \"ip_address\" : \"fe80::2acf:e9ff:fe12:e56f\" , "
+ " \"ip-address\" : \"fe80::2acf:e9ff:fe12:e56f\" , "
" \"dhcid\" : \"010203040A7F8E3D\" , "
- " \"lease_expires_on\" : \"20130121132405\" , "
- " \"lease_length\" : 1300 "
+ " \"lease-expires-on\" : \"20130121132405\" , "
+ " \"lease-length\" : 1300 "
"}"
};
{
// Valid Add.
"{"
- " \"change_type\" : 0 , "
- " \"forward_change\" : true , "
- " \"reverse_change\" : false , "
+ " \"change-type\" : 0 , "
+ " \"forward-change\" : true , "
+ " \"reverse-change\" : false , "
" \"fqdn\" : \"walah.walah.com\" , "
- " \"ip_address\" : \"192.168.2.1\" , "
+ " \"ip-address\" : \"192.168.2.1\" , "
" \"dhcid\" : \"010203040A7F8E3D\" , "
- " \"lease_expires_on\" : \"20130121132405\" , "
- " \"lease_length\" : 1300 "
+ " \"lease-expires-on\" : \"20130121132405\" , "
+ " \"lease-length\" : 1300 "
"}",
// Valid Remove.
"{"
- " \"change_type\" : 1 , "
- " \"forward_change\" : true , "
- " \"reverse_change\" : false , "
+ " \"change-type\" : 1 , "
+ " \"forward-change\" : true , "
+ " \"reverse-change\" : false , "
" \"fqdn\" : \"walah.walah.com\" , "
- " \"ip_address\" : \"192.168.2.1\" , "
+ " \"ip-address\" : \"192.168.2.1\" , "
" \"dhcid\" : \"010203040A7F8E3D\" , "
- " \"lease_expires_on\" : \"20130121132405\" , "
- " \"lease_length\" : 1300 "
+ " \"lease-expires-on\" : \"20130121132405\" , "
+ " \"lease-length\" : 1300 "
"}",
// Valid Add with IPv6 address
"{"
- " \"change_type\" : 0 , "
- " \"forward_change\" : true , "
- " \"reverse_change\" : false , "
+ " \"change-type\" : 0 , "
+ " \"forward-change\" : true , "
+ " \"reverse-change\" : false , "
" \"fqdn\" : \"walah.walah.com\" , "
- " \"ip_address\" : \"fe80::2acf:e9ff:fe12:e56f\" , "
+ " \"ip-address\" : \"fe80::2acf:e9ff:fe12:e56f\" , "
" \"dhcid\" : \"010203040A7F8E3D\" , "
- " \"lease_expires_on\" : \"20130121132405\" , "
- " \"lease_length\" : 1300 "
+ " \"lease-expires-on\" : \"20130121132405\" , "
+ " \"lease-length\" : 1300 "
"}"
};
{
// Invalid change type.
"{"
- " \"change_type\" : 7 , "
- " \"forward_change\" : true , "
- " \"reverse_change\" : false , "
+ " \"change-type\" : 7 , "
+ " \"forward-change\" : true , "
+ " \"reverse-change\" : false , "
" \"fqdn\" : \"walah.walah.com\" , "
- " \"ip_address\" : \"192.168.2.1\" , "
+ " \"ip-address\" : \"192.168.2.1\" , "
" \"dhcid\" : \"010203040A7F8E3D\" , "
- " \"lease_expires_on\" : \"20130121132405\" , "
- " \"lease_length\" : 1300 "
+ " \"lease-expires-on\" : \"20130121132405\" , "
+ " \"lease-length\" : 1300 "
"}",
// Invalid forward change.
"{"
- " \"change_type\" : 0 , "
- " \"forward_change\" : \"bogus\" , "
- " \"reverse_change\" : false , "
+ " \"change-type\" : 0 , "
+ " \"forward-change\" : \"bogus\" , "
+ " \"reverse-change\" : false , "
" \"fqdn\" : \"walah.walah.com\" , "
- " \"ip_address\" : \"192.168.2.1\" , "
+ " \"ip-address\" : \"192.168.2.1\" , "
" \"dhcid\" : \"010203040A7F8E3D\" , "
- " \"lease_expires_on\" : \"20130121132405\" , "
- " \"lease_length\" : 1300 "
+ " \"lease-expires-on\" : \"20130121132405\" , "
+ " \"lease-length\" : 1300 "
"}",
// Invalid reverse change.
"{"
- " \"change_type\" : 0 , "
- " \"forward_change\" : true , "
- " \"reverse_change\" : 500 , "
+ " \"change-type\" : 0 , "
+ " \"forward-change\" : true , "
+ " \"reverse-change\" : 500 , "
" \"fqdn\" : \"walah.walah.com\" , "
- " \"ip_address\" : \"192.168.2.1\" , "
+ " \"ip-address\" : \"192.168.2.1\" , "
" \"dhcid\" : \"010203040A7F8E3D\" , "
- " \"lease_expires_on\" : \"20130121132405\" , "
- " \"lease_length\" : 1300 "
+ " \"lease-expires-on\" : \"20130121132405\" , "
+ " \"lease-length\" : 1300 "
"}",
// Forward and reverse change both false.
"{"
- " \"change_type\" : 0 , "
- " \"forward_change\" : false , "
- " \"reverse_change\" : false , "
+ " \"change-type\" : 0 , "
+ " \"forward-change\" : false , "
+ " \"reverse-change\" : false , "
" \"fqdn\" : \"walah.walah.com\" , "
- " \"ip_address\" : \"192.168.2.1\" , "
+ " \"ip-address\" : \"192.168.2.1\" , "
" \"dhcid\" : \"010203040A7F8E3D\" , "
- " \"lease_expires_on\" : \"20130121132405\" , "
- " \"lease_length\" : 1300 "
+ " \"lease-expires-on\" : \"20130121132405\" , "
+ " \"lease-length\" : 1300 "
"}",
// Blank FQDN
"{"
- " \"change_type\" : 0 , "
- " \"forward_change\" : true , "
- " \"reverse_change\" : false , "
+ " \"change-type\" : 0 , "
+ " \"forward-change\" : true , "
+ " \"reverse-change\" : false , "
" \"fqdn\" : \"\" , "
- " \"ip_address\" : \"192.168.2.1\" , "
+ " \"ip-address\" : \"192.168.2.1\" , "
" \"dhcid\" : \"010203040A7F8E3D\" , "
- " \"lease_expires_on\" : \"20130121132405\" , "
- " \"lease_length\" : 1300 "
+ " \"lease-expires-on\" : \"20130121132405\" , "
+ " \"lease-length\" : 1300 "
"}",
// Malformed FQDN
"{"
- " \"change_type\" : 0 , "
- " \"forward_change\" : true , "
- " \"reverse_change\" : false , "
+ " \"change-type\" : 0 , "
+ " \"forward-change\" : true , "
+ " \"reverse-change\" : false , "
" \"fqdn\" : \".bad_name\" , "
- " \"ip_address\" : \"192.168.2.1\" , "
+ " \"ip-address\" : \"192.168.2.1\" , "
" \"dhcid\" : \"010203040A7F8E3D\" , "
- " \"lease_expires_on\" : \"20130121132405\" , "
- " \"lease_length\" : 1300 "
+ " \"lease-expires-on\" : \"20130121132405\" , "
+ " \"lease-length\" : 1300 "
"}",
// Bad IP address
"{"
- " \"change_type\" : 0 , "
- " \"forward_change\" : true , "
- " \"reverse_change\" : false , "
+ " \"change-type\" : 0 , "
+ " \"forward-change\" : true , "
+ " \"reverse-change\" : false , "
" \"fqdn\" : \"walah.walah.com\" , "
- " \"ip_address\" : \"xxxxxx\" , "
+ " \"ip-address\" : \"xxxxxx\" , "
" \"dhcid\" : \"010203040A7F8E3D\" , "
- " \"lease_expires_on\" : \"20130121132405\" , "
- " \"lease_length\" : 1300 "
+ " \"lease-expires-on\" : \"20130121132405\" , "
+ " \"lease-length\" : 1300 "
"}",
// Blank DHCID
"{"
- " \"change_type\" : 0 , "
- " \"forward_change\" : true , "
- " \"reverse_change\" : false , "
+ " \"change-type\" : 0 , "
+ " \"forward-change\" : true , "
+ " \"reverse-change\" : false , "
" \"fqdn\" : \"walah.walah.com\" , "
- " \"ip_address\" : \"192.168.2.1\" , "
+ " \"ip-address\" : \"192.168.2.1\" , "
" \"dhcid\" : \"\" , "
- " \"lease_expires_on\" : \"20130121132405\" , "
- " \"lease_length\" : 1300 "
+ " \"lease-expires-on\" : \"20130121132405\" , "
+ " \"lease-length\" : 1300 "
"}",
// Odd number of digits in DHCID
"{"
- " \"change_type\" : 0 , "
- " \"forward_change\" : true , "
- " \"reverse_change\" : false , "
+ " \"change-type\" : 0 , "
+ " \"forward-change\" : true , "
+ " \"reverse-change\" : false , "
" \"fqdn\" : \"walah.walah.com\" , "
- " \"ip_address\" : \"192.168.2.1\" , "
+ " \"ip-address\" : \"192.168.2.1\" , "
" \"dhcid\" : \"010203040A7F8E3\" , "
- " \"lease_expires_on\" : \"20130121132405\" , "
- " \"lease_length\" : 1300 "
+ " \"lease-expires-on\" : \"20130121132405\" , "
+ " \"lease-length\" : 1300 "
"}",
// Text in DHCID
"{"
- " \"change_type\" : 0 , "
- " \"forward_change\" : true , "
- " \"reverse_change\" : false , "
+ " \"change-type\" : 0 , "
+ " \"forward-change\" : true , "
+ " \"reverse-change\" : false , "
" \"fqdn\" : \"walah.walah.com\" , "
- " \"ip_address\" : \"192.168.2.1\" , "
+ " \"ip-address\" : \"192.168.2.1\" , "
" \"dhcid\" : \"THIS IS BOGUS!!!\" , "
- " \"lease_expires_on\" : \"20130121132405\" , "
- " \"lease_length\" : 1300 "
+ " \"lease-expires-on\" : \"20130121132405\" , "
+ " \"lease-length\" : 1300 "
"}",
// Invalid lease expiration string
"{"
- " \"change_type\" : 0 , "
- " \"forward_change\" : true , "
- " \"reverse_change\" : false , "
+ " \"change-type\" : 0 , "
+ " \"forward-change\" : true , "
+ " \"reverse-change\" : false , "
" \"fqdn\" : \"walah.walah.com\" , "
- " \"ip_address\" : \"192.168.2.1\" , "
+ " \"ip-address\" : \"192.168.2.1\" , "
" \"dhcid\" : \"010203040A7F8E3D\" , "
- " \"lease_expires_on\" : \"Wed Jun 26 13:46:46 EDT 2013\" , "
- " \"lease_length\" : 1300 "
+ " \"lease-expires-on\" : \"Wed Jun 26 13:46:46 EDT 2013\" , "
+ " \"lease-length\" : 1300 "
"}",
// Non-integer for lease length.
"{"
- " \"change_type\" : 0 , "
- " \"forward_change\" : true , "
- " \"reverse_change\" : false , "
+ " \"change-type\" : 0 , "
+ " \"forward-change\" : true , "
+ " \"reverse-change\" : false , "
" \"fqdn\" : \"walah.walah.com\" , "
- " \"ip_address\" : \"192.168.2.1\" , "
+ " \"ip-address\" : \"192.168.2.1\" , "
" \"dhcid\" : \"010203040A7F8E3D\" , "
- " \"lease_expires_on\" : \"20130121132405\" , "
- " \"lease_length\" : \"BOGUS\" "
+ " \"lease-expires-on\" : \"20130121132405\" , "
+ " \"lease-length\" : \"BOGUS\" "
"}"
};
TEST(NameChangeRequestTest, basicJsonTest) {
// Define valid JSON rendition of a request.
std::string msg_str = "{"
- "\"change_type\":1,"
- "\"forward_change\":true,"
- "\"reverse_change\":false,"
+ "\"change-type\":1,"
+ "\"forward-change\":true,"
+ "\"reverse-change\":false,"
"\"fqdn\":\"walah.walah.com.\","
- "\"ip_address\":\"192.168.2.1\","
+ "\"ip-address\":\"192.168.2.1\","
"\"dhcid\":\"010203040A7F8E3D\","
- "\"lease_expires_on\":\"20130121132405\","
- "\"lease_length\":1300"
+ "\"lease-expires-on\":\"20130121132405\","
+ "\"lease-length\":1300"
"}";
// Verify that a NameChangeRequests can be instantiated from the
TEST(NameChangeRequestTest, toFromBufferTest) {
// Define a string containing a valid JSON NameChangeRequest rendition.
std::string msg_str = "{"
- "\"change_type\":1,"
- "\"forward_change\":true,"
- "\"reverse_change\":false,"
+ "\"change-type\":1,"
+ "\"forward-change\":true,"
+ "\"reverse-change\":false,"
"\"fqdn\":\"walah.walah.com.\","
- "\"ip_address\":\"192.168.2.1\","
+ "\"ip-address\":\"192.168.2.1\","
"\"dhcid\":\"010203040A7F8E3D\","
- "\"lease_expires_on\":\"20130121132405\","
- "\"lease_length\":1300"
+ "\"lease-expires-on\":\"20130121132405\","
+ "\"lease-length\":1300"
"}";
// Create a request from JSON directly.
// Build an NCR from json string.
const char* ncr_str =
"{"
- " \"change_type\" : 0 , "
- " \"forward_change\" : true , "
- " \"reverse_change\" : false , "
+ " \"change-type\" : 0 , "
+ " \"forward-change\" : true , "
+ " \"reverse-change\" : false , "
" \"fqdn\" : \"myhost.example.com.\" , "
- " \"ip_address\" : \"192.168.2.1\" , "
+ " \"ip-address\" : \"192.168.2.1\" , "
" \"dhcid\" : \"010203040A7F8E3D\" , "
- " \"lease_expires_on\" : \"20140121132405\" , "
- " \"lease_length\" : 1300 "
+ " \"lease-expires-on\" : \"20140121132405\" , "
+ " \"lease-length\" : 1300 "
"}";
return (dhcp_ddns::NameChangeRequest::fromJSON(ncr_str));