Commit aa753912 authored by Stephen Morris's avatar Stephen Morris
Browse files

[2472] Merge branch 'master' into trac2472

parents 2adb0227 06069bf9
505. [bug] jelte
Fixed a bug in b10-xfrin where a wrong call was made during the
final check of a TSIG-signed transfer, incorrectly rejecting the
transfer.
(Trac #2464, git eac81c0cbebee72f6478bdb5cda915f5470d08e1)
504. [bug]* naokikambe
Fixed an XML format viewed from b10-stats-httpd. Regarding
per-zone counters as zones of Xfrout, a part of the item values wasn't
an exact XML format. A zone name can be specified in URI as
/bind10/statistics/xml/Xfrout/zones/example.org/xfrreqdone. XSD and XSL
formats are also changed to constant ones due to these changes.
(Trac #2298, git 512d2d46f3cb431bcdbf8d90af27bff8874ba075)
503. [func] Stephen
Add initial version of a MySQL backend for the DHCP code. This
implements the basic IPv6 lease access functions - add lease, delete
......
This diff is collapsed.
......@@ -53,6 +53,8 @@ public:
}
~Dhcp6ParserTest() {
// Reset configuration database after each test.
resetConfiguration();
};
/// @brief Create the simple configuration with single option.
......@@ -116,6 +118,51 @@ public:
return (stream.str());
}
/// @brief Reset configuration database.
///
/// This function resets configuration data base by
/// removing all subnets and option-data. Reset must
/// be performed after each test to make sure that
/// contents of the database do not affect result of
/// subsequent tests.
void resetConfiguration() {
ConstElementPtr status;
string config = "{ \"interface\": [ \"all\" ],"
"\"preferred-lifetime\": 3000,"
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
"\"valid-lifetime\": 4000, "
"\"subnet6\": [ ], "
"\"option-data\": [ ] }";
try {
ElementPtr json = Element::fromJSON(config);
status = configureDhcp6Server(srv_, json);
} catch (const std::exception& ex) {
FAIL() << "Fatal error: unable to reset configuration database"
<< " after the test. The following configuration was used"
<< " to reset database: " << std::endl
<< config << std::endl
<< " and the following error message was returned:"
<< ex.what() << std::endl;
}
// returned value should be 0 (configuration success)
if (!status) {
FAIL() << "Fatal error: unable to reset configuration database"
<< " after the test. Configuration function returned"
<< " NULL pointer" << std::endl;
}
comment_ = parseAnswer(rcode_, status);
if (rcode_ != 0) {
FAIL() << "Fatal error: unable to reset configuration database"
<< " after the test. Configuration function returned"
<< " error code " << rcode_ << std::endl;
}
}
/// @brief Test invalid option parameter value.
///
/// This test function constructs the simple configuration
......@@ -691,7 +738,7 @@ TEST_F(Dhcp6ParserTest, stdOptionData) {
// Option code 3 means OPTION_IA_NA.
params["code"] = "3";
params["data"] = "ABCDEF01 02030405 06070809";
std::string config = createConfigWithOption(params);
ElementPtr json = Element::fromJSON(config);
......
<?xml version="1.0" encoding="UTF-8"?>
$xsd_string
<schema targetNamespace="$xsd_namespace"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:bind10="$xsd_namespace">
<annotation>
<documentation>XML schema of statistics data in BIND 10</documentation>
</annotation>
<element name="statistics">
<annotation><documentation>A set of statistics data</documentation></annotation>
<complexType>
<sequence>
<element name="item" maxOccurs="unbounded" minOccurs="1">
<complexType>
<attribute name="identifier" type="string" use="required">
<annotation>
<appinfo>Identifier</appinfo>
<documentation>Identifier of item</documentation>
</annotation>
</attribute>
<attribute name="value" type="string" use="optional">
<annotation>
<appinfo>Value</appinfo>
<documentation>Value of item</documentation>
</annotation>
</attribute>
<attribute name="owner" type="string" use="required">
<annotation>
<appinfo>Owner</appinfo>
<documentation>Owner module name</documentation>
</annotation>
</attribute>
<attribute name="uri" type="anyURI" use="required">
<annotation>
<appinfo>URI</appinfo>
<documentation>URI of item</documentation>
</annotation>
</attribute>
<attribute name="name" type="string" use="required">
<annotation>
<appinfo>Name</appinfo>
<documentation>Name of item</documentation>
</annotation>
</attribute>
<attribute name="type" use="required">
<annotation>
<appinfo>Type</appinfo>
<documentation>Type of item</documentation>
</annotation>
<simpleType>
<restriction base="token">
<enumeration value="boolean"/>
<enumeration value="integer"/>
<enumeration value="real"/>
<enumeration value="string"/>
<enumeration value="map"/>
<enumeration value="list"/>
<enumeration value="named_set"/>
<enumeration value="any"/>
</restriction>
</simpleType>
</attribute>
<attribute name="description" type="string" use="optional">
<annotation>
<appinfo>Description</appinfo>
<documentation>Description of item</documentation>
</annotation>
</attribute>
<attribute name="title" type="string" use="optional">
<annotation>
<appinfo>Title</appinfo>
<documentation>Title of item</documentation>
</annotation>
</attribute>
<attribute name="optional" type="boolean" use="optional">
<annotation>
<appinfo>Optional</appinfo>
<documentation>The item is optional or not</documentation>
</annotation>
</attribute>
<attribute name="default" type="string" use="optional">
<annotation>
<appinfo>Default</appinfo>
<documentation>Default of item</documentation>
</annotation>
</attribute>
<attribute name="format" type="string" use="optional">
<annotation>
<appinfo>Format</appinfo>
<documentation>Format of item value</documentation>
</annotation>
</attribute>
</complexType>
</element>
</sequence>
</complexType>
</element>
</schema>
......@@ -30,5 +30,27 @@ td.title {
</body>
</html>
</xsl:template>
$xsl_string
<xsl:template match="bind10:statistics">
<table>
<tr>
<th>Identifier</th><th>Value</th><th>Description</th>
</tr>
<xsl:for-each select="item">
<tr>
<td>
<xsl:element name="a">
<xsl:attribute name="href"><xsl:value-of select="@uri" /></xsl:attribute>
<xsl:value-of select="@identifier" />
</xsl:element>
</td>
<td>
<xsl:if test="@value"><xsl:value-of select="@value" /></xsl:if>
</td>
<td>
<xsl:if test="@description"><xsl:value-of select="@description" /></xsl:if>
</td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
This diff is collapsed.
This diff is collapsed.
# Copyright (C) 2011-2012 Internet Systems Consortium.
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SYSTEMS CONSORTIUM
# DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
# INTERNET SYSTEMS CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
"""
Utilities and mock modules for unittests of statistics modules
......@@ -16,6 +31,8 @@ import isc.config.cfgmgr
import stats
import stats_httpd
CONST_BASETIME = (2011, 6, 22, 8, 14, 8, 2, 173, 0)
class SignalHandler():
"""A signal handler class for deadlock in unittest"""
def __init__(self, fail_handler, timeout=20):
......@@ -222,7 +239,7 @@ class MockBoss:
}
}
"""
_BASETIME = (2011, 6, 22, 8, 14, 8, 2, 173, 0)
_BASETIME = CONST_BASETIME
def __init__(self):
self._started = threading.Event()
......@@ -457,6 +474,11 @@ class MockAuth:
return isc.config.create_answer(1, "Unknown Command")
class MyStats(stats.Stats):
stats._BASETIME = CONST_BASETIME
stats.get_timestamp = lambda: time.mktime(CONST_BASETIME)
stats.get_datetime = lambda x=None: time.strftime("%Y-%m-%dT%H:%M:%SZ", CONST_BASETIME)
def __init__(self):
self._started = threading.Event()
stats.Stats.__init__(self)
......
......@@ -570,7 +570,7 @@ class TestXfrinIXFRAdd(TestXfrinState):
# difference, starting with removing that SOA.
self.conn._diff.add_data(self.ns_rrset) # put some dummy change
self.conn._tsig_ctx = MockTSIGContext(TSIG_KEY)
self.conn._tsig_ctx.last_has_signature = lambda: False
self.conn._tsig_ctx.last_had_signature = lambda: False
# First, push a starting SOA inside. This should be OK, nothing checked
# yet.
self.state.handle_rr(self.conn, self.begin_soa)
......@@ -821,7 +821,7 @@ class TestAXFR(TestXfrinConnection):
mock_ctx = MockTSIGContext(key)
mock_ctx.error = error
if not has_last_signature:
mock_ctx.last_has_signature = lambda: False
mock_ctx.last_had_signature = lambda: False
return mock_ctx
def __match_exception(self, expected_exception, expected_msg, expression):
......
......@@ -797,7 +797,7 @@ class XfrinConnection(asyncore.dispatcher):
Check there's a signature at the last message.
"""
if self._tsig_ctx is not None:
if not self._tsig_ctx.last_has_signature():
if not self._tsig_ctx.last_had_signature():
raise XfrinProtocolError('TSIG verify fail: no TSIG on last '+
'message')
......
......@@ -69,6 +69,12 @@ public:
/// @param persist if true option is always sent.
OptionDescriptor(OptionPtr& opt, bool persist)
: option(opt), persistent(persist) {};
/// @brief Constructor
///
/// @param persist if true option is always sent.
OptionDescriptor(bool persist)
: option(OptionPtr()), persistent(persist) {};
};
/// @brief Extractor class to extract key with another key.
......
......@@ -92,7 +92,7 @@ RRTTL::RRTTL(const std::string& ttlstr) {
// There's a unit now.
units_mode = true;
// Find the unit and get the size.
uint32_t multiply;
uint32_t multiply = 1; // initialize to silence compiler warnings
bool found = false;
for (size_t i = 0; i < sizeof(units) / sizeof(*units); ++i) {
if (toupper(*unit) == units[i].unit) {
......
......@@ -52,5 +52,5 @@ class MockTSIGContext(TSIGContext):
return self.error(self)
return self.error
def last_has_signature(self):
def last_had_signature(self):
return True
......@@ -61,6 +61,8 @@ copylist = [
"configurations/ddns/noddns.config"],
["configurations/xfrin/retransfer_master.conf.orig",
"configurations/xfrin/retransfer_master.conf"],
["configurations/xfrin/retransfer_slave.conf.orig",
"configurations/xfrin/retransfer_slave.conf"],
["data/inmem-xfrin.sqlite3.orig",
"data/inmem-xfrin.sqlite3"],
["data/xfrin-notify.sqlite3.orig",
......
Feature: Xfrin
Feature: Xfrin
Tests for Xfrin, specific for BIND 10 behaviour.
Scenario: Retransfer command
# Standard check to test (non-)existence of a file.
# This file is actually automatically created.
......@@ -37,3 +37,52 @@ Feature: Xfrin
# We don't have to specify the address/port here; the defaults will work.
When I do an AXFR transfer of example.org
Then transfer result should have 13 rrs
Scenario: Transfer with TSIG
# Similar setup to the test above, but this time, we add TSIG configuration
# In order to check that the tests don't give false positives because config
# happens to be right (like no TSIG on either side), we take an existing
# non-TSIG config, add TSIG on the master side, see it fail, add TSIG
# on the slave side, then check again.
Given I have bind10 running with configuration xfrin/retransfer_master.conf with cmdctl port 47804 as master
And wait for master stderr message AUTH_SERVER_STARTED
And wait for master stderr message XFROUT_STARTED
And I have bind10 running with configuration xfrin/retransfer_slave.conf
And wait for bind10 stderr message CMDCTL_STARTED
And wait for bind10 stderr message XFRIN_STARTED
# Set slave config for 'automatic' xfrin
When I set bind10 configuration Xfrin/zones to [{"master_port": 47806, "name": "example.org", "master_addr": "::1"}]
# Make sure it is fully open
When I send bind10 the command Xfrin retransfer example.org
Then wait for new bind10 stderr message XFRIN_TRANSFER_SUCCESS not XFRIN_XFR_PROCESS_FAILURE
And wait for new bind10 stderr message ZONEMGR_RECEIVE_XFRIN_SUCCESS
# First to master, a transfer should then fail
When I send bind10 the following commands with cmdctl port 47804:
"""
config add tsig_keys/keys "example.key.:c2VjcmV0"
config set Xfrout/zone_config[0]/transfer_acl [{"action": "ACCEPT", "from": "::1", "key": "example.key."}]
config commit
"""
# Transfer should fail
When I send bind10 the command Xfrin retransfer example.org
Then wait for new bind10 stderr message XFRIN_XFR_TRANSFER_PROTOCOL_ERROR not XFRIN_TRANSFER_SUCCESS
# Set client to use TSIG as well
When I send bind10 the following commands:
"""
config add tsig_keys/keys "example.key.:c2VjcmV0"
config set Xfrin/zones[0]/tsig_key "example.key.:c2VjcmV0"
config commit
"""
# Transwer should succeed now
When I send bind10 the command Xfrin retransfer example.org
Then wait for new bind10 stderr message XFRIN_TRANSFER_SUCCESS not XFRIN_XFR_PROCESS_FAILURE
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