File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -573,8 +573,14 @@ cdef class CoreProtocol:
573573
574574 elif status == AUTH_REQUIRED_PASSWORD:
575575 # AuthenticationCleartextPassword
576- self .result_type = RESULT_OK
577- self .auth_msg = self ._auth_password_message_cleartext()
576+ if self .password is None :
577+ self .result_type = RESULT_FAILED
578+ self .result = apg_exc.InterfaceError(
579+ ' password authentication requested by server, '
580+ ' but no password was supplied' )
581+ else :
582+ self .result_type = RESULT_OK
583+ self .auth_msg = self ._auth_password_message_cleartext()
578584
579585 elif status == AUTH_REQUIRED_PASSWORDMD5:
580586 # AuthenticationMD5Password
Original file line number Diff line number Diff line change @@ -266,6 +266,12 @@ async def test_auth_password_cleartext(self):
266266 user = 'password_user' ,
267267 password = 'wrongpassword' )
268268
269+ async def test_auth_password_cleartext_without_password (self ):
270+ with self .assertRaisesRegex (
271+ asyncpg .InterfaceError , 'no password was supplied' ):
272+ await self ._try_connect (
273+ user = 'password_user' , password = None )
274+
269275 async def test_auth_password_cleartext_callable (self ):
270276 def get_correctpassword ():
271277 return CORRECT_PASSWORD
You can’t perform that action at this time.
0 commit comments