Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions asyncpg/protocol/coreproto.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -573,8 +573,14 @@ cdef class CoreProtocol:

elif status == AUTH_REQUIRED_PASSWORD:
# AuthenticationCleartextPassword
self.result_type = RESULT_OK
self.auth_msg = self._auth_password_message_cleartext()
if self.password is None:
self.result_type = RESULT_FAILED
self.result = apg_exc.InterfaceError(
'password authentication requested by server, '
'but no password was supplied')
else:
self.result_type = RESULT_OK
self.auth_msg = self._auth_password_message_cleartext()

elif status == AUTH_REQUIRED_PASSWORDMD5:
# AuthenticationMD5Password
Expand Down
6 changes: 6 additions & 0 deletions tests/test_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,12 @@ async def test_auth_password_cleartext(self):
user='password_user',
password='wrongpassword')

async def test_auth_password_cleartext_without_password(self):
with self.assertRaisesRegex(
asyncpg.InterfaceError, 'no password was supplied'):
await self._try_connect(
user='password_user', password=None)

async def test_auth_password_cleartext_callable(self):
def get_correctpassword():
return CORRECT_PASSWORD
Expand Down