gtully commented on code in PR #4440:
URL: https://github.com/apache/activemq-artemis/pull/4440#discussion_r1172311729


##########
artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Run.java:
##########
@@ -133,6 +133,8 @@ public void deActivate() {
             broker.components.add(broker.web);
          }
 
+         
server.getServer().getConfiguration().parsePrefixedProperties(broker.web, 
"web", System.getProperties(), 
ActiveMQDefaultConfiguration.getDefaultWebPropertyPrefix());

Review Comment:
   think maybe system-web, or even "system-" + 
ActiveMQDefaultConfiguration.getDefaultWebPropertyPrefix()
   
   this will only show up in the config.getStatus, to identify checksum and to 
capture any errors specific to that set of properties. 



##########
tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/web/WebServerDTOConfigTest.java:
##########
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.artemis.tests.integration.web;
+
+import java.util.Properties;
+
+import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
+import org.apache.activemq.artemis.core.config.Configuration;
+import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl;
+import org.apache.activemq.artemis.dto.AppDTO;
+import org.apache.activemq.artemis.dto.BindingDTO;
+import org.apache.activemq.artemis.dto.WebServerDTO;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class WebServerDTOConfigTest {
+
+   @Test
+   public void testSetWebProperties() throws Throwable {
+      WebServerDTO webServer = new WebServerDTO();
+      Properties properties = new Properties();
+      
properties.put(ActiveMQDefaultConfiguration.getDefaultWebPropertyPrefix() + 
"customizer", "customizerTest");
+      
properties.put(ActiveMQDefaultConfiguration.getDefaultWebPropertyPrefix() + 
"rootRedirectLocation", "locationTest");
+      
properties.put(ActiveMQDefaultConfiguration.getDefaultWebPropertyPrefix() + 
"webContentEnabled", "true");
+      Configuration configuration = new ConfigurationImpl();
+      configuration.parsePrefixedProperties(webServer, "web", properties, 
ActiveMQDefaultConfiguration.getDefaultWebPropertyPrefix());
+
+      Assert.assertEquals("customizerTest", webServer.getCustomizer());
+      Assert.assertEquals("locationTest", webServer.getRootRedirectLocation());
+      Assert.assertEquals(true, webServer.getWebContentEnabled());
+   }
+
+   @Test
+   public void testSetWebBindingProperties() throws Throwable {
+      WebServerDTO webServer = new WebServerDTO();
+      Properties properties = new Properties();
+      
properties.put(ActiveMQDefaultConfiguration.getDefaultWebPropertyPrefix() + 
"bindings.test-binding.uri", "test-uri");
+      
properties.put(ActiveMQDefaultConfiguration.getDefaultWebPropertyPrefix() + 
"bindings.test-binding.clientAuth", "true");
+      
properties.put(ActiveMQDefaultConfiguration.getDefaultWebPropertyPrefix() + 
"bindings.test-binding.passwordCodec", "test-passwordCodec");
+      
properties.put(ActiveMQDefaultConfiguration.getDefaultWebPropertyPrefix() + 
"bindings.test-binding.keyStorePath", "test-keyStorePath");
+      
properties.put(ActiveMQDefaultConfiguration.getDefaultWebPropertyPrefix() + 
"bindings.test-binding.trustStorePath", "test-trustStorePath");
+      
properties.put(ActiveMQDefaultConfiguration.getDefaultWebPropertyPrefix() + 
"bindings.test-binding.includedTLSProtocols", "test-includedTLSProtocols,0");
+      
properties.put(ActiveMQDefaultConfiguration.getDefaultWebPropertyPrefix() + 
"bindings.test-binding.excludedTLSProtocols", "test-excludedTLSProtocols,1");
+      
properties.put(ActiveMQDefaultConfiguration.getDefaultWebPropertyPrefix() + 
"bindings.test-binding.includedCipherSuites", "test-includedCipherSuites,2");
+      
properties.put(ActiveMQDefaultConfiguration.getDefaultWebPropertyPrefix() + 
"bindings.test-binding.excludedCipherSuites", "test-excludedCipherSuites,3");
+      
properties.put(ActiveMQDefaultConfiguration.getDefaultWebPropertyPrefix() + 
"bindings.test-binding.keyStorePassword", "test-keyStorePassword");
+      
properties.put(ActiveMQDefaultConfiguration.getDefaultWebPropertyPrefix() + 
"bindings.test-binding.trustStorePassword", "test-trustStorePassword");
+      Configuration configuration = new ConfigurationImpl();
+      configuration.parsePrefixedProperties(webServer, "web", properties, 
ActiveMQDefaultConfiguration.getDefaultWebPropertyPrefix());
+
+      BindingDTO testBinding = 
webServer.getAllBindings().stream().filter(binding -> 
"test-binding".equals(binding.getName())).findFirst().get();
+      Assert.assertEquals("test-uri", testBinding.getUri());
+      Assert.assertEquals(true, testBinding.getClientAuth());
+      Assert.assertEquals("test-passwordCodec", 
testBinding.getPasswordCodec());
+      Assert.assertEquals("test-keyStorePath", testBinding.getKeyStorePath());
+      Assert.assertEquals("test-trustStorePath", 
testBinding.getTrustStorePath());
+      Assert.assertEquals("test-includedTLSProtocols,0", String.join(",", 
testBinding.getIncludedTLSProtocols()));
+      Assert.assertEquals("test-excludedTLSProtocols,1", String.join(",", 
testBinding.getExcludedTLSProtocols()));
+      Assert.assertEquals("test-includedCipherSuites,2", String.join(",", 
testBinding.getIncludedCipherSuites()));
+      Assert.assertEquals("test-excludedCipherSuites,3", String.join(",", 
testBinding.getExcludedCipherSuites()));
+      Assert.assertEquals("test-keyStorePassword", 
testBinding.getKeyStorePassword());
+      Assert.assertEquals("test-trustStorePassword", 
testBinding.getTrustStorePassword());
+   }
+
+   @Test
+   public void testSetWebBindingAppProperties() throws Throwable {
+      WebServerDTO webServer = new WebServerDTO();
+      Properties properties = new Properties();
+      
properties.put(ActiveMQDefaultConfiguration.getDefaultWebPropertyPrefix() + 
"bindings.test-binding.apps.test-app.url", "test-url");
+      
properties.put(ActiveMQDefaultConfiguration.getDefaultWebPropertyPrefix() + 
"bindings.test-binding.apps.test-app.war", "test-war");
+      Configuration configuration = new ConfigurationImpl();
+      configuration.parsePrefixedProperties(webServer, "web", properties, 
ActiveMQDefaultConfiguration.getDefaultWebPropertyPrefix());
+
+      BindingDTO testBinding = 
webServer.getAllBindings().stream().filter(binding -> 
"test-binding".equals(binding.getName())).findFirst().get();
+      AppDTO testApp = testBinding.getApps().stream().filter(app -> 
"test-app".equals(app.getName())).findFirst().get();
+      Assert.assertEquals("test-url", testApp.getUrl());
+      Assert.assertEquals("test-war", testApp.getWar());
+   }
+}

Review Comment:
   maybe one more test, that verifies feedback when an attribute is not found 
or misspelled. but otherwise this is great :-)



##########
artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Run.java:
##########
@@ -133,6 +133,8 @@ public void deActivate() {
             broker.components.add(broker.web);
          }
 
+         
server.getServer().getConfiguration().parsePrefixedProperties(broker.web, 
"web", System.getProperties(), 
ActiveMQDefaultConfiguration.getDefaultWebPropertyPrefix());

Review Comment:
   that would make it "system-webconfig." am wondering if the dot should be 
removed, but if the prefix is configured by a user, it is good that the actual 
configured value appears in the status. So i would keep the dot.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to