You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@activemq.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2023/04/20 09:21:00 UTC

[jira] [Work logged] (ARTEMIS-4244) Set web config using system properties

     [ https://issues.apache.org/jira/browse/ARTEMIS-4244?focusedWorklogId=858154&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-858154 ]

ASF GitHub Bot logged work on ARTEMIS-4244:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 20/Apr/23 09:20
            Start Date: 20/Apr/23 09:20
    Worklog Time Spent: 10m 
      Work Description: 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.





Issue Time Tracking
-------------------

            Worklog Id:     (was: 858154)
    Remaining Estimate: 0h
            Time Spent: 10m

> Set web config using system properties
> --------------------------------------
>
>                 Key: ARTEMIS-4244
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-4244
>             Project: ActiveMQ Artemis
>          Issue Type: New Feature
>            Reporter: Domenico Francesco Bruscino
>            Assignee: Domenico Francesco Bruscino
>            Priority: Major
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> Set web config using system properties as users can set broker config, i.e. starting the broker JVM with the option `-Dwebconfig.webContentEnabled=true` enables the web content.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)