Merge "Ensure Sink Handlers encode UTF8 names"
This commit is contained in:
commit
b674cbf6ac
@ -66,6 +66,8 @@ class NotificationHandler(ExtensionPlugin):
|
|||||||
|
|
||||||
def _find_or_create_recordset(self, context, domain_id, name, type,
|
def _find_or_create_recordset(self, context, domain_id, name, type,
|
||||||
ttl=None):
|
ttl=None):
|
||||||
|
name = name.encode('idna')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
recordset = self.central_api.find_recordset(context, {
|
recordset = self.central_api.find_recordset(context, {
|
||||||
'domain_id': domain_id,
|
'domain_id': domain_id,
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright 2012 Managed I.T.
|
# Copyright 2012 Managed I.T.
|
||||||
#
|
#
|
||||||
# Author: Kiall Mac Innes <kiall@managedit.ie>
|
# Author: Kiall Mac Innes <kiall@managedit.ie>
|
||||||
@ -59,6 +60,44 @@ class NovaFixedHandlerTest(TestCase, NotificationHandlerMixin):
|
|||||||
|
|
||||||
self.assertEqual(3, len(records))
|
self.assertEqual(3, len(records))
|
||||||
|
|
||||||
|
def test_instance_create_end_utf8(self):
|
||||||
|
self.config(format='%(display_name)s.%(domain)s',
|
||||||
|
group='handler:nova_fixed')
|
||||||
|
|
||||||
|
event_type = 'compute.instance.create.end'
|
||||||
|
fixture = self.get_notification_fixture('nova', event_type)
|
||||||
|
|
||||||
|
# Set the instance display_name to a string containing UTF8.
|
||||||
|
fixture['payload']['display_name'] = u'Test↟Instance'
|
||||||
|
|
||||||
|
self.assertIn(event_type, self.plugin.get_event_types())
|
||||||
|
|
||||||
|
criterion = {'domain_id': self.domain_id}
|
||||||
|
|
||||||
|
# Ensure we start with 2 records
|
||||||
|
recordsets = self.central_service.find_recordsets(
|
||||||
|
self.admin_context, criterion)
|
||||||
|
|
||||||
|
# Should only be SOA and NS recordsets
|
||||||
|
self.assertEqual(2, len(recordsets))
|
||||||
|
|
||||||
|
self.plugin.process_notification(
|
||||||
|
self.admin_context, event_type, fixture['payload'])
|
||||||
|
|
||||||
|
# Ensure we now have exactly 1 more recordset
|
||||||
|
recordsets = self.central_service.find_recordsets(
|
||||||
|
self.admin_context, criterion)
|
||||||
|
|
||||||
|
self.assertEqual(3, len(recordsets))
|
||||||
|
|
||||||
|
# Ensure the created record was correctly converted per IDN rules.
|
||||||
|
criterion['type'] = 'A'
|
||||||
|
recordsets = self.central_service.find_recordsets(
|
||||||
|
self.admin_context, criterion)
|
||||||
|
|
||||||
|
self.assertEqual('xn--testinstance-q83g.example.com.',
|
||||||
|
recordsets[0].name)
|
||||||
|
|
||||||
def test_instance_delete_start(self):
|
def test_instance_delete_start(self):
|
||||||
# Prepare for the test
|
# Prepare for the test
|
||||||
start_event_type = 'compute.instance.create.end'
|
start_event_type = 'compute.instance.create.end'
|
||||||
|
Loading…
Reference in New Issue
Block a user