Skip to content

Commit

Permalink
#26481 include in 22.03.12
Browse files Browse the repository at this point in the history
  • Loading branch information
erickgonzalez committed Dec 4, 2023
1 parent 835687a commit c140eb4
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
14 changes: 13 additions & 1 deletion dotCMS/src/main/java/com/dotcms/dotpubsub/PgNgDataSourceUrl.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
class PgNgDataSourceUrl {

static final String SSL_MODE = System.getenv("DOT_PUBSUB_SSL_MODE") != null ? System.getenv("DOT_PUBSUB_SSL_MODE") : "prefer";

private final String finalUrl;

/**
Expand Down Expand Up @@ -66,7 +68,17 @@ private String createUrl(final String username, final String password, final Str
sw.append("/");
sw.append(data[data.length - 1]);

return sw.toString();
if(url.contains("ssl.mode=")){
return sw.toString();
}
if(url.contains("?")){
sw.append( "&");
}else{
sw.append( "?");
}

sw.append("ssl.mode=" + SSL_MODE);
return sw.toString();

}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.dotcms.dotpubsub;

import java.net.MalformedURLException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import org.junit.BeforeClass;
Expand All @@ -11,9 +12,28 @@ public class PgNgDataSourceUrlTest {
@BeforeClass
public static void setUpBeforeClass() throws Exception {}


final String PgNgUrl = "jdbc:pgsql://dotcmsUserName:dotcmsPassword@dbServer.com/dotcms?ssl.mode=" + PgNgDataSourceUrl.SSL_MODE;

@Test
public void test_ssl_mode_is_added() throws MalformedURLException {

String url = "jdbc:postgresql://dbServer.com/dotcms";
String username = "username";
String password = "password";


PgNgDataSourceUrl testDataSource = new PgNgDataSourceUrl(username, password, url);

final String PgNgUrl = "jdbc:pgsql://dotcmsUserName:dotcmsPassword@dbServer.com/dotcms";
assert testDataSource.getDbUrl().contains("?ssl.mode=" + PgNgDataSourceUrl.SSL_MODE);

url = "jdbc:postgresql://dbServer.com/dotcms?test=here";


testDataSource = new PgNgDataSourceUrl(username, password, url);

assert testDataSource.getDbUrl().contains("&ssl.mode=" + PgNgDataSourceUrl.SSL_MODE);

}



Expand Down
3 changes: 2 additions & 1 deletion hotfix_tracking.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,5 @@ This maintenance release includes the following code fixes:
180. https://github.com/dotCMS/core/issues/24167 : Relationship fields couldn't update with workflow apis #24167
181. https://github.com/dotCMS/core/issues/24490 : Content with an invalid detail page fails to render/instanciate #24490
182. https://github.com/dotCMS/core/issues/24885 : Define startup and liveness probes #24885
183. https://github.com/dotCMS/core/issues/25613 : MonitorResource throws exception if DOT_SYSTEM_STATUS_API_IP_ACL is not set #25613
183. https://github.com/dotCMS/core/issues/25613 : MonitorResource throws exception if DOT_SYSTEM_STATUS_API_IP_ACL is not set #25613
184. https://github.com/dotCMS/core/issues/26481 : Pubsub Connection should prefer SSL #26481

0 comments on commit c140eb4

Please sign in to comment.