aboutsummaryrefslogtreecommitdiff
path: root/gn_libs
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-12-09 10:40:42 -0600
committerFrederick Muriuki Muriithi2024-12-09 11:33:41 -0600
commit5f5e33daaf909a5dbc5b0a1730c7510f19576548 (patch)
tree1fa7a0182efb8e08b2e7947b76042477bd5b902c /gn_libs
parent0e26bfd28f27603e7039b51cbdf596c58065c6c6 (diff)
downloadgn-libs-5f5e33daaf909a5dbc5b0a1730c7510f19576548.tar.gz
Parse for SSL_MODE option values from a list of acceptable values.
Diffstat (limited to 'gn_libs')
-rw-r--r--gn_libs/mysqldb.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/gn_libs/mysqldb.py b/gn_libs/mysqldb.py
index d620b11..4997ac7 100644
--- a/gn_libs/mysqldb.py
+++ b/gn_libs/mysqldb.py
@@ -29,6 +29,15 @@ def __non_negative_int__(val: str) -> int:
_val = int(val)
assert (val >= 0), f"Expected a non-negative value. Got {_val}"
return _val
+
+
+def __parse_ssl_mode_options__(val: str) -> str:
+ mode_opts = (
+ "DISABLED", "PREFERRED", "REQUIRED", "VERIFY_CA", "VERIFY_IDENTITY")
+ _val = val.strip().upper()
+ if(_val not in mode_opts):
+ raise InvalidOptionValue(f"Invalid ssl_mode option: {_val}")
+ return _val
def __parse_db_opts__(opts: str) -> dict:
"""Parse database options into their appropriate values.
@@ -48,6 +57,7 @@ def __parse_db_opts__(opts: str) -> dict:
"client_flag": int,
# "ssl": __parse_ssl_options__,
"multi_statements": __parse_boolean__,
+ "ssl_mode": __parse_ssl_mode_options__,
"local_infile": __parse_boolean__,
"autocommit": __parse_boolean__,
"binary_prefix": __parse_boolean__