View | Details | Raw Unified | Return to bug 39060
Collapse All | Expand All

(-)a/services/univention-s4-connector/modules/univention/s4connector/s4/__init__.py (+1 lines)
 Lines 2418-2423   class s4(univention.s4connector.ucs): Link Here 
2418
			if hasattr(self.property[property_type], 'dn_mapping_function'):
2418
			if hasattr(self.property[property_type], 'dn_mapping_function'):
2419
				tmp_object = copy.deepcopy(object)
2419
				tmp_object = copy.deepcopy(object)
2420
				tmp_object['dn'] = old_dn
2420
				tmp_object['dn'] = old_dn
2421
				del tmp_object['olddn']
2421
				for function in self.property[property_type].dn_mapping_function:
2422
				for function in self.property[property_type].dn_mapping_function:
2422
					tmp_object = function(self, tmp_object, [], isUCSobject=True)
2423
					tmp_object = function(self, tmp_object, [], isUCSobject=True)
2423
				old_dn = tmp_object['dn']
2424
				old_dn = tmp_object['dn']
(-)a/services/univention-s4-connector/modules/univention/s4connector/s4/dns.py (-17 / +16 lines)
 Lines 167-184   def dns_dn_mapping(s4connector, given_object, dn_mapping_stored, isUCSobject): Link Here 
167
			exploded_dn = ldap.dn.str2dn(unicode_to_utf8(dn))
167
			exploded_dn = ldap.dn.str2dn(unicode_to_utf8(dn))
168
			(fst_rdn_attribute_utf8, fst_rdn_value_utf8, _flags) = exploded_dn[0][0]
168
			(fst_rdn_attribute_utf8, fst_rdn_value_utf8, _flags) = exploded_dn[0][0]
169
169
170
			attributes_from_dn = {attr: value for rdn in exploded_dn
171
				for (attr, value, _flags) in rdn}
172
170
			if isUCSobject:
173
			if isUCSobject:
171
				ud.debug(ud.LDAP, ud.INFO, "dns_dn_mapping: got an UCS-Object")
174
				ud.debug(ud.LDAP, ud.INFO, "dns_dn_mapping: got an UCS-Object")
172
				# lookup the relativeDomainName as DC/dnsNode in S4 to get corresponding DN, if not found create new
175
				# lookup the relativeDomainName as DC/dnsNode in S4 to get corresponding DN, if not found create new
173
176
174
				try:
177
				try:
175
					relativeDomainName = obj['attributes'][ol_RR_attr][0]
178
					relativeDomainName = attributes_from_dn[ol_RR_attr]
176
				except (KeyError, IndexError):
179
				except KeyError:
177
					# Safety fallback for the unexpected case, where relativeDomainName would not be set
180
					try:
178
					if 'zoneName' == fst_rdn_attribute_utf8:
181
						relativeDomainName = obj['attributes'][ol_RR_attr][0]
179
						relativeDomainName = '@'
182
					except (KeyError, IndexError):
180
					else:
183
						# Safety fallback for the unexpected case, where relativeDomainName would not be set
181
						raise  # can't determine relativeDomainName
184
						if 'zoneName' == fst_rdn_attribute_utf8:
185
							relativeDomainName = '@'
186
						else:
187
							raise  # can't determine relativeDomainName
182
188
183
				if s4connector.property[propertyname].mapping_table and propertyattrib in s4connector.property[propertyname].mapping_table.keys():
189
				if s4connector.property[propertyname].mapping_table and propertyattrib in s4connector.property[propertyname].mapping_table.keys():
184
					for ucsval, conval in s4connector.property[propertyname].mapping_table[propertyattrib]:
190
					for ucsval, conval in s4connector.property[propertyname].mapping_table[propertyattrib]:
 Lines 191-205   def dns_dn_mapping(s4connector, given_object, dn_mapping_stored, isUCSobject): Link Here 
191
							pass  # values are not the same codec
197
							pass  # values are not the same codec
192
198
193
				try:
199
				try:
200
					ol_zone_name = attributes_from_dn['zoneName']
201
				except KeyError:
202
					# let exceptions pass through, we have no other fallback
194
					ol_zone_name = obj['attributes']['zoneName'][0]
203
					ol_zone_name = obj['attributes']['zoneName'][0]
195
				except (KeyError, IndexError):
196
					# Safety fallback for the unexpected case, where zoneName would not be set
197
					if ol_RR_attr == fst_rdn_attribute_utf8:
198
						(snd_rdn_attribute_utf8, snd_rdn_value_utf8, _flags) = exploded_dn[1][0]
199
						if 'zoneName' == snd_rdn_attribute_utf8:
200
							ol_zone_name = snd_rdn_value_utf8
201
						else:
202
							raise  # can't determine zoneName for this relativeDomainName
203
204
204
				target_RR_val = relativeDomainName
205
				target_RR_val = relativeDomainName
205
				target_zone_name = ol_zone_name
206
				target_zone_name = ol_zone_name
206
- 
207
--
208
test/ucs-test/tests/52_s4connector/175sync_create_dns_a_record          | 2 ++
207
test/ucs-test/tests/52_s4connector/175sync_create_dns_a_record          | 2 ++
209
test/ucs-test/tests/52_s4connector/175sync_create_dns_aaaa_record       | 2 ++
208
test/ucs-test/tests/52_s4connector/175sync_create_dns_aaaa_record       | 2 ++
210
test/ucs-test/tests/52_s4connector/175sync_create_dns_alias             | 2 ++
209
test/ucs-test/tests/52_s4connector/175sync_create_dns_alias             | 2 ++
211
.../tests/52_s4connector/175sync_create_dns_msdcs_record_con2ucs        | 2 ++
210
.../tests/52_s4connector/175sync_create_dns_msdcs_record_con2ucs        | 2 ++
212
.../tests/52_s4connector/175sync_create_dns_msdcs_record_ucs2con        | 2 ++
211
.../tests/52_s4connector/175sync_create_dns_msdcs_record_ucs2con        | 2 ++
213
test/ucs-test/tests/52_s4connector/175sync_create_dns_pointer_record    | 2 ++
212
test/ucs-test/tests/52_s4connector/175sync_create_dns_pointer_record    | 2 ++
214
test/ucs-test/tests/52_s4connector/175sync_create_dns_serial            | 2 ++
213
test/ucs-test/tests/52_s4connector/175sync_create_dns_serial            | 2 ++
215
test/ucs-test/tests/52_s4connector/175sync_create_dns_service_record    | 2 ++
214
test/ucs-test/tests/52_s4connector/175sync_create_dns_service_record    | 2 ++
216
test/ucs-test/tests/52_s4connector/175sync_create_dns_ttl               | 2 ++
215
test/ucs-test/tests/52_s4connector/175sync_create_dns_ttl               | 2 ++
217
test/ucs-test/tests/52_s4connector/175sync_create_dns_txt               | 2 ++
216
test/ucs-test/tests/52_s4connector/175sync_create_dns_txt               | 2 ++
218
test/ucs-test/tests/52_s4connector/175sync_create_dns_wildcard_host     | 2 ++
217
test/ucs-test/tests/52_s4connector/175sync_create_dns_wildcard_host     | 2 ++
219
11 files changed, 22 insertions(+)
218
11 files changed, 22 insertions(+)
(-)a/test/ucs-test/tests/52_s4connector/175sync_create_dns_a_record (+2 lines)
 Lines 6-11    Link Here 
6
##   - univention-directory-manager-tools
6
##   - univention-directory-manager-tools
7
##   - univention-s4-connector
7
##   - univention-s4-connector
8
##   - dnsutils
8
##   - dnsutils
9
## tags:
10
##  - s4c_dns
9
11
10
import univention.testing.udm as udm_test
12
import univention.testing.udm as udm_test
11
from univention.testing.utils import fail, wait_for_replication_and_postrun
13
from univention.testing.utils import fail, wait_for_replication_and_postrun
(-)a/test/ucs-test/tests/52_s4connector/175sync_create_dns_aaaa_record (+2 lines)
 Lines 6-11    Link Here 
6
##   - univention-directory-manager-tools
6
##   - univention-directory-manager-tools
7
##   - univention-s4-connector
7
##   - univention-s4-connector
8
##   - dnsutils
8
##   - dnsutils
9
## tags:
10
##  - s4c_dns
9
11
10
import univention.testing.udm as udm_test
12
import univention.testing.udm as udm_test
11
from univention.testing.utils import fail, wait_for_replication_and_postrun
13
from univention.testing.utils import fail, wait_for_replication_and_postrun
(-)a/test/ucs-test/tests/52_s4connector/175sync_create_dns_alias (+2 lines)
 Lines 6-11    Link Here 
6
##   - univention-directory-manager-tools
6
##   - univention-directory-manager-tools
7
##   - univention-s4-connector
7
##   - univention-s4-connector
8
##   - dnsutils
8
##   - dnsutils
9
## tags:
10
##  - s4c_dns
9
11
10
import univention.testing.strings as uts
12
import univention.testing.strings as uts
11
import univention.testing.udm as udm_test
13
import univention.testing.udm as udm_test
(-)a/test/ucs-test/tests/52_s4connector/175sync_create_dns_msdcs_record_con2ucs (+2 lines)
 Lines 6-11    Link Here 
6
##   - univention-directory-manager-tools
6
##   - univention-directory-manager-tools
7
##   - univention-s4-connector
7
##   - univention-s4-connector
8
##   - dnsutils
8
##   - dnsutils
9
## tags:
10
##  - s4c_dns
9
11
10
import univention.testing.strings as uts
12
import univention.testing.strings as uts
11
import univention.testing.udm as udm_test
13
import univention.testing.udm as udm_test
(-)a/test/ucs-test/tests/52_s4connector/175sync_create_dns_msdcs_record_ucs2con (+2 lines)
 Lines 6-11    Link Here 
6
##   - univention-directory-manager-tools
6
##   - univention-directory-manager-tools
7
##   - univention-s4-connector
7
##   - univention-s4-connector
8
##   - dnsutils
8
##   - dnsutils
9
## tags:
10
##  - s4c_dns
9
11
10
import univention.testing.strings as uts
12
import univention.testing.strings as uts
11
import univention.testing.utils as utils
13
import univention.testing.utils as utils
(-)a/test/ucs-test/tests/52_s4connector/175sync_create_dns_pointer_record (+2 lines)
 Lines 6-11    Link Here 
6
##   - univention-directory-manager-tools
6
##   - univention-directory-manager-tools
7
##   - univention-s4-connector
7
##   - univention-s4-connector
8
##   - dnsutils
8
##   - dnsutils
9
## tags:
10
##  - s4c_dns
9
11
10
import univention.testing.udm as udm_test
12
import univention.testing.udm as udm_test
11
import univention.testing.utils as utils
13
import univention.testing.utils as utils
(-)a/test/ucs-test/tests/52_s4connector/175sync_create_dns_serial (+2 lines)
 Lines 8-13    Link Here 
8
##   - dnsutils
8
##   - dnsutils
9
## bugs:
9
## bugs:
10
##   - 32156
10
##   - 32156
11
## tags:
12
##  - s4c_dns
11
13
12
import univention.testing.udm as udm_test
14
import univention.testing.udm as udm_test
13
import univention.testing.utils as utils
15
import univention.testing.utils as utils
(-)a/test/ucs-test/tests/52_s4connector/175sync_create_dns_service_record (+2 lines)
 Lines 6-11    Link Here 
6
##   - univention-directory-manager-tools
6
##   - univention-directory-manager-tools
7
##   - univention-s4-connector
7
##   - univention-s4-connector
8
##   - dnsutils
8
##   - dnsutils
9
## tags:
10
##  - s4c_dns
9
11
10
import univention.testing.udm as udm_test
12
import univention.testing.udm as udm_test
11
import univention.testing.utils as utils
13
import univention.testing.utils as utils
(-)a/test/ucs-test/tests/52_s4connector/175sync_create_dns_ttl (+2 lines)
 Lines 10-15    Link Here 
10
##   - 23732
10
##   - 23732
11
## versions:
11
## versions:
12
##  3.2-0: skip
12
##  3.2-0: skip
13
## tags:
14
##  - s4c_dns
13
15
14
16
15
import univention.testing.udm as udm_test
17
import univention.testing.udm as udm_test
(-)a/test/ucs-test/tests/52_s4connector/175sync_create_dns_txt (+2 lines)
 Lines 8-13    Link Here 
8
##   - dnsutils
8
##   - dnsutils
9
## versions:
9
## versions:
10
##  3.2-0: skip
10
##  3.2-0: skip
11
## tags:
12
##  - s4c_dns
11
13
12
import univention.testing.udm as udm_test
14
import univention.testing.udm as udm_test
13
import univention.testing.utils as utils
15
import univention.testing.utils as utils
(-)a/test/ucs-test/tests/52_s4connector/175sync_create_dns_wildcard_host (-2 / +2 lines)
 Lines 6-11    Link Here 
6
##   - univention-directory-manager-tools
6
##   - univention-directory-manager-tools
7
##   - univention-s4-connector
7
##   - univention-s4-connector
8
##   - dnsutils
8
##   - dnsutils
9
## tags:
10
##  - s4c_dns
9
11
10
import univention.testing.udm as udm_test
12
import univention.testing.udm as udm_test
11
import dnstests
13
import dnstests
12
- 
13
--
14
.../tests/52_s4connector/503_test_dns_rename.py    | 70 ++++++++++++++++++++++
14
.../tests/52_s4connector/503_test_dns_rename.py    | 70 ++++++++++++++++++++++
15
1 file changed, 70 insertions(+)
15
1 file changed, 70 insertions(+)
16
create mode 100755 test/ucs-test/tests/52_s4connector/503_test_dns_rename.py
16
create mode 100755 test/ucs-test/tests/52_s4connector/503_test_dns_rename.py
(-)a/test/ucs-test/tests/52_s4connector/503_test_dns_rename.py (-2 / +70 lines)
Line 0    Link Here 
0
- 
1
#!/usr/share/ucs-test/runner /usr/bin/py.test -s
2
# coding: utf-8
3
## desc: "Test the UCS<->AD sync in {read,write,sync} mode for dns objects."
4
## exposure: dangerous
5
## packages:
6
## - univention-s4-connector
7
## bugs:
8
##  - 39060
9
## tags:
10
##  - s4c_dns
11
12
import ldap
13
import pytest
14
15
from univention.testing.udm import UCSTestUDM
16
import univention.testing.connector_common as tcommon
17
import univention.testing.strings as tstring
18
19
import s4connector
20
from s4connector import (connector_running_on_this_host, connector_setup)
21
import dnstests
22
23
24
def build_s4_host_dn(host, zone, domain):
25
	first = [
26
		[("DC", host, ldap.AVA_STRING)],
27
		[("DC", zone, ldap.AVA_STRING)],
28
		[("CN", "MicrosoftDNS", ldap.AVA_STRING)],
29
		[("DC", "DomainDnsZones", ldap.AVA_STRING)],
30
	]
31
	return ldap.dn.dn2str(first + ldap.dn.str2dn(domain))
32
33
34
@pytest.mark.parametrize("sync_mode", ["write", "sync"])
35
@pytest.mark.skipif(not connector_running_on_this_host(),
36
	reason="Univention S4 Connector not configured.")
37
def test_attribute_sync_from_udm_to_s4(sync_mode):
38
	with connector_setup(sync_mode) as s4, UCSTestUDM() as udm:
39
		base = dnstests.ucr.get('ldap/base')
40
		ip = dnstests.make_random_ip()
41
		random_zone = dnstests.random_zone()
42
		random_host_a = tstring.random_name()
43
		random_host_b = tstring.random_name()
44
		nameserver = dnstests.get_hostname_of_ldap_master()
45
46
		print 'Creating objects..\n'
47
		zone_dn = udm.create_object('dns/forward_zone', zone=random_zone, nameserver=nameserver)
48
		host_dn = udm.create_object('dns/host_record', name=random_host_a, a=ip, superordinate=zone_dn)
49
		s4connector.wait_for_sync()
50
		s4_host_dn = build_s4_host_dn(random_host_a, random_zone, base)
51
		s4.verify_object(s4_host_dn, {"name": random_host_a, "dc": random_host_a})
52
		tcommon.verify_udm_object("dns/host_record", host_dn, {"name": random_host_a, "a": ip})
53
54
		print 'Modifying host record..\n'
55
		new_host_dn = udm.modify_object('dns/host_record', dn=host_dn, name=random_host_b)
56
57
		s4connector.wait_for_sync()
58
		s4_new_host_dn = build_s4_host_dn(random_host_b, random_zone, base)
59
		s4.verify_object(s4_host_dn, None)
60
		tcommon.verify_udm_object("dns/host_record", host_dn, None)
61
		s4.verify_object(s4_new_host_dn, {"name": random_host_b, "dc": random_host_b})
62
		tcommon.verify_udm_object("dns/host_record", new_host_dn, {"name": random_host_b, "a": ip})
63
64
		print 'Cleaning up..\n'
65
		udm.remove_object('dns/host_record', dn=new_host_dn)
66
		udm.remove_object('dns/forward_zone', dn=zone_dn)
67
68
		s4connector.wait_for_sync()
69
		s4.verify_object(s4_new_host_dn, None)
70
		tcommon.verify_udm_object("dns/host_record", new_host_dn, None)
1
503_test_dns_rename.py
71
503_test_dns_rename.py
2
--
3
test/ucs-test/tests/52_s4connector/503_test_dns_rename.py | 8 ++++++++
72
test/ucs-test/tests/52_s4connector/503_test_dns_rename.py | 8 ++++++++
4
1 file changed, 8 insertions(+)
73
1 file changed, 8 insertions(+)
(-)a/test/ucs-test/tests/52_s4connector/503_test_dns_rename.py (-1 / +8 lines)
 Lines 53-58   def test_attribute_sync_from_udm_to_s4(sync_mode): Link Here 
53
53
54
		print 'Modifying host record..\n'
54
		print 'Modifying host record..\n'
55
		new_host_dn = udm.modify_object('dns/host_record', dn=host_dn, name=random_host_b)
55
		new_host_dn = udm.modify_object('dns/host_record', dn=host_dn, name=random_host_b)
56
		# XXX after a modify, the old DN is _wrongly_ returned: see bug #41694
57
		if new_host_dn == host_dn:
58
			new_host_dn = ldap.dn.dn2str([[("relativeDomainName", random_host_b, ldap.AVA_STRING)]] +
59
				ldap.dn.str2dn(host_dn)[1:])
60
			if host_dn in udm._cleanup.get('dns/host_record', []):
61
				udm._cleanup.setdefault('dns/host_record', []).append(new_host_dn)
62
				udm._cleanup['dns/host_record'].remove(host_dn)
63
		# XXX end of workarround for bug #41694
56
64
57
		s4connector.wait_for_sync()
65
		s4connector.wait_for_sync()
58
		s4_new_host_dn = build_s4_host_dn(random_host_b, random_zone, base)
66
		s4_new_host_dn = build_s4_host_dn(random_host_b, random_zone, base)
59
- 

Return to bug 39060