Skip to content

Commit

Permalink
auroradns: Properly parse TTL as extra data
Browse files Browse the repository at this point in the history
Small typo in the list caused this not to be parsed properly
  • Loading branch information
wido committed Jan 8, 2016
1 parent a2a36f0 commit 9a747d3
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 1 deletion.
2 changes: 1 addition & 1 deletion libcloud/dns/drivers/auroradns.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
DEFAULT_ZONE_TTL = 3600
DEFAULT_ZONE_TYPE = 'master'

VALID_RECORD_PARAMS_EXTRA = ['ttl' 'prio', 'health_check_id', 'disabled']
VALID_RECORD_PARAMS_EXTRA = ['ttl', 'prio', 'health_check_id', 'disabled']


class AuroraDNSResponse(JsonResponse):
Expand Down
63 changes: 63 additions & 0 deletions libcloud/test/dns/test_auroradns.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and

import sys
import unittest

from libcloud.dns.drivers.auroradns import AuroraDNSDriver
from libcloud.dns.types import RecordType
from libcloud.test import LibcloudTestCase, MockHttpTestCase
from libcloud.test.secrets import DNS_PARAMS_AURORADNS
from libcloud.test.file_fixtures import DNSFileFixtures


class AuroraDNSDriverTests(LibcloudTestCase):

def setUp(self):
AuroraDNSDriver.connectionCls.conn_classes = \
(None, AuroraDNSDriverMockHttp)
AuroraDNSDriverMockHttp.type = None
self.driver = AuroraDNSDriver(*DNS_PARAMS_AURORADNS)

def test_merge_extra_data(self):
rdata = {
'name': 'localhost',
'type': RecordType.A,
'content': '127.0.0.1'
}

params = {'ttl': 900,
'prio': 0,
'health_check_id': None,
'disabled': False}

for param in params:
extra = {
param: params[param]
}

data = self.driver._AuroraDNSDriver__merge_extra_data(rdata,
extra)
self.assertEqual(data['content'], '127.0.0.1')
self.assertEqual(data['type'], RecordType.A)
self.assertEqual(data[param], params[param])
self.assertEqual(data['name'], 'localhost')


class AuroraDNSDriverMockHttp(MockHttpTestCase):
fixtures = DNSFileFixtures('auroradns')


if __name__ == '__main__':
sys.exit(unittest.main())
1 change: 1 addition & 0 deletions libcloud/test/secrets.py-dist
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,4 @@ DNS_PARAMS_ZONOMI = ('key')
DNS_PARAMS_DURABLEDNS = ('api_user', 'api_key')
DNS_PARAMS_GODADDY = ('customer-id', 'api_user', 'api_key')
DNS_PARAMS_CLOUDFLARE = ('user@example.com', 'key')
DNS_PARAMS_AURORADNS = ('apikey', 'secretkey')

0 comments on commit 9a747d3

Please sign in to comment.