1 Commits
Author SHA1 Message Date
Michael Burgess 6f74026514 Use raw JDBC parameter string instead of ssl boolean flag
build / build (push) Failing after 14s
2026-08-06 19:45:09 -04:00
5 changed files with 15 additions and 14 deletions
@@ -29,11 +29,11 @@ public class MariadbStatsStore {
String host = config.getString("host", "localhost");
int port = config.getInt("port", 3306);
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");
int port = config.getInt("port", 3306);
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!)
# - username: username 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
#port: 3306
#database: ''
#username: ''
#password: ''
#ssl: false
#ssl: ''
#--------------------------------------------------------------------
#--------------------------------------------------------------------
@@ -16,7 +16,7 @@ class MariadbStatsStoreTest {
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));
}
@@ -26,11 +26,11 @@ class MariadbStatsStoreTest {
config.set("host", "stats.example.com");
config.set("port", 1337);
config.set("database", "mastats");
config.set("ssl", true);
config.set("ssl", "verifyServerCertificate=false&sslmode=required");
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));
}
@@ -16,7 +16,7 @@ class MysqlStatsStoreTest {
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));
}
@@ -26,11 +26,11 @@ class MysqlStatsStoreTest {
config.set("host", "stats.example.com");
config.set("port", 1337);
config.set("database", "mastats");
config.set("ssl", true);
config.set("ssl", "verifyServerCertificate=false&sslmode=required");
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));
}