Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Handle / in zone names for arpa domains. fixes #61.

  • Loading branch information...
commit 02b1da1509e42aa3188b0fd52f84cfc924c47e2b 1 parent e048bfa
Barnaby Gray authored
View
3  scripts/cli53
@@ -425,6 +425,7 @@ class R53ToBindFormatter(object):
def convert(self, info, rrsets, z=None):
if not z:
origin = info.HostedZone.Name
+ origin = origin.replace('\\057', '/')
z = dns.zone.Zone(dns.name.from_text(origin))
for rrset in rrsets:
@@ -432,6 +433,7 @@ class R53ToBindFormatter(object):
if '\\052' in name:
# * char seems to confuse Amazon and is returned as \\052
name = name.replace('\\052', '*')
+ name = name.replace('\\057', '/')
rtype = rrset.type
ttl = int(rrset.ttl)
values = rrset.resource_records
@@ -603,6 +605,7 @@ def Zone(zone):
return zone
ret = r53.get_all_hosted_zones()
+ zone = zone.replace('/', '\\057')
hzs = [ hz.Id.replace('/hostedzone/', '') for hz in ret.ListHostedZonesResponse.HostedZones if hz.Name == zone or hz.Name == zone+'.' ]
if len(hzs) == 1:
return hzs[0]
View
30 tests/test_bind.py
@@ -20,8 +20,6 @@ def __eq__(self, x):
class BindTest(unittest.TestCase):
def setUp(self):
- # re-use if already created
- self.zone = '%d.example.com' % random.randint(0, sys.maxint)
self._cmd('create', self.zone)
def tearDown(self):
@@ -38,6 +36,9 @@ def _cmd(self, cmd, *args):
raise NonZeroExit
return p.stdout.read()
+class ZoneTest(BindTest):
+ zone = '%d.example.com' % random.randint(0, sys.maxint)
+
def _zonefile(self, fname):
with file('temp.txt', 'w') as fout:
print >>fout, "$ORIGIN %s." % self.zone
@@ -102,7 +103,7 @@ def test_import2(self):
],
output
)
-
+
def test_aws_extensions(self):
fname = self._zonefile('zoneaws.txt')
self._cmd('import', '--file', fname, self.zone)
@@ -133,3 +134,26 @@ def test_invalid1(self):
fname = self._zonefile('invalid1.txt')
self.assertRaises(NonZeroExit,
self._cmd, 'import', '--file', fname, self.zone)
+
+class ArpaTest(BindTest):
+ zone = '0/25.0.1.10.in-addr.arpa'
+
+ def test_import_arpa(self):
+ self._cmd('import', '--file', _f('zone3.txt'), self.zone)
+
+ output = self._cmd('export', self.zone)
+ output = [ x for x in output.split('\n') if x ]
+ output.sort()
+
+ self.assertEqual(
+ [
+ "$ORIGIN %s." % self.zone,
+ "98 0 IN PTR blah.foo.com.",
+ RegexEqual('^@ 172800 IN NS'),
+ RegexEqual('^@ 172800 IN NS'),
+ RegexEqual('^@ 172800 IN NS'),
+ RegexEqual('^@ 172800 IN NS'),
+ RegexEqual('^@ 900 IN SOA'),
+ ],
+ output
+ )
View
10 tests/test_commands.py
@@ -38,13 +38,13 @@ def test_rrcreate(self):
self._cmd('rrcreate', self.zone, '', 'A', '10.0.0.1')
self._cmd('rrcreate', self.zone, 'www', 'CNAME', self.zone+'.', '-x 3600')
self._cmd('rrcreate', self.zone, 'info', 'TXT', 'this is a "test"')
- self._cmd('rrcreate', self.zone, 'weighttest1', 'CNAME', self.zone+'.', '-x 60', '-w 0', '-i awsweightzero')
- self._cmd('rrcreate', self.zone, 'weighttest2', 'CNAME', self.zone+'.', '-x 60', '-w 1', '-i awsweightone')
- self._cmd('rrcreate', self.zone, 'weighttest3', 'CNAME', self.zone+'.', '-x 60', '-w 50', '-i awsweightfifty')
+ self._cmd('rrcreate', self.zone, 'weighttest1', 'CNAME', self.zone+'.', '-x 60', '-w 0', '-i awsweightzero')
+ self._cmd('rrcreate', self.zone, 'weighttest2', 'CNAME', self.zone+'.', '-x 60', '-w 1', '-i awsweightone')
+ self._cmd('rrcreate', self.zone, 'weighttest3', 'CNAME', self.zone+'.', '-x 60', '-w 50', '-i awsweightfifty')
output = self._cmd('export', self.zone)
output = [ x for x in output.split('\n') if '10.0.0.1' in x or 'CNAME' in x or 'TXT' in x ]
-
+
self.assertEqual(
[
"@ 86400 IN A 10.0.0.1",
@@ -56,7 +56,7 @@ def test_rrcreate(self):
],
output
)
-
+
def test_rrdelete(self):
self._cmd('rrcreate', self.zone, '', 'A', '10.0.0.1')
self._cmd('rrdelete', self.zone, '', 'A')
View
2  tests/zone3.txt
@@ -0,0 +1,2 @@
+$ORIGIN 0/25.0.1.10.in-addr.arpa.
+98 PTR blah.foo.com.
Please sign in to comment.
Something went wrong with that request. Please try again.