|
2 | 2 | from pathlib import Path |
3 | 3 | import requests |
4 | 4 | from requests.auth import HTTPBasicAuth |
| 5 | +import time |
5 | 6 |
|
6 | 7 |
|
7 | 8 | def main(): |
@@ -29,21 +30,62 @@ def download_jdbc(version): |
29 | 30 | resp.raise_for_status() |
30 | 31 | target.write_bytes(resp.content) |
31 | 32 |
|
32 | | - |
33 | 33 | def create_user(): |
34 | 34 | requests.post( |
35 | 35 | "http://localhost:8000/v1/query/", |
36 | 36 | auth=HTTPBasicAuth("root", ""), |
37 | 37 | headers={"Content-Type": "application/json"}, |
38 | | - json={"sql": "CREATE USER IF NOT EXISTS databend IDENTIFIED BY 'databend'"}, |
| 38 | + json={"sql": "DROP USER IF EXISTS databend"}, |
39 | 39 | ).raise_for_status() |
40 | 40 | requests.post( |
41 | 41 | "http://localhost:8000/v1/query/", |
42 | 42 | auth=HTTPBasicAuth("root", ""), |
43 | 43 | headers={"Content-Type": "application/json"}, |
44 | | - json={"sql": "GRANT ALL ON *.* TO databend"}, |
| 44 | + json={"sql": "DROP ROLE IF EXISTS test_jdbc"}, |
| 45 | + ).raise_for_status() |
| 46 | + requests.post( |
| 47 | + "http://localhost:8000/v1/query/", |
| 48 | + auth=HTTPBasicAuth("root", ""), |
| 49 | + headers={"Content-Type": "application/json"}, |
| 50 | + json={"sql": "CREATE USER databend IDENTIFIED BY 'databend' with default_role='test_jdbc'"}, |
| 51 | + ).raise_for_status() |
| 52 | + requests.post( |
| 53 | + "http://localhost:8000/v1/query/", |
| 54 | + auth=HTTPBasicAuth("root", ""), |
| 55 | + headers={"Content-Type": "application/json"}, |
| 56 | + json={"sql": "CREATE ROLE test_jdbc"}, |
| 57 | + ).raise_for_status() |
| 58 | + requests.post( |
| 59 | + "http://localhost:8000/v1/query/", |
| 60 | + auth=HTTPBasicAuth("root", ""), |
| 61 | + headers={"Content-Type": "application/json"}, |
| 62 | + json={"sql": "GRANT ALL ON *.* TO ROLE test_jdbc"}, |
| 63 | + ).raise_for_status() |
| 64 | + requests.post( |
| 65 | + "http://localhost:8000/v1/query/", |
| 66 | + auth=HTTPBasicAuth("root", ""), |
| 67 | + headers={"Content-Type": "application/json"}, |
| 68 | + json={"sql": "GRANT ROLE test_jdbc TO USER databend"}, |
| 69 | + ).raise_for_status() |
| 70 | + time.sleep(16) |
| 71 | + requests.post( |
| 72 | + "http://localhost:8001/v1/query/", |
| 73 | + auth=HTTPBasicAuth("root", ""), |
| 74 | + headers={"Content-Type": "application/json"}, |
| 75 | + json={"sql": "SHOW GRANTS FOR USER databend"}, |
| 76 | + ).raise_for_status() |
| 77 | + requests.post( |
| 78 | + "http://localhost:8002/v1/query/", |
| 79 | + auth=HTTPBasicAuth("root", ""), |
| 80 | + headers={"Content-Type": "application/json"}, |
| 81 | + json={"sql": "SHOW GRANTS FOR USER databend"}, |
| 82 | + ).raise_for_status() |
| 83 | + requests.post( |
| 84 | + "http://localhost:8003/v1/query/", |
| 85 | + auth=HTTPBasicAuth("root", ""), |
| 86 | + headers={"Content-Type": "application/json"}, |
| 87 | + json={"sql": "SHOW GRANTS FOR USER databend"}, |
45 | 88 | ).raise_for_status() |
46 | | - |
47 | 89 |
|
48 | 90 | def download_testng(): |
49 | 91 | urls = [ |
|
0 commit comments