Blame SOURCES/0015-Work-with-existing-resolve_rrsets-and-newer-resolve_.patch

9b0b1a
From d59a031264c5b30ce2686d2c2bd6d756b05ebcc8 Mon Sep 17 00:00:00 2001
9b0b1a
From: root <root@ipa.example.test>
9b0b1a
Date: Thu, 7 Oct 2021 18:02:30 -0400
9b0b1a
Subject: [PATCH] Work with existing resolve_rrsets and newer
9b0b1a
 resolve_rrsets_nss
9b0b1a
9b0b1a
Up to freeipa 4.8.9 resolve_rrsets is used to look up the
9b0b1a
ipa-ca values. After that, and in master, resovle_rrsets_nss
9b0b1a
is used instead. Handle both in the DNS mock testing.
9b0b1a
---
9b0b1a
 tests/test_ipa_dns.py | 27 ++++++++++++++++++---------
9b0b1a
 1 file changed, 18 insertions(+), 9 deletions(-)
9b0b1a
9b0b1a
diff --git a/tests/test_ipa_dns.py b/tests/test_ipa_dns.py
9b0b1a
index b6a9610..91b15c2 100644
9b0b1a
--- a/tests/test_ipa_dns.py
9b0b1a
+++ b/tests/test_ipa_dns.py
9b0b1a
@@ -27,6 +27,15 @@ from ipaserver.dns_data_management import (
9b0b1a
     IPA_DEFAULT_ADTRUST_SRV_REC
9b0b1a
 )
9b0b1a
 
9b0b1a
+try:
9b0b1a
+    # pylint: disable=unused-import
9b0b1a
+    from ipaserver.install.installutils import resolve_rrsets_nss  # noqa: F401
9b0b1a
+    # pylint: enable=unused-import
9b0b1a
+except ImportError:
9b0b1a
+    resolve_rrsets_import = 'ipaserver.dns_data_management.resolve_rrsets'
9b0b1a
+else:
9b0b1a
+    resolve_rrsets_import = 'ipaserver.install.installutils.resolve_rrsets_nss'
9b0b1a
+
9b0b1a
 
9b0b1a
 def add_srv_records(qname, port_map, priority=0, weight=100):
9b0b1a
     rdlist = []
9b0b1a
@@ -182,7 +191,7 @@ class TestDNSSystemRecords(BaseTest):
9b0b1a
        2. fake_query() overrides dns.resolver.query to simulate
9b0b1a
           A, AAAA and TXT record lookups.
9b0b1a
     """
9b0b1a
-    @patch('ipaserver.dns_data_management.resolve_rrsets')
9b0b1a
+    @patch(resolve_rrsets_import)
9b0b1a
     @patch('ipapython.dnsutil.query_srv')
9b0b1a
     @patch('dns.resolver.query')
9b0b1a
     def test_dnsrecords_single(self, mock_query, mock_query_srv, mock_rrset):
9b0b1a
@@ -217,7 +226,7 @@ class TestDNSSystemRecords(BaseTest):
9b0b1a
             assert result.source == 'ipahealthcheck.ipa.idns'
9b0b1a
             assert result.check == 'IPADNSSystemRecordsCheck'
9b0b1a
 
9b0b1a
-    @patch('ipaserver.dns_data_management.resolve_rrsets')
9b0b1a
+    @patch(resolve_rrsets_import)
9b0b1a
     @patch('ipapython.dnsutil.query_srv')
9b0b1a
     @patch('dns.resolver.query')
9b0b1a
     def test_dnsrecords_two(self, mock_query, mock_query_srv, mock_rrset):
9b0b1a
@@ -265,7 +274,7 @@ class TestDNSSystemRecords(BaseTest):
9b0b1a
             assert result.source == 'ipahealthcheck.ipa.idns'
9b0b1a
             assert result.check == 'IPADNSSystemRecordsCheck'
9b0b1a
 
9b0b1a
-    @patch('ipaserver.dns_data_management.resolve_rrsets')
9b0b1a
+    @patch(resolve_rrsets_import)
9b0b1a
     @patch('ipapython.dnsutil.query_srv')
9b0b1a
     @patch('dns.resolver.query')
9b0b1a
     def test_dnsrecords_three(self, mock_query, mock_query_srv, mock_rrset):
9b0b1a
@@ -323,7 +332,7 @@ class TestDNSSystemRecords(BaseTest):
9b0b1a
             assert result.source == 'ipahealthcheck.ipa.idns'
9b0b1a
             assert result.check == 'IPADNSSystemRecordsCheck'
9b0b1a
 
9b0b1a
-    @patch('ipaserver.dns_data_management.resolve_rrsets')
9b0b1a
+    @patch(resolve_rrsets_import)
9b0b1a
     @patch('ipapython.dnsutil.query_srv')
9b0b1a
     @patch('dns.resolver.query')
9b0b1a
     def test_dnsrecords_three_mixed(self, mock_query, mock_query_srv,
9b0b1a
@@ -379,7 +388,7 @@ class TestDNSSystemRecords(BaseTest):
9b0b1a
             assert result.result == constants.SUCCESS
9b0b1a
             assert result.source == 'ipahealthcheck.ipa.idns'
9b0b1a
 
9b0b1a
-    @patch('ipaserver.dns_data_management.resolve_rrsets')
9b0b1a
+    @patch(resolve_rrsets_import)
9b0b1a
     @patch('ipapython.dnsutil.query_srv')
9b0b1a
     @patch('dns.resolver.query')
9b0b1a
     def test_dnsrecords_missing_server(self, mock_query, mock_query_srv,
9b0b1a
@@ -445,7 +454,7 @@ class TestDNSSystemRecords(BaseTest):
9b0b1a
         for result in warn:
9b0b1a
             assert result.kw.get('msg') == 'Expected SRV record missing'
9b0b1a
 
9b0b1a
-    @patch('ipaserver.dns_data_management.resolve_rrsets')
9b0b1a
+    @patch(resolve_rrsets_import)
9b0b1a
     @patch('ipapython.dnsutil.query_srv')
9b0b1a
     @patch('dns.resolver.query')
9b0b1a
     def test_dnsrecords_missing_ipa_ca(self, mock_query, mock_query_srv,
9b0b1a
@@ -516,7 +525,7 @@ class TestDNSSystemRecords(BaseTest):
9b0b1a
             assert result.kw.get('count') == 2
9b0b1a
             assert result.kw.get('expected') == 3
9b0b1a
 
9b0b1a
-    @patch('ipaserver.dns_data_management.resolve_rrsets')
9b0b1a
+    @patch(resolve_rrsets_import)
9b0b1a
     @patch('ipapython.dnsutil.query_srv')
9b0b1a
     @patch('dns.resolver.query')
9b0b1a
     def test_dnsrecords_extra_srv(self, mock_query, mock_query_srv,
9b0b1a
@@ -586,7 +595,7 @@ class TestDNSSystemRecords(BaseTest):
9b0b1a
             assert result.kw.get('msg') == \
9b0b1a
                 'Unexpected SRV entry in DNS'
9b0b1a
 
9b0b1a
-    @patch('ipaserver.dns_data_management.resolve_rrsets')
9b0b1a
+    @patch(resolve_rrsets_import)
9b0b1a
     @patch('ipapython.dnsutil.query_srv')
9b0b1a
     @patch('dns.resolver.query')
9b0b1a
     def test_dnsrecords_bad_realm(self, mock_query, mock_query_srv,
9b0b1a
@@ -626,7 +635,7 @@ class TestDNSSystemRecords(BaseTest):
9b0b1a
         assert result.kw.get('msg') == 'expected realm missing'
9b0b1a
         assert result.kw.get('key') == '\"FAKE_REALM\"'
9b0b1a
 
9b0b1a
-    @patch('ipaserver.dns_data_management.resolve_rrsets')
9b0b1a
+    @patch(resolve_rrsets_import)
9b0b1a
     @patch('ipapython.dnsutil.query_srv')
9b0b1a
     @patch('dns.resolver.query')
9b0b1a
     def test_dnsrecords_one_with_ad(self, mock_query, mock_query_srv,
9b0b1a
-- 
9b0b1a
2.27.0
9b0b1a