Skip to content

Commit

Permalink
Merge pull request #131 from swisspost/develop
Browse files Browse the repository at this point in the history
merge to master to trigger release
  • Loading branch information
ZhengXinCN authored Aug 3, 2023
2 parents 2b859a9 + bc309c8 commit 683880e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.swisspush</groupId>
<artifactId>rest-storage</artifactId>
<version>3.0.14-SNAPSHOT</version>
<version>3.0.15-SNAPSHOT</version>
<name>rest-storage</name>
<description>
Persistence for REST resources in the filesystem or a redis database
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ private Future<RedisAPI> setupRedisClient(){

private Future<RedisAPI> connectToRedis() {
Promise<RedisAPI> promise = Promise.promise();
String protocol = configuration.isRedisEnableTls() ? "rediss://" : "redis://";
Redis.createClient(vertx, new RedisOptions()
.setConnectionString("redis://" + configuration.getRedisHost() + ":" + configuration.getRedisPort())
.setConnectionString(protocol + configuration.getRedisHost() + ":" + configuration.getRedisPort())
.setPassword((configuration.getRedisAuth() == null ? "" : configuration.getRedisAuth()))
.setMaxPoolSize(configuration.getMaxRedisConnectionPoolSize())
.setMaxPoolWaiting(configuration.getMaxQueueWaiting())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public enum StorageType {
private Map<String, String> editorConfig = null;
private String redisHost = "localhost";
private int redisPort = 6379;
private boolean redisEnableTls;
private String redisAuth = null;
private String expirablePrefix = "rest-storage:expirable";
private String resourcesPrefix = "rest-storage:resources";
Expand Down Expand Up @@ -112,6 +113,12 @@ public ModuleConfiguration redisPort(int redisPort) {
this.redisPort = redisPort;
return this;
}

public ModuleConfiguration redisEnableTls(boolean redisEnableTls) {
this.redisEnableTls = redisEnableTls;
return this;
}

public ModuleConfiguration redisAuth(String redisAuth) {
this.redisAuth = redisAuth;
return this;
Expand Down Expand Up @@ -235,6 +242,10 @@ public int getRedisPort() {
return redisPort;
}

public boolean isRedisEnableTls() {
return redisEnableTls;
}

public String getRedisAuth() {
return redisAuth;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public void testDefaultConfiguration(TestContext testContext) {
testContext.assertNull(config.getEditorConfig());
testContext.assertEquals(config.getRedisHost(), "localhost");
testContext.assertEquals(config.getRedisPort(), 6379);
testContext.assertFalse(config.isRedisEnableTls());
testContext.assertEquals(config.getExpirablePrefix(), "rest-storage:expirable");
testContext.assertEquals(config.getResourcesPrefix(), "rest-storage:resources");
testContext.assertEquals(config.getCollectionsPrefix(), "rest-storage:collections");
Expand All @@ -58,6 +59,7 @@ public void testOverrideConfiguration(TestContext testContext) {
ModuleConfiguration config = new ModuleConfiguration()
.redisHost("anotherhost")
.redisPort(1234)
.redisEnableTls(true)
.editorConfig(new HashMap<>() {{
put("myKey", "myValue");
}})
Expand Down Expand Up @@ -92,6 +94,7 @@ public void testOverrideConfiguration(TestContext testContext) {
// overridden values
testContext.assertEquals(config.getRedisHost(), "anotherhost");
testContext.assertEquals(config.getRedisPort(), 1234);
testContext.assertTrue(config.isRedisEnableTls());
testContext.assertFalse(config.isHttpRequestHandlerEnabled());
testContext.assertNotNull(config.getEditorConfig());
testContext.assertTrue(config.getEditorConfig().containsKey("myKey"));
Expand All @@ -114,8 +117,9 @@ public void testGetDefaultAsJsonObject(TestContext testContext){
testContext.assertEquals(json.getString("root"), ".");
testContext.assertEquals(json.getString("storageType"), StorageType.filesystem.name());
testContext.assertEquals(json.getInteger("port"), 8989);
testContext.assertTrue(json.getBoolean("httpRequestHandlerEnabled"));
testContext.assertFalse(json.getBoolean("httpRequestHandlerAuthenticationEnabled"));
testContext.assertTrue(json.getBoolean("httpRequestHandlerEnabled"));
testContext.assertFalse(json.getBoolean("redisEnableTls"));
testContext.assertNull(json.getJsonObject("httpRequestHandlerUsername"));
testContext.assertNull(json.getJsonObject("httpRequestHandlerPassword"));
testContext.assertEquals(json.getString("prefix"), "");
Expand Down Expand Up @@ -143,6 +147,7 @@ public void testGetOverriddenAsJsonObject(TestContext testContext){
ModuleConfiguration config = new ModuleConfiguration()
.redisHost("anotherhost")
.redisPort(1234)
.redisEnableTls(true)
.editorConfig(new HashMap<>() {{
put("myKey", "myValue");
}})
Expand Down Expand Up @@ -176,6 +181,7 @@ public void testGetOverriddenAsJsonObject(TestContext testContext){
// overridden values
testContext.assertEquals(json.getString("redisHost"), "anotherhost");
testContext.assertEquals(json.getInteger("redisPort"), 1234);
testContext.assertTrue(json.getBoolean("redisEnableTls"));
testContext.assertTrue(json.getBoolean("confirmCollectionDelete"));
testContext.assertTrue(json.getBoolean("rejectStorageWriteOnLowMemory"));
testContext.assertEquals(config.getFreeMemoryCheckIntervalMs(), 5000L);
Expand Down Expand Up @@ -203,6 +209,7 @@ public void testGetDefaultFromJsonObject(TestContext testContext){
testContext.assertNull(config.getEditorConfig());
testContext.assertEquals(config.getRedisHost(), "localhost");
testContext.assertEquals(config.getRedisPort(), 6379);
testContext.assertFalse(json.getBoolean("redisEnableTls"));
testContext.assertEquals(config.getMaxRedisWaitingHandlers(), 2048);
testContext.assertEquals(config.getExpirablePrefix(), "rest-storage:expirable");
testContext.assertEquals(config.getResourcesPrefix(), "rest-storage:resources");
Expand All @@ -227,6 +234,7 @@ public void testGetOverriddenFromJsonObject(TestContext testContext){
json.put("root", "newroot");
json.put("storageType", "redis");
json.put("port", 1234);
json.put("redisEnableTls", true);
json.put("httpRequestHandlerEnabled", false);
json.put("httpRequestHandlerAuthenticationEnabled", true);
json.put("httpRequestHandlerUsername", "foo");
Expand All @@ -252,6 +260,7 @@ public void testGetOverriddenFromJsonObject(TestContext testContext){
testContext.assertEquals(config.getRoot(), "newroot");
testContext.assertEquals(config.getStorageType(), StorageType.redis);
testContext.assertEquals(config.getPort(), 1234);
testContext.assertTrue(config.isRedisEnableTls());
testContext.assertFalse(config.isHttpRequestHandlerEnabled());
testContext.assertTrue(config.isHttpRequestHandlerAuthenticationEnabled());
testContext.assertEquals(config.getHttpRequestHandlerUsername(), "foo");
Expand Down

0 comments on commit 683880e

Please sign in to comment.