Skip to content
Merged
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
2 changes: 1 addition & 1 deletion asyncpg/protocol/coreproto.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ cdef class CoreProtocol:
WriteBuffer msg

msg = WriteBuffer.new_message(b'p')
msg.write_bytestring(self.password.encode(self.encoding))
msg.write_bytestring((self.password or '').encode(self.encoding))
msg.end_message()

return msg
Expand Down
5 changes: 5 additions & 0 deletions tests/test_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,11 @@ async def test_auth_password_cleartext(self):
user='password_user',
password='wrongpassword')

async def test_auth_password_cleartext_without_password(self):
with self.assertRaises(asyncpg.InvalidPasswordError):
await self._try_connect(
user='password_user', password=lambda: None)

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