summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Burke <tim.burke@gmail.com>2021-12-13 12:58:32 -0800
committerTim Burke <tburke@nvidia.com>2021-12-14 23:49:40 +0000
commitade6b52f5058fb5f99f77645a468841abb3fc892 (patch)
tree71902c374f8456c3c08e9b0af2581df868957f59
parent4b0d6a87e9b2d0a032fe3b3a85e6fef0e5e8839f (diff)
downloadswift-ade6b52f5058fb5f99f77645a468841abb3fc892.tar.gz
Fix cname_lookup test
c.badtest.com actually has a CNAME now, and apparently we're actually doing the look-up during tests. Change-Id: I306b7d05740a2b8fcef2f5f432ebf5211bc723cc (cherry picked from commit 54fc8a7dee4ad7a38944cbd4c2e3b5f2ec393765)
-rw-r--r--test/unit/common/middleware/test_cname_lookup.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/test/unit/common/middleware/test_cname_lookup.py b/test/unit/common/middleware/test_cname_lookup.py
index 4e1a72f98..2dbea6654 100644
--- a/test/unit/common/middleware/test_cname_lookup.py
+++ b/test/unit/common/middleware/test_cname_lookup.py
@@ -305,7 +305,9 @@ class TestCNAMELookup(unittest.TestCase):
resp = do_test('c.badtest.com')
self.assertEqual(resp, bad_domain)
- def test_host_is_storage_domain(self):
+ @mock.patch('dns.resolver.Resolver.query',
+ side_effect=dns.exception.DNSException)
+ def test_host_is_storage_domain(self, mock_lookup):
conf = {'storage_domain': 'storage.example.com',
'lookup_depth': 2}
app = cname_lookup.CNAMELookupMiddleware(FakeApp(), conf)
@@ -318,9 +320,12 @@ class TestCNAMELookup(unittest.TestCase):
bad_domain = [b'CNAME lookup failed to resolve to a valid domain']
resp = do_test('c.badtest.com')
self.assertEqual(resp, bad_domain)
+ self.assertEqual(1, len(mock_lookup.mock_calls))
+ mock_lookup.reset_mock()
resp = do_test('storage.example.com')
self.assertEqual(resp, [b'FAKE APP'])
+ self.assertEqual(0, len(mock_lookup.mock_calls))
def test_resolution_to_storage_domain_exactly(self):
conf = {'storage_domain': 'example.com',