Skip to content

Commit

Permalink
[improve] [ws] add cryptoKeyReaderFactoryClassName into the file webs…
Browse files Browse the repository at this point in the history
…ocket.conf (#20840)

Motivation: Since the PR #16234 add the prop `cryptoKeyReaderFactoryClassName` for the WebSocket Proxy, but did not add this prop to `websocket.conf`.  This can make the script which try to replacement attribute a bit difficult to write

Modifications: add the conf `cryptoKeyReaderFactoryClassName` into the file `websocket.conf`
(cherry picked from commit 5d0aa56)
  • Loading branch information
poorbarcode committed Jul 20, 2023
1 parent 7ae3e8f commit 4845e39
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions conf/websocket.conf
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,6 @@ zooKeeperSessionTimeoutMillis=-1
# ZooKeeper cache expiry time in seconds
# Deprecated: use metadataStoreCacheExpirySeconds
zooKeeperCacheExpirySeconds=-1

# CryptoKeyReader factory classname to support encryption at websocket.
cryptoKeyReaderFactoryClassName=
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import java.io.PrintWriter;

import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNull;

public class WebSocketProxyConfigurationTest {

Expand Down Expand Up @@ -64,13 +65,15 @@ public void testBackwardCompatibility() throws IOException {
printWriter.println("metadataStoreCacheExpirySeconds=500");
printWriter.println("zooKeeperSessionTimeoutMillis=-1");
printWriter.println("zooKeeperCacheExpirySeconds=-1");
printWriter.println("cryptoKeyReaderFactoryClassName=");
}
testConfigFile.deleteOnExit();
stream = new FileInputStream(testConfigFile);
serviceConfig = PulsarConfigurationLoader.create(stream, WebSocketProxyConfiguration.class);
stream.close();
assertEquals(serviceConfig.getMetadataStoreSessionTimeoutMillis(), 60);
assertEquals(serviceConfig.getMetadataStoreCacheExpirySeconds(), 500);
assertNull(serviceConfig.getCryptoKeyReaderFactoryClassName());

testConfigFile = new File("tmp." + System.currentTimeMillis() + ".properties");
if (testConfigFile.exists()) {
Expand All @@ -81,13 +84,15 @@ public void testBackwardCompatibility() throws IOException {
printWriter.println("metadataStoreCacheExpirySeconds=30");
printWriter.println("zooKeeperSessionTimeoutMillis=100");
printWriter.println("zooKeeperCacheExpirySeconds=300");
printWriter.println("cryptoKeyReaderFactoryClassName=A.class");
}
testConfigFile.deleteOnExit();
stream = new FileInputStream(testConfigFile);
serviceConfig = PulsarConfigurationLoader.create(stream, WebSocketProxyConfiguration.class);
stream.close();
assertEquals(serviceConfig.getMetadataStoreSessionTimeoutMillis(), 100);
assertEquals(serviceConfig.getMetadataStoreCacheExpirySeconds(), 300);
assertEquals(serviceConfig.getCryptoKeyReaderFactoryClassName(), "A.class");
}

@Test
Expand Down

0 comments on commit 4845e39

Please sign in to comment.