Merge "Encode username and password for basic auth"

This commit is contained in:
Zuul 2024-12-20 06:38:02 +00:00 committed by Gerrit Code Review
commit 62a07420a0
2 changed files with 5 additions and 2 deletions

View File

@ -74,7 +74,9 @@ class RequestsHTTPProviderTestCase(unittest.TestCase):
mock_api, cluster.Provider('9.8.7.6', 'https://9.8.7.6',
'nsxuser', password, None))
self.assertEqual(('nsxuser', password), session.auth)
self.assertEqual(('nsxuser'.encode('utf-8'),
password.encode('utf-8')),
session.auth)
self.assertFalse(session.verify)
self.assertIsNone(session.cert)
self.assertEqual(100,

View File

@ -214,7 +214,8 @@ class NSXRequestsHTTPProvider(AbstractHTTPProvider):
# Set the headers with Auth info when token provider is set,
# otherwise set the username and password
elif not config.token_provider:
session.auth = (provider.username, provider.password)
session.auth = (provider.username.encode('utf-8'),
provider.password.encode('utf-8'))
# NSX v3 doesn't use redirects
session.max_redirects = 0