@@ -126,6 +126,9 @@ def test_server_version_02(self):
126
126
self .assertEqual (expected , result )
127
127
128
128
129
+ CORRECT_PASSWORD = 'correct\u1680 password'
130
+
131
+
129
132
class TestAuthentication (tb .ConnectedTestCase ):
130
133
def setUp (self ):
131
134
super ().setUp ()
@@ -136,9 +139,9 @@ def setUp(self):
136
139
methods = [
137
140
('trust' , None ),
138
141
('reject' , None ),
139
- ('scram-sha-256' , 'correctpassword' ),
140
- ('md5' , 'correctpassword' ),
141
- ('password' , 'correctpassword' ),
142
+ ('scram-sha-256' , CORRECT_PASSWORD ),
143
+ ('md5' , CORRECT_PASSWORD ),
144
+ ('password' , CORRECT_PASSWORD ),
142
145
]
143
146
144
147
self .cluster .reset_hba ()
@@ -160,7 +163,7 @@ def setUp(self):
160
163
create_script .append (
161
164
'CREATE ROLE {}_user WITH LOGIN{};' .format (
162
165
username ,
163
- ' PASSWORD {!r}' . format (password ) if password else ' '
166
+ f ' PASSWORD E { (password or "" )!r } '
164
167
)
165
168
)
166
169
@@ -250,7 +253,7 @@ async def test_auth_reject(self):
250
253
async def test_auth_password_cleartext (self ):
251
254
conn = await self .connect (
252
255
user = 'password_user' ,
253
- password = 'correctpassword' )
256
+ password = CORRECT_PASSWORD )
254
257
await conn .close ()
255
258
256
259
with self .assertRaisesRegex (
@@ -262,7 +265,7 @@ async def test_auth_password_cleartext(self):
262
265
263
266
async def test_auth_password_cleartext_callable (self ):
264
267
def get_correctpassword ():
265
- return 'correctpassword'
268
+ return CORRECT_PASSWORD
266
269
267
270
def get_wrongpassword ():
268
271
return 'wrongpassword'
@@ -281,7 +284,7 @@ def get_wrongpassword():
281
284
282
285
async def test_auth_password_cleartext_callable_coroutine (self ):
283
286
async def get_correctpassword ():
284
- return 'correctpassword'
287
+ return CORRECT_PASSWORD
285
288
286
289
async def get_wrongpassword ():
287
290
return 'wrongpassword'
@@ -300,7 +303,7 @@ async def get_wrongpassword():
300
303
301
304
async def test_auth_password_cleartext_callable_awaitable (self ):
302
305
async def get_correctpassword ():
303
- return 'correctpassword'
306
+ return CORRECT_PASSWORD
304
307
305
308
async def get_wrongpassword ():
306
309
return 'wrongpassword'
@@ -319,7 +322,7 @@ async def get_wrongpassword():
319
322
320
323
async def test_auth_password_md5 (self ):
321
324
conn = await self .connect (
322
- user = 'md5_user' , password = 'correctpassword' )
325
+ user = 'md5_user' , password = CORRECT_PASSWORD )
323
326
await conn .close ()
324
327
325
328
with self .assertRaisesRegex (
@@ -334,7 +337,7 @@ async def test_auth_password_scram_sha_256(self):
334
337
return
335
338
336
339
conn = await self .connect (
337
- user = 'scram_sha_256_user' , password = 'correctpassword' )
340
+ user = 'scram_sha_256_user' , password = CORRECT_PASSWORD )
338
341
await conn .close ()
339
342
340
343
with self .assertRaisesRegex (
@@ -371,7 +374,7 @@ async def test_auth_password_scram_sha_256(self):
371
374
await conn .close ()
372
375
373
376
alter_password = \
374
- "ALTER ROLE scram_sha_256_user PASSWORD 'correctpassword' ;"
377
+ f "ALTER ROLE scram_sha_256_user PASSWORD E { CORRECT_PASSWORD !r } ;"
375
378
await self .con .execute (alter_password )
376
379
await self .con .execute ("SET password_encryption = 'md5';" )
377
380
@@ -381,7 +384,7 @@ async def test_auth_md5_unsupported(self, _):
381
384
exceptions .InternalClientError ,
382
385
".*no md5.*" ,
383
386
):
384
- await self .connect (user = 'md5_user' , password = 'correctpassword' )
387
+ await self .connect (user = 'md5_user' , password = CORRECT_PASSWORD )
385
388
386
389
387
390
class TestConnectParams (tb .TestCase ):
0 commit comments