Commit 6ede2d9c authored by Likun Zhang's avatar Likun Zhang

Fix bug, when user doesn't enter the port number for xfrin command, the xfrin shouldn't crash.

git-svn-id: svn://bind10.isc.org/svn/bind10/trunk@1569 e5f2f494-b856-4b98-b285-d166d9295462
parent b0c7deb1
......@@ -31,14 +31,25 @@ class TestXfrin(unittest.TestCase):
args['zone_name'] = 'sd.cn.'
args['port'] = '12345'
args['master'] = '218.241.108.122'
args['db_file'] = '/home/tt'
name, master, port, db_file = xfr._parse_cmd_params(args)
self.assertEqual(port, 12345)
self.assertEqual(name, 'sd.cn.')
self.assertEqual(master, '218.241.108.122')
self.assertEqual(db_file, '/tmp/zone.sqlite3')
self.assertEqual(db_file, '/home/tt')
def test_parse_cmd_params_1(self):
xfr = MyXfrin()
args = {}
args['port'] = '12345'
args['master'] = '218.241.108.122'
args['db_file'] = '/home/tt'
self.assertRaises(XfrinException, xfr._parse_cmd_params, args)
self.assertRaises(XfrinException, xfr._parse_cmd_params, {'zone_name':'ds.cn.', 'master':'3.3.3'})
self.assertRaises(XfrinException, xfr._parse_cmd_params, {'zone_name':'ds.cn.'})
self.assertRaises(XfrinException, xfr._parse_cmd_params, {'master':'ds.cn.'})
if __name__== "__main__":
......
......@@ -372,14 +372,20 @@ class Xfrin():
return answer
def _parse_cmd_params(self, args):
zone_name = args['zone_name']
master = args['master']
zone_name = args.get('zone_name')
if not zone_name:
raise XfrinException('zone name should be provided')
master = args.get('master')
if not master:
raise XfrinException('master address should be provided')
check_addr(master)
port = int(args.get('port'))
if port:
port = 53
port_str = args.get('port')
if port_str:
port = int(port_str)
check_port(port)
else:
port = 53
db_file = args.get('db_file')
if not db_file:
......
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