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:08 +0000
commita25a936c4fd4486d66c434715f0cb8a6f404885d (patch)
tree358d18d7657bcf94a313d1e05bed7c39b34e4ddd
parentc966628978ac4ceb1d94ba92879df071b8ca265d (diff)
downloadswift-a25a936c4fd4486d66c434715f0cb8a6f404885d.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',