Browse Source

Unit tests for ns1 escape handling and fix

pull/88/head
Ross McFarland 9 years ago
parent
commit
818c1e9cc6
No known key found for this signature in database GPG Key ID: 61C10C4FC8FE4A89
2 changed files with 35 additions and 1 deletions
  1. +1
    -1
      octodns/provider/ns1.py
  2. +34
    -0
      tests/test_octodns_provider_ns1.py

+ 1
- 1
octodns/provider/ns1.py View File

@ -154,7 +154,7 @@ class Ns1Provider(BaseProvider):
# NS1 seems to be the only provider that doesn't want things escaped in
# values so we have to strip them here and add them when going the
# other way
values = [v.replace('\\', '') for v in record.values]
values = [v.replace('\;', ';') for v in record.values]
return {'answers': values, 'ttl': record.ttl}
_params_for_TXT = _params_for_SPF


+ 34
- 0
tests/test_octodns_provider_ns1.py View File

@ -277,3 +277,37 @@ class TestNs1Provider(TestCase):
call.update(answers=[u'1.2.3.4'], ttl=32),
call.delete()
])
def test_escaping(self):
provider = Ns1Provider('test', 'api-key')
record = {
'ttl': 31,
'short_answers': ['foo; bar baz; blip']
}
self.assertEquals(['foo\; bar baz\; blip'],
provider._data_for_SPF('SPF', record)['values'])
record = {
'ttl': 31,
'short_answers': ['no', 'foo; bar baz; blip', 'yes']
}
self.assertEquals(['no', 'foo\; bar baz\; blip', 'yes'],
provider._data_for_TXT('TXT', record)['values'])
zone = Zone('unit.tests.', [])
record = Record.new(zone, 'spf', {
'ttl': 34,
'type': 'SPF',
'value': 'foo\; bar baz\; blip'
})
self.assertEquals(['foo; bar baz; blip'],
provider._params_for_SPF(record)['answers'])
record = Record.new(zone, 'txt', {
'ttl': 35,
'type': 'TXT',
'value': 'foo\; bar baz\; blip'
})
self.assertEquals(['foo; bar baz; blip'],
provider._params_for_TXT(record)['answers'])

Loading…
Cancel
Save