From 94872cfe1a76ae0dd543cebbd9f9a282862802f1 Mon Sep 17 00:00:00 2001 From: Christopher Giroir Date: Fri, 23 Feb 2024 08:17:16 -0800 Subject: [PATCH 1/4] feat: add gssapi plugin for mariadb --- mysql_mimic/auth.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mysql_mimic/auth.py b/mysql_mimic/auth.py index a6e07fd..0f7c8f7 100644 --- a/mysql_mimic/auth.py +++ b/mysql_mimic/auth.py @@ -219,6 +219,20 @@ async def auth(self, auth_info: Optional[AuthInfo] = None) -> AuthState: yield Success(username) +class GSSAPIAuthPlugin(KerberosAuthPlugin): + """ + This plugin implements the Generic Security Service Application Program + Interface (GSS-API) by way of the Kerberos mechanism as described in + RFC1964(https://www.rfc-editor.org/rfc/rfc1964.html). + + It uses the name of the GSSAPI plugin that the MariaDB client uses, but is + otherwise identical to KerberosAuthPlugin. + """ + + name = "auth_gssapi" + client_plugin_name = "auth_gssapi_client" + + class NoLoginAuthPlugin(AuthPlugin): """ Standard plugin that prevents all clients from direct login. From 422714008330c57b83373a8b5ead1cde412a1be9 Mon Sep 17 00:00:00 2001 From: Christopher Giroir Date: Fri, 23 Feb 2024 08:40:48 -0800 Subject: [PATCH 2/4] fix: running make format --- integration/run.py | 8 +++++--- mysql_mimic/__init__.py | 1 + mysql_mimic/connection.py | 8 +++++--- mysql_mimic/schema.py | 3 +-- mysql_mimic/variables.py | 6 ++---- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/integration/run.py b/integration/run.py index 113df88..48cd315 100644 --- a/integration/run.py +++ b/integration/run.py @@ -72,9 +72,11 @@ async def get_user(self, username): password = user.get("password") return User( name=username, - auth_string=NativePasswordAuthPlugin.create_auth_string(password) - if password - else None, + auth_string=( + NativePasswordAuthPlugin.create_auth_string(password) + if password + else None + ), auth_plugin=NativePasswordAuthPlugin.name, ) elif auth_plugin == "authentication_kerberos": diff --git a/mysql_mimic/__init__.py b/mysql_mimic/__init__.py index 2da223c..9fec965 100644 --- a/mysql_mimic/__init__.py +++ b/mysql_mimic/__init__.py @@ -1,4 +1,5 @@ """Implementation of the mysql server wire protocol""" + from mysql_mimic.auth import ( User, IdentityProvider, diff --git a/mysql_mimic/connection.py b/mysql_mimic/connection.py index 10e7847..5160192 100644 --- a/mysql_mimic/connection.py +++ b/mysql_mimic/connection.py @@ -544,9 +544,11 @@ async def handle_stmt_fetch(self, data: bytes) -> None: await self.stream.write( self.ok_or_eof( - flags=types.ServerStatus.SERVER_STATUS_LAST_ROW_SENT - if done - else types.ServerStatus.SERVER_STATUS_CURSOR_EXISTS + flags=( + types.ServerStatus.SERVER_STATUS_LAST_ROW_SENT + if done + else types.ServerStatus.SERVER_STATUS_CURSOR_EXISTS + ) ) ) diff --git a/mysql_mimic/schema.py b/mysql_mimic/schema.py index bc3e0ab..5d7f587 100644 --- a/mysql_mimic/schema.py +++ b/mysql_mimic/schema.py @@ -275,8 +275,7 @@ class BaseInfoSchema: Base InfoSchema interface used by the `Session` class. """ - async def query(self, expression: exp.Expression) -> AllowedResult: - ... + async def query(self, expression: exp.Expression) -> AllowedResult: ... class InfoSchema(BaseInfoSchema): diff --git a/mysql_mimic/variables.py b/mysql_mimic/variables.py index 2c6fab6..e5a0d8a 100644 --- a/mysql_mimic/variables.py +++ b/mysql_mimic/variables.py @@ -10,8 +10,7 @@ from mysql_mimic.errors import MysqlError, ErrorCode -class Default: - ... +class Default: ... VariableType = Callable[[Any], Any] @@ -102,8 +101,7 @@ def list(self) -> list[tuple[str, str]]: @property @abc.abstractmethod - def schema(self) -> dict[str, VariableSchema]: - ... + def schema(self) -> dict[str, VariableSchema]: ... class GlobalVariables(Variables): From 6a0c236199a596bc3003e70997d7e10bcae33af3 Mon Sep 17 00:00:00 2001 From: Christopher Giroir Date: Fri, 23 Feb 2024 08:46:14 -0800 Subject: [PATCH 3/4] fix: linting --- mysql_mimic/variables.py | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql_mimic/variables.py b/mysql_mimic/variables.py index e5a0d8a..a408462 100644 --- a/mysql_mimic/variables.py +++ b/mysql_mimic/variables.py @@ -10,6 +10,7 @@ from mysql_mimic.errors import MysqlError, ErrorCode +# pylint: disable=multiple-statements class Default: ... From 9a1a6fa764aba3f2255db899bd81dbfd394c5f1a Mon Sep 17 00:00:00 2001 From: Christopher Giroir Date: Fri, 23 Feb 2024 08:59:52 -0800 Subject: [PATCH 4/4] fix: fixed sqlalchemy dep --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 02c053c..16c0a20 100644 --- a/setup.py +++ b/setup.py @@ -30,7 +30,7 @@ "pytest", "pytest-asyncio", "sphinx", - "sqlalchemy", + "sqlalchemy[asyncio]", "twine", "wheel", ],