Skip to content

Commit ec3c1f0

Browse files
committed
fix test
1 parent cb852dd commit ec3c1f0

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

test/asynchronous/test_auth.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
import pytest
3636

3737
from pymongo import AsyncMongoClient, monitoring
38-
from pymongo.asynchronous.auth import HAVE_KERBEROS
38+
from pymongo.asynchronous.auth import HAVE_KERBEROS, _canonicalize_hostname
3939
from pymongo.auth_shared import _build_credentials_tuple
4040
from pymongo.errors import OperationFailure
4141
from pymongo.hello import HelloCompat
@@ -331,6 +331,12 @@ async def test_gssapi_host_name(self):
331331
)
332332
await client.server_info()
333333

334+
def test_canonicalize_host_name(self):
335+
result = _canonicalize_hostname(GSSAPI_HOST, "forward")
336+
self.assertIn("compute-1.amazonaws.com", result)
337+
result = _canonicalize_hostname(GSSAPI_HOST, "forwardAndReverse")
338+
self.assertEqual(result, GSSAPI_HOST)
339+
334340

335341
class TestSASLPlain(AsyncPyMongoTestCase):
336342
@classmethod

test/test_auth.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
from pymongo.hello import HelloCompat
4141
from pymongo.read_preferences import ReadPreference
4242
from pymongo.saslprep import HAVE_STRINGPREP
43-
from pymongo.synchronous.auth import HAVE_KERBEROS
43+
from pymongo.synchronous.auth import HAVE_KERBEROS, _canonicalize_hostname
4444

4545
_IS_SYNC = True
4646

@@ -331,6 +331,12 @@ def test_gssapi_host_name(self):
331331
)
332332
client.server_info()
333333

334+
def test_canonicalize_host_name(self):
335+
result = _canonicalize_hostname(GSSAPI_HOST, "forward")
336+
self.assertIn("compute-1.amazonaws.com", result)
337+
result = _canonicalize_hostname(GSSAPI_HOST, "forwardAndReverse")
338+
self.assertEqual(result, GSSAPI_HOST)
339+
334340

335341
class TestSASLPlain(PyMongoTestCase):
336342
@classmethod

0 commit comments

Comments
 (0)