File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change 1+ import pytest
2+ import ydb
3+
4+ from concurrent .futures import TimeoutError
5+
6+
7+ USERNAME = "root"
8+ PASSWORD = "1234"
9+
10+
11+ def check_driver_works (driver ):
12+ driver .wait (timeout = 15 )
13+ pool = ydb .QuerySessionPool (driver )
14+ result = pool .execute_with_retries ("SELECT 1 as cnt" )
15+ assert result [0 ].rows [0 ].cnt == 1
16+
17+
18+ def test_static_credentials_default (endpoint , database ):
19+ driver_config = ydb .DriverConfig (
20+ endpoint ,
21+ database
22+ )
23+ credentials = ydb .StaticCredentials (driver_config , USERNAME , PASSWORD )
24+
25+ with ydb .Driver (driver_config = driver_config , credentials = credentials ) as driver :
26+ check_driver_works (driver )
27+
28+
29+ def test_static_credentials_classmethod (endpoint , database ):
30+ driver_config = ydb .DriverConfig (
31+ endpoint ,
32+ database ,
33+ credentials = ydb .StaticCredentials .from_user_password (USERNAME , PASSWORD )
34+ )
35+
36+ with ydb .Driver (driver_config = driver_config ) as driver :
37+ check_driver_works (driver )
38+
39+
40+ def test_static_credentials_wrong_creds (endpoint , database ):
41+ driver_config = ydb .DriverConfig (
42+ endpoint ,
43+ database ,
44+ credentials = ydb .StaticCredentials .from_user_password (USERNAME , PASSWORD * 2 )
45+ )
46+
47+ with pytest .raises (TimeoutError ):
48+ with ydb .Driver (driver_config = driver_config ) as driver :
49+ driver .wait (5 )
50+
You can’t perform that action at this time.
0 commit comments