From 4845e39f6b550510630d7dde22ad83866d53517e Mon Sep 17 00:00:00 2001 From: fengyubiao Date: Thu, 20 Jul 2023 17:48:33 +0800 Subject: [PATCH] [improve] [ws] add cryptoKeyReaderFactoryClassName into the file websocket.conf (#20840) Motivation: Since the PR https://github.com/apache/pulsar/pull/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 5d0aa5615df68ee6898d0c2e58006166b8a0a8bd) --- conf/websocket.conf | 3 +++ .../pulsar/websocket/WebSocketProxyConfigurationTest.java | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/conf/websocket.conf b/conf/websocket.conf index 79dee8edeebb2..1c10d2d960278 100644 --- a/conf/websocket.conf +++ b/conf/websocket.conf @@ -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= diff --git a/pulsar-websocket/src/test/java/org/apache/pulsar/websocket/WebSocketProxyConfigurationTest.java b/pulsar-websocket/src/test/java/org/apache/pulsar/websocket/WebSocketProxyConfigurationTest.java index d271dd4324786..6ecbe53ede23f 100644 --- a/pulsar-websocket/src/test/java/org/apache/pulsar/websocket/WebSocketProxyConfigurationTest.java +++ b/pulsar-websocket/src/test/java/org/apache/pulsar/websocket/WebSocketProxyConfigurationTest.java @@ -34,6 +34,7 @@ import java.io.PrintWriter; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNull; public class WebSocketProxyConfigurationTest { @@ -64,6 +65,7 @@ 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); @@ -71,6 +73,7 @@ public void testBackwardCompatibility() throws IOException { stream.close(); assertEquals(serviceConfig.getMetadataStoreSessionTimeoutMillis(), 60); assertEquals(serviceConfig.getMetadataStoreCacheExpirySeconds(), 500); + assertNull(serviceConfig.getCryptoKeyReaderFactoryClassName()); testConfigFile = new File("tmp." + System.currentTimeMillis() + ".properties"); if (testConfigFile.exists()) { @@ -81,6 +84,7 @@ 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); @@ -88,6 +92,7 @@ public void testBackwardCompatibility() throws IOException { stream.close(); assertEquals(serviceConfig.getMetadataStoreSessionTimeoutMillis(), 100); assertEquals(serviceConfig.getMetadataStoreCacheExpirySeconds(), 300); + assertEquals(serviceConfig.getCryptoKeyReaderFactoryClassName(), "A.class"); } @Test