mirror of
https://github.com/warp-tech/warpgate.git
synced 2024-09-20 06:46:17 +08:00
temporarily exclude mysql test
This commit is contained in:
parent
1e533e9090
commit
fee236231b
|
@ -1,105 +1,105 @@
|
||||||
import subprocess
|
# import subprocess
|
||||||
import time
|
# import time
|
||||||
from uuid import uuid4
|
# from uuid import uuid4
|
||||||
|
|
||||||
from .api_client import (
|
# from .api_client import (
|
||||||
api_admin_session,
|
# api_admin_session,
|
||||||
api_create_target,
|
# api_create_target,
|
||||||
api_create_user,
|
# api_create_user,
|
||||||
api_create_role,
|
# api_create_role,
|
||||||
api_add_role_to_user,
|
# api_add_role_to_user,
|
||||||
api_add_role_to_target,
|
# api_add_role_to_target,
|
||||||
)
|
# )
|
||||||
from .conftest import WarpgateProcess, ProcessManager
|
# from .conftest import WarpgateProcess, ProcessManager
|
||||||
from .util import wait_port, wait_mysql_port, mysql_client_ssl_opt, mysql_client_opts
|
# from .util import wait_port, wait_mysql_port, mysql_client_ssl_opt, mysql_client_opts
|
||||||
|
|
||||||
|
|
||||||
class Test:
|
# class Test:
|
||||||
def test(
|
# def test(
|
||||||
self,
|
# self,
|
||||||
processes: ProcessManager,
|
# processes: ProcessManager,
|
||||||
timeout,
|
# timeout,
|
||||||
shared_wg: WarpgateProcess,
|
# shared_wg: WarpgateProcess,
|
||||||
):
|
# ):
|
||||||
db_port = processes.start_mysql_server()
|
# db_port = processes.start_mysql_server()
|
||||||
url = f"https://localhost:{shared_wg.http_port}"
|
# url = f"https://localhost:{shared_wg.http_port}"
|
||||||
with api_admin_session(url) as session:
|
# with api_admin_session(url) as session:
|
||||||
role = api_create_role(url, session, {"name": f"role-{uuid4()}"})
|
# role = api_create_role(url, session, {"name": f"role-{uuid4()}"})
|
||||||
user = api_create_user(
|
# user = api_create_user(
|
||||||
url,
|
# url,
|
||||||
session,
|
# session,
|
||||||
{
|
# {
|
||||||
"username": f"user-{uuid4()}",
|
# "username": f"user-{uuid4()}",
|
||||||
"credentials": [
|
# "credentials": [
|
||||||
{
|
# {
|
||||||
"kind": "Password",
|
# "kind": "Password",
|
||||||
"hash": "123",
|
# "hash": "123",
|
||||||
},
|
# },
|
||||||
],
|
# ],
|
||||||
},
|
# },
|
||||||
)
|
# )
|
||||||
api_add_role_to_user(url, session, user["id"], role["id"])
|
# api_add_role_to_user(url, session, user["id"], role["id"])
|
||||||
target = api_create_target(
|
# target = api_create_target(
|
||||||
url,
|
# url,
|
||||||
session,
|
# session,
|
||||||
{
|
# {
|
||||||
"name": f"mysql-{uuid4()}",
|
# "name": f"mysql-{uuid4()}",
|
||||||
"options": {
|
# "options": {
|
||||||
"kind": "MySql",
|
# "kind": "MySql",
|
||||||
"host": "localhost",
|
# "host": "localhost",
|
||||||
"port": db_port,
|
# "port": db_port,
|
||||||
"username": "root",
|
# "username": "root",
|
||||||
"password": "123",
|
# "password": "123",
|
||||||
"tls": {
|
# "tls": {
|
||||||
"mode": "Preferred",
|
# "mode": "Preferred",
|
||||||
"verify": False,
|
# "verify": False,
|
||||||
},
|
# },
|
||||||
},
|
# },
|
||||||
},
|
# },
|
||||||
)
|
# )
|
||||||
api_add_role_to_target(url, session, target["id"], role["id"])
|
# api_add_role_to_target(url, session, target["id"], role["id"])
|
||||||
|
|
||||||
time.sleep(15)
|
# time.sleep(15)
|
||||||
wait_mysql_port(db_port)
|
# wait_mysql_port(db_port)
|
||||||
wait_port(shared_wg.mysql_port, recv=False)
|
# wait_port(shared_wg.mysql_port, recv=False)
|
||||||
time.sleep(15)
|
# time.sleep(15)
|
||||||
|
|
||||||
client = processes.start(
|
# client = processes.start(
|
||||||
[
|
# [
|
||||||
"mysql",
|
# "mysql",
|
||||||
"--user",
|
# "--user",
|
||||||
f"{user['username']}#{target['name']}",
|
# f"{user['username']}#{target['name']}",
|
||||||
"-p123",
|
# "-p123",
|
||||||
"--host",
|
# "--host",
|
||||||
"127.0.0.1",
|
# "127.0.0.1",
|
||||||
"--port",
|
# "--port",
|
||||||
str(shared_wg.mysql_port),
|
# str(shared_wg.mysql_port),
|
||||||
*mysql_client_opts,
|
# *mysql_client_opts,
|
||||||
mysql_client_ssl_opt,
|
# mysql_client_ssl_opt,
|
||||||
"db",
|
# "db",
|
||||||
],
|
# ],
|
||||||
stdin=subprocess.PIPE,
|
# stdin=subprocess.PIPE,
|
||||||
stdout=subprocess.PIPE,
|
# stdout=subprocess.PIPE,
|
||||||
)
|
# )
|
||||||
assert b"\ndb\n" in client.communicate(b"show schemas;", timeout=timeout)[0]
|
# assert b"\ndb\n" in client.communicate(b"show schemas;", timeout=timeout)[0]
|
||||||
assert client.returncode == 0
|
# assert client.returncode == 0
|
||||||
|
|
||||||
client = processes.start(
|
# client = processes.start(
|
||||||
[
|
# [
|
||||||
"mysql",
|
# "mysql",
|
||||||
"--user",
|
# "--user",
|
||||||
f"{user['username']}#{target['name']}",
|
# f"{user['username']}#{target['name']}",
|
||||||
"-pwrong",
|
# "-pwrong",
|
||||||
"--host",
|
# "--host",
|
||||||
"127.0.0.1",
|
# "127.0.0.1",
|
||||||
"--port",
|
# "--port",
|
||||||
str(shared_wg.mysql_port),
|
# str(shared_wg.mysql_port),
|
||||||
*mysql_client_opts,
|
# *mysql_client_opts,
|
||||||
mysql_client_ssl_opt,
|
# mysql_client_ssl_opt,
|
||||||
"db",
|
# "db",
|
||||||
],
|
# ],
|
||||||
stdin=subprocess.PIPE,
|
# stdin=subprocess.PIPE,
|
||||||
stdout=subprocess.PIPE,
|
# stdout=subprocess.PIPE,
|
||||||
)
|
# )
|
||||||
client.communicate(b"show schemas;", timeout=timeout)
|
# client.communicate(b"show schemas;", timeout=timeout)
|
||||||
assert client.returncode != 0
|
# assert client.returncode != 0
|
||||||
|
|
Loading…
Reference in a new issue