Use raw JDBC parameter string instead of ssl boolean flag
build / build (push) Failing after 14s

This commit is contained in:
Michael Burgess
2026-08-06 19:45:09 -04:00
parent eb77193fbd
commit 6f74026514
5 changed files with 15 additions and 14 deletions
@@ -29,11 +29,11 @@ public class MariadbStatsStore {
String host = config.getString("host", "localhost"); String host = config.getString("host", "localhost");
int port = config.getInt("port", 3306); int port = config.getInt("port", 3306);
String database = config.getString("database", "mobarena_stats"); String database = config.getString("database", "mobarena_stats");
boolean ssl = config.getBoolean("ssl", false); String ssl = config.getString("ssl", "");
String params = "useSSL=" + ssl; String url = "jdbc:mariadb://" + host + ":" + port + "/" + database;
return "jdbc:mariadb://" + host + ":" + port + "/" + database + "?" + params; return ssl.isEmpty() ? url : url + "?" + ssl;
} }
} }
@@ -27,11 +27,11 @@ public class MysqlStatsStore {
String host = config.getString("host", "localhost"); String host = config.getString("host", "localhost");
int port = config.getInt("port", 3306); int port = config.getInt("port", 3306);
String database = config.getString("database", "mobarena_stats"); String database = config.getString("database", "mobarena_stats");
boolean ssl = config.getBoolean("ssl", false); String ssl = config.getString("ssl", "");
String params = "useSSL=" + ssl; String url = "jdbc:mysql://" + host + ":" + port + "/" + database;
return "jdbc:mysql://" + host + ":" + port + "/" + database + "?" + params; return ssl.isEmpty() ? url : url + "?" + ssl;
} }
} }
+3 -2
View File
@@ -38,14 +38,15 @@ store:
# - database: name of the database (must exist!) # - database: name of the database (must exist!)
# - username: username of a valid database user # - username: username of a valid database user
# - password: password of a valid database user # - password: password of a valid database user
# - ssl: whether to use SSL for database connections # - ssl: extra JDBC connection parameters, appended to the URL as-is
# (e.g. 'verifyServerCertificate=false&sslmode=required')
# #
#host: localhost #host: localhost
#port: 3306 #port: 3306
#database: '' #database: ''
#username: '' #username: ''
#password: '' #password: ''
#ssl: false #ssl: ''
#-------------------------------------------------------------------- #--------------------------------------------------------------------
#-------------------------------------------------------------------- #--------------------------------------------------------------------
@@ -16,7 +16,7 @@ class MariadbStatsStoreTest {
String result = MariadbStatsStore.getUrl(config); String result = MariadbStatsStore.getUrl(config);
String expected = "jdbc:mariadb://localhost:3306/mobarena_stats?useSSL=false"; String expected = "jdbc:mariadb://localhost:3306/mobarena_stats";
assertThat(result, equalTo(expected)); assertThat(result, equalTo(expected));
} }
@@ -26,11 +26,11 @@ class MariadbStatsStoreTest {
config.set("host", "stats.example.com"); config.set("host", "stats.example.com");
config.set("port", 1337); config.set("port", 1337);
config.set("database", "mastats"); config.set("database", "mastats");
config.set("ssl", true); config.set("ssl", "verifyServerCertificate=false&sslmode=required");
String result = MariadbStatsStore.getUrl(config); String result = MariadbStatsStore.getUrl(config);
String expected = "jdbc:mariadb://stats.example.com:1337/mastats?useSSL=true"; String expected = "jdbc:mariadb://stats.example.com:1337/mastats?verifyServerCertificate=false&sslmode=required";
assertThat(result, equalTo(expected)); assertThat(result, equalTo(expected));
} }
@@ -16,7 +16,7 @@ class MysqlStatsStoreTest {
String result = MysqlStatsStore.getUrl(config); String result = MysqlStatsStore.getUrl(config);
String expected = "jdbc:mysql://localhost:3306/mobarena_stats?useSSL=false"; String expected = "jdbc:mysql://localhost:3306/mobarena_stats";
assertThat(result, equalTo(expected)); assertThat(result, equalTo(expected));
} }
@@ -26,11 +26,11 @@ class MysqlStatsStoreTest {
config.set("host", "stats.example.com"); config.set("host", "stats.example.com");
config.set("port", 1337); config.set("port", 1337);
config.set("database", "mastats"); config.set("database", "mastats");
config.set("ssl", true); config.set("ssl", "verifyServerCertificate=false&sslmode=required");
String result = MysqlStatsStore.getUrl(config); String result = MysqlStatsStore.getUrl(config);
String expected = "jdbc:mysql://stats.example.com:1337/mastats?useSSL=true"; String expected = "jdbc:mysql://stats.example.com:1337/mastats?verifyServerCertificate=false&sslmode=required";
assertThat(result, equalTo(expected)); assertThat(result, equalTo(expected));
} }