|
5 | 5 | */
|
6 | 6 | package org.elasticsearch.xpack.sql.jdbc;
|
7 | 7 |
|
| 8 | +import org.elasticsearch.SpecialPermission; |
8 | 9 | import org.elasticsearch.test.ESTestCase;
|
9 | 10 | import org.elasticsearch.xpack.sql.client.SslConfig;
|
| 11 | +import org.elasticsearch.xpack.sql.client.SuppressForbidden; |
10 | 12 |
|
11 | 13 | import java.net.URI;
|
12 | 14 | import java.net.URISyntaxException;
|
| 15 | +import java.security.AccessController; |
| 16 | +import java.security.PrivilegedAction; |
13 | 17 | import java.sql.DriverManager;
|
14 | 18 | import java.sql.SQLException;
|
15 | 19 | import java.util.HashMap;
|
@@ -252,14 +256,20 @@ public void testSSLPropertiesOverride() throws Exception {
|
252 | 256 | assertSslConfig(props, JdbcConfiguration.create("jdbc:es://test?" + sslUrlProps.toString(), props, 0).sslConfig());
|
253 | 257 | }
|
254 | 258 |
|
255 |
| - @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/41557") |
| 259 | + @SuppressForbidden(reason = "JDBC drivers allows logging to Sys.out") |
256 | 260 | public void testDriverConfigurationWithSSLInURL() {
|
257 | 261 | Map<String, String> urlPropMap = sslProperties();
|
258 |
| - |
259 |
| - Properties allProps = new Properties(); |
260 |
| - allProps.putAll(urlPropMap); |
261 | 262 | String sslUrlProps = urlPropMap.entrySet().stream().map(e -> e.getKey() + "=" + e.getValue()).collect(Collectors.joining("&"));
|
262 | 263 |
|
| 264 | + SecurityManager sm = System.getSecurityManager(); |
| 265 | + if (sm != null) { |
| 266 | + sm.checkPermission(new SpecialPermission()); |
| 267 | + } |
| 268 | + AccessController.doPrivileged((PrivilegedAction<Void>) () -> { |
| 269 | + DriverManager.setLogWriter(new java.io.PrintWriter(System.out)); |
| 270 | + return null; |
| 271 | + }); |
| 272 | + |
263 | 273 | try {
|
264 | 274 | DriverManager.getDriver("jdbc:es://test?" + sslUrlProps);
|
265 | 275 | } catch (SQLException sqle) {
|
|
0 commit comments