You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2020/07/29 03:51:42 UTC
[activemq-artemis] branch master updated: ARTEMIS-2846 Cannot
define hawtio.role with whitespace
This is an automated email from the ASF dual-hosted git repository.
clebertsuconic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
The following commit(s) were added to refs/heads/master by this push:
new 3ce9e2e ARTEMIS-2846 Cannot define hawtio.role with whitespace
new 0d9b581 This closes #3219
3ce9e2e is described below
commit 3ce9e2e0dc3f1cab836fb1563f38894cf252d6b8
Author: brusdev <br...@gmail.com>
AuthorDate: Fri Jul 24 17:01:12 2020 +0200
ARTEMIS-2846 Cannot define hawtio.role with whitespace
Move the `hawtio.role` property definition to avoid the word splitting.
---
.../activemq/artemis/cli/commands/Create.java | 1 +
.../activemq/artemis/cli/commands/bin/artemis | 1 +
.../cli/commands/etc/artemis-roles.properties | 2 +-
.../artemis/cli/commands/etc/artemis.profile | 6 +++++-
.../org/apache/activemq/cli/test/ArtemisTest.java | 23 ++++++++++++++++++++++
.../src/test/scripts/validate-instalation.sh | 19 +++++++++++++++++-
.../src/test/scripts/validate-spaces.sh | 2 +-
7 files changed, 50 insertions(+), 4 deletions(-)
diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java
index 2c56c35..5cb6e8b 100644
--- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java
@@ -634,6 +634,7 @@ public class Create extends InputAbstract {
filters.put("${user}", getUser());
filters.put("${password}", getPassword());
filters.put("${role}", role);
+ filters.put("${encoded.role}", role.replaceAll(" ", "\\\\ "));
if (globalMaxSize == null || globalMaxSize.trim().equals("")) {
diff --git a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis
index 72ec821..21b61a8 100755
--- a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis
+++ b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis
@@ -119,6 +119,7 @@ fi
exec "$JAVACMD" \
$JAVA_ARGS \
+ -Dhawtio.role="$HAWTIO_ROLE" \
-Xbootclasspath/a:"$LOG_MANAGER:$WILDFLY_COMMON" \
-Djava.security.auth.login.config="$ARTEMIS_INSTANCE_ETC/login.config" \
$ARTEMIS_CLUSTER_PROPS \
diff --git a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis-roles.properties b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis-roles.properties
index 74f4266..b6f67b1 100644
--- a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis-roles.properties
+++ b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis-roles.properties
@@ -15,4 +15,4 @@
## limitations under the License.
## ---------------------------------------------------------------------------
-${role} = ${user}
\ No newline at end of file
+${encoded.role} = ${user}
\ No newline at end of file
diff --git a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis.profile b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis.profile
index 2ce58f2..8d30b67 100644
--- a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis.profile
+++ b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis.profile
@@ -31,9 +31,13 @@ ARTEMIS_INSTANCE_ETC_URI='${artemis.instance.etc.uri}'
#ARTEMIS_CLUSTER_PROPS="-Dactivemq.remoting.default.port=61617 -Dactivemq.remoting.amqp.port=5673 -Dactivemq.remoting.stomp.port=61614 -Dactivemq.remoting.hornetq.port=5446"
+# Hawtio Properties
+HAWTIO_ROLE='${role}'
+
+
# Java Opts
if [ -z "$JAVA_ARGS" ]; then
- JAVA_ARGS="${java-opts} -XX:+PrintClassHistogram -XX:+UseG1GC -XX:+UseStringDeduplication -Xms512M -Xmx2G -Dhawtio.realm=activemq -Dhawtio.offline=true -Dhawtio.role=${role} -Dhawtio.rolePrincipalClasses=org.apache.activemq.artemis.spi.core.security.jaas.RolePrincipal -Djolokia.policyLocation=${ARTEMIS_INSTANCE_ETC_URI}jolokia-access.xml"
+ JAVA_ARGS="${java-opts} -XX:+PrintClassHistogram -XX:+UseG1GC -XX:+UseStringDeduplication -Xms512M -Xmx2G -Dhawtio.realm=activemq -Dhawtio.offline=true -Dhawtio.rolePrincipalClasses=org.apache.activemq.artemis.spi.core.security.jaas.RolePrincipal -Djolokia.policyLocation=${ARTEMIS_INSTANCE_ETC_URI}jolokia-access.xml"
fi
#
diff --git a/artemis-cli/src/test/java/org/apache/activemq/cli/test/ArtemisTest.java b/artemis-cli/src/test/java/org/apache/activemq/cli/test/ArtemisTest.java
index 1760544..92d4503 100644
--- a/artemis-cli/src/test/java/org/apache/activemq/cli/test/ArtemisTest.java
+++ b/artemis-cli/src/test/java/org/apache/activemq/cli/test/ArtemisTest.java
@@ -780,6 +780,29 @@ public class ArtemisTest extends CliTestBase {
}
@Test
+ public void testRoleWithSpaces() throws Exception {
+ String roleWithSpaces = "amq with spaces";
+ Run.setEmbedded(true);
+ File instanceRole = new File(temporaryFolder.getRoot(), "instance_role");
+ System.setProperty("java.security.auth.login.config", instanceRole.getAbsolutePath() + "/etc/login.config");
+ Artemis.main("create", instanceRole.getAbsolutePath(), "--silent", "--no-autotune", "--role", roleWithSpaces);
+ System.setProperty("artemis.instance", instanceRole.getAbsolutePath());
+
+ File roleFile = new File(instanceRole.getAbsolutePath() + "/etc/artemis-roles.properties");
+
+ ListUser listCmd = new ListUser();
+ TestActionContext context = new TestActionContext();
+ listCmd.execute(context);
+
+ String result = context.getStdout();
+ log.debug("output1:\n" + result);
+
+ assertTrue(result.contains("\"admin\"(" + roleWithSpaces + ")"));
+
+ checkRole("admin", roleFile, roleWithSpaces);
+ }
+
+ @Test
public void testUserCommandResetViaManagementPlaintext() throws Exception {
internalTestUserCommandResetViaManagement(true);
}
diff --git a/artemis-distribution/src/test/scripts/validate-instalation.sh b/artemis-distribution/src/test/scripts/validate-instalation.sh
index 54f002b..64a9994 100755
--- a/artemis-distribution/src/test/scripts/validate-instalation.sh
+++ b/artemis-distribution/src/test/scripts/validate-instalation.sh
@@ -23,6 +23,14 @@ rm -rf target
mkdir target
mkdir target/"$1"
+if [ -z "$2" ]
+ then
+ export ARTEMIS_ROLE=amq
+ else
+ export ARTEMIS_ROLE=$2
+fi
+
+echo with the role $ARTEMIS_ROLE
# Setting the script to fail if anything goes wrong
set -e
@@ -39,7 +47,7 @@ echo artemis instance is $ARTEMIS_HOME
cd "$ARTEMIS_HOME/bin"
-./artemis create --silent --force "$ARTEMIS_INSTANCE"
+./artemis create --silent --force --role "$ARTEMIS_ROLE" "$ARTEMIS_INSTANCE"
cd "$ARTEMIS_INSTANCE/bin"
pwd
@@ -66,6 +74,15 @@ sleep 5
./artemis producer
./artemis consumer --receive-timeout 10000 --break-on-null
+export HTTP_CODE=$(curl -H "Origin:http://localhost" -u admin:admin --write-out '%{http_code}' --silent --output /dev/null http://localhost:8161/console/jolokia/read/org.apache.activemq.artemis:broker=%220.0.0.0%22/Version)
+
+if [[ "$HTTP_CODE" -ne 200 ]]
+ then
+ echo "Artemis Jolokia REST API check failed: " $HTTP_CODE
+ else
+ echo "Artemis Jolokia REST API check passed"
+fi
+
./artemis-service stop
cd $CURRENT_DIR
diff --git a/artemis-distribution/src/test/scripts/validate-spaces.sh b/artemis-distribution/src/test/scripts/validate-spaces.sh
index fd9c21c..fe32d1f 100755
--- a/artemis-distribution/src/test/scripts/validate-spaces.sh
+++ b/artemis-distribution/src/test/scripts/validate-spaces.sh
@@ -18,4 +18,4 @@
# This script will validate the distribution works with folders with spaces on Linux machines
-./validate-instalation.sh with\ spaces\ And\ Weird\ %26\ Characters\ Čeština\ 漢字\ водка\ 昨夜のコ\ ﷹﷸ
\ No newline at end of file
+./validate-instalation.sh with\ spaces\ And\ Weird\ %26\ Characters\ Čeština\ 漢字\ водка\ 昨夜のコ\ ﷹﷸ amq\ with\ spaces
\ No newline at end of file