@@ -41,6 +41,46 @@ async def cleanup(self, request, management_client: TGlideClient):
41
41
except RequestError :
42
42
pass
43
43
44
+ @pytest .mark .parametrize ("cluster_mode" , [True , False ])
45
+ @pytest .mark .parametrize ("protocol" , [ProtocolVersion .RESP2 , ProtocolVersion .RESP3 ])
46
+ async def test_update_connection_password (
47
+ self , glide_client : TGlideClient , management_client : TGlideClient
48
+ ):
49
+ """
50
+ Test replacing the connection password without immediate re-authentication.
51
+ Verifies that:
52
+ 1. The client can update its internal password
53
+ 2. The client remains connected with current auth
54
+ 3. The client can reconnect using the new password after server password change
55
+ This test is only for cluster mode, as standalone mode does not have a connection available handler
56
+ """
57
+ result = await glide_client .update_connection_password (
58
+ NEW_PASSWORD , immediate_auth = False
59
+ )
60
+ assert result == OK
61
+ # Verify that the client is still authenticated
62
+ assert await glide_client .set ("test_key" , "test_value" ) == OK
63
+ value = await glide_client .get ("test_key" )
64
+ assert value == b"test_value"
65
+ await config_set_new_password (glide_client , NEW_PASSWORD )
66
+ await kill_connections (management_client )
67
+ # Add a short delay to allow the server to apply the new password
68
+ # without this delay, command may or may not time out while the client reconnect
69
+ # ending up with a flaky test
70
+ await asyncio .sleep (2 )
71
+ # Verify that the client is able to reconnect with the new password,
72
+ value = await glide_client .get ("test_key" )
73
+ assert value == b"test_value"
74
+ await kill_connections (management_client )
75
+ await asyncio .sleep (2 )
76
+ # Verify that the client is able to immediateAuth with the new password after client is killed
77
+ result = await glide_client .update_connection_password (
78
+ NEW_PASSWORD , immediate_auth = True
79
+ )
80
+ assert result == OK
81
+ # Verify that the client is still authenticated
82
+ assert await glide_client .set ("test_key" , "test_value" ) == OK
83
+
44
84
@pytest .mark .parametrize ("cluster_mode" , [False ])
45
85
@pytest .mark .parametrize ("protocol" , [ProtocolVersion .RESP2 , ProtocolVersion .RESP3 ])
46
86
async def test_update_connection_password_connection_lost_before_password_update (
@@ -54,7 +94,7 @@ async def test_update_connection_password_connection_lost_before_password_update
54
94
await glide_client .set ("test_key" , "test_value" )
55
95
await config_set_new_password (glide_client , NEW_PASSWORD )
56
96
await kill_connections (management_client )
57
- await asyncio .sleep (1 )
97
+ await asyncio .sleep (2 )
58
98
result = await glide_client .update_connection_password (
59
99
NEW_PASSWORD , immediate_auth = False
60
100
)
@@ -176,6 +216,9 @@ async def test_update_connection_password_with_acl_user(
176
216
management_client , USERNAME , NEW_PASSWORD
177
217
)
178
218
219
+ # Sleep to allow enough time for reconnecting
220
+ await asyncio .sleep (2 )
221
+
179
222
# The client should now reconnect with the new password automatically
180
223
# Verify that the client is still able to perform operations
181
224
value = await acl_glide_client .get ("test_key" )
@@ -208,6 +251,9 @@ async def test_update_connection_password_reconnection_with_immediate_auth_with_
208
251
management_client , USERNAME , NEW_PASSWORD
209
252
)
210
253
254
+ # Sleep to allow enough time for reconnecting
255
+ await asyncio .sleep (2 )
256
+
211
257
result = await acl_glide_client .update_connection_password (
212
258
NEW_PASSWORD , immediate_auth = True
213
259
)
0 commit comments