@@ -117,6 +117,9 @@ def test_server_version_02(self):
117
117
self .assertEqual (expected , result )
118
118
119
119
120
+ CORRECT_PASSWORD = 'correct\u1680 password'
121
+
122
+
120
123
class TestAuthentication (tb .ConnectedTestCase ):
121
124
def setUp (self ):
122
125
super ().setUp ()
@@ -127,9 +130,9 @@ def setUp(self):
127
130
methods = [
128
131
('trust' , None ),
129
132
('reject' , None ),
130
- ('scram-sha-256' , 'correctpassword' ),
131
- ('md5' , 'correctpassword' ),
132
- ('password' , 'correctpassword' ),
133
+ ('scram-sha-256' , CORRECT_PASSWORD ),
134
+ ('md5' , CORRECT_PASSWORD ),
135
+ ('password' , CORRECT_PASSWORD ),
133
136
]
134
137
135
138
self .cluster .reset_hba ()
@@ -151,7 +154,7 @@ def setUp(self):
151
154
create_script .append (
152
155
'CREATE ROLE {}_user WITH LOGIN{};' .format (
153
156
username ,
154
- ' PASSWORD {!r}' . format (password ) if password else ' '
157
+ f ' PASSWORD E { (password or "" )!r } '
155
158
)
156
159
)
157
160
@@ -241,7 +244,7 @@ async def test_auth_reject(self):
241
244
async def test_auth_password_cleartext (self ):
242
245
conn = await self .connect (
243
246
user = 'password_user' ,
244
- password = 'correctpassword' )
247
+ password = CORRECT_PASSWORD )
245
248
await conn .close ()
246
249
247
250
with self .assertRaisesRegex (
@@ -253,7 +256,7 @@ async def test_auth_password_cleartext(self):
253
256
254
257
async def test_auth_password_cleartext_callable (self ):
255
258
def get_correctpassword ():
256
- return 'correctpassword'
259
+ return CORRECT_PASSWORD
257
260
258
261
def get_wrongpassword ():
259
262
return 'wrongpassword'
@@ -272,7 +275,7 @@ def get_wrongpassword():
272
275
273
276
async def test_auth_password_cleartext_callable_coroutine (self ):
274
277
async def get_correctpassword ():
275
- return 'correctpassword'
278
+ return CORRECT_PASSWORD
276
279
277
280
async def get_wrongpassword ():
278
281
return 'wrongpassword'
@@ -291,7 +294,7 @@ async def get_wrongpassword():
291
294
292
295
async def test_auth_password_cleartext_callable_awaitable (self ):
293
296
async def get_correctpassword ():
294
- return 'correctpassword'
297
+ return CORRECT_PASSWORD
295
298
296
299
async def get_wrongpassword ():
297
300
return 'wrongpassword'
@@ -310,7 +313,7 @@ async def get_wrongpassword():
310
313
311
314
async def test_auth_password_md5 (self ):
312
315
conn = await self .connect (
313
- user = 'md5_user' , password = 'correctpassword' )
316
+ user = 'md5_user' , password = CORRECT_PASSWORD )
314
317
await conn .close ()
315
318
316
319
with self .assertRaisesRegex (
@@ -325,7 +328,7 @@ async def test_auth_password_scram_sha_256(self):
325
328
return
326
329
327
330
conn = await self .connect (
328
- user = 'scram_sha_256_user' , password = 'correctpassword' )
331
+ user = 'scram_sha_256_user' , password = CORRECT_PASSWORD )
329
332
await conn .close ()
330
333
331
334
with self .assertRaisesRegex (
@@ -362,7 +365,7 @@ async def test_auth_password_scram_sha_256(self):
362
365
await conn .close ()
363
366
364
367
alter_password = \
365
- "ALTER ROLE scram_sha_256_user PASSWORD 'correctpassword' ;"
368
+ f "ALTER ROLE scram_sha_256_user PASSWORD E { CORRECT_PASSWORD !r } ;"
366
369
await self .con .execute (alter_password )
367
370
await self .con .execute ("SET password_encryption = 'md5';" )
368
371
@@ -372,7 +375,7 @@ async def test_auth_md5_unsupported(self, _):
372
375
exceptions .InternalClientError ,
373
376
".*no md5.*" ,
374
377
):
375
- await self .connect (user = 'md5_user' , password = 'correctpassword' )
378
+ await self .connect (user = 'md5_user' , password = CORRECT_PASSWORD )
376
379
377
380
378
381
class TestConnectParams (tb .TestCase ):
0 commit comments