|
@@ -139,6 +139,14 @@ class MockCC(MockModuleCCSession):
|
|
|
if identifier == "zones/use_ixfr":
|
|
|
return False
|
|
|
|
|
|
+ def get_remote_config_value(self, module, identifier):
|
|
|
+ if module == 'tsig_keys' and identifier == 'keys':
|
|
|
+ return (['example.com.key.:EvAAsfU2h7uofnmqaTCrhHunGsc=',
|
|
|
+ 'bad.key.:EvAAsfU2h7uofnmqaTCrhHu' ], True)
|
|
|
+ else:
|
|
|
+ raise Exception('MockCC requested for unknown config value ' +
|
|
|
+ + module + "/" + identifier)
|
|
|
+
|
|
|
def remove_remote_config(self, module_name):
|
|
|
pass
|
|
|
|
|
@@ -2427,9 +2435,10 @@ class TestXfrin(unittest.TestCase):
|
|
|
self.assertEqual(str(zone_info.master_addr), zone_config['master_addr'])
|
|
|
self.assertEqual(zone_info.master_port, zone_config['master_port'])
|
|
|
if 'tsig_key' in zone_config:
|
|
|
- self.assertEqual(zone_info.tsig_key.to_text(), TSIGKey(zone_config['tsig_key']).to_text())
|
|
|
+ self.assertEqual(zone_info.tsig_key_name.to_text(),
|
|
|
+ Name(zone_config['tsig_key']).to_text())
|
|
|
else:
|
|
|
- self.assertIsNone(zone_info.tsig_key)
|
|
|
+ self.assertIsNone(zone_info.tsig_key_name)
|
|
|
if 'use_ixfr' in zone_config and\
|
|
|
zone_config.get('use_ixfr'):
|
|
|
self.assertTrue(zone_info.use_ixfr)
|
|
@@ -2562,7 +2571,7 @@ class TestXfrin(unittest.TestCase):
|
|
|
{ 'name': 'test2.example.',
|
|
|
'master_addr': '192.0.2.9',
|
|
|
'master_port': 53,
|
|
|
- 'tsig_key': 'badkey'
|
|
|
+ 'tsig_key': 'badkey..'
|
|
|
}
|
|
|
]}
|
|
|
self.assertEqual(self.xfr.config_handler(zones)['result'][0], 1)
|
|
@@ -2581,13 +2590,14 @@ class TestXfrin(unittest.TestCase):
|
|
|
self.assertEqual(self.xfr.config_handler(config)['result'][0], 0)
|
|
|
self._check_zones_config(config)
|
|
|
|
|
|
- def common_ixfr_setup(self, xfr_mode, use_ixfr):
|
|
|
+ def common_ixfr_setup(self, xfr_mode, use_ixfr, tsig_key_str = None):
|
|
|
# This helper method explicitly sets up a zone configuration with
|
|
|
# use_ixfr, and invokes either retransfer or refresh.
|
|
|
# Shared by some of the following test cases.
|
|
|
config = {'zones': [
|
|
|
{'name': 'example.com.',
|
|
|
'master_addr': '192.0.2.1',
|
|
|
+ 'tsig_key': tsig_key_str,
|
|
|
'use_ixfr': use_ixfr}]}
|
|
|
self.assertEqual(self.xfr.config_handler(config)['result'][0], 0)
|
|
|
self.assertEqual(self.xfr.command_handler(xfr_mode,
|
|
@@ -2603,6 +2613,34 @@ class TestXfrin(unittest.TestCase):
|
|
|
self.common_ixfr_setup('refresh', True)
|
|
|
self.assertEqual(RRType.IXFR(), self.xfr.xfrin_started_request_type)
|
|
|
|
|
|
+ def test_command_handler_retransfer_with_tsig(self):
|
|
|
+ self.common_ixfr_setup('retransfer', False, 'example.com.key')
|
|
|
+ self.assertEqual(RRType.AXFR(), self.xfr.xfrin_started_request_type)
|
|
|
+
|
|
|
+ def test_command_handler_retransfer_with_tsig_bad_key(self):
|
|
|
+ # bad keys should not reach xfrin, but should they somehow,
|
|
|
+ # they are ignored (and result in 'key not found' + error log).
|
|
|
+ self.assertRaises(XfrinZoneInfoException, self.common_ixfr_setup,
|
|
|
+ 'retransfer', False, 'bad.key')
|
|
|
+
|
|
|
+ def test_command_handler_retransfer_with_tsig_unknown_key(self):
|
|
|
+ self.assertRaises(XfrinZoneInfoException, self.common_ixfr_setup,
|
|
|
+ 'retransfer', False, 'no.such.key')
|
|
|
+
|
|
|
+ def test_command_handler_refresh_with_tsig(self):
|
|
|
+ self.common_ixfr_setup('refresh', False, 'example.com.key')
|
|
|
+ self.assertEqual(RRType.AXFR(), self.xfr.xfrin_started_request_type)
|
|
|
+
|
|
|
+ def test_command_handler_refresh_with_tsig_bad_key(self):
|
|
|
+ # bad keys should not reach xfrin, but should they somehow,
|
|
|
+ # they are ignored (and result in 'key not found' + error log).
|
|
|
+ self.assertRaises(XfrinZoneInfoException, self.common_ixfr_setup,
|
|
|
+ 'refresh', False, 'bad.key')
|
|
|
+
|
|
|
+ def test_command_handler_refresh_with_tsig_unknown_key(self):
|
|
|
+ self.assertRaises(XfrinZoneInfoException, self.common_ixfr_setup,
|
|
|
+ 'refresh', False, 'no.such.key')
|
|
|
+
|
|
|
def test_command_handler_retransfer_ixfr_disabled(self):
|
|
|
# Similar to the previous case, but explicitly disabled. AXFR should
|
|
|
# be used.
|