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 54fc8a7dee)
This commit is contained in:
Tim Burke 2021-12-13 12:58:32 -08:00 committed by Tim Burke
parent 4b0d6a87e9
commit ade6b52f50
1 changed files with 6 additions and 1 deletions

View File

@ -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',