You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by or...@apache.org on 2020/10/15 23:22:48 UTC
[qpid-broker-j] branch 8.0.x updated: QPID-8478:[Broker-J]Added
null check for ACL predicates
This is an automated email from the ASF dual-hosted git repository.
orudyy pushed a commit to branch 8.0.x
in repository https://gitbox.apache.org/repos/asf/qpid-broker-j.git
The following commit(s) were added to refs/heads/8.0.x by this push:
new 29fbd72 QPID-8478:[Broker-J]Added null check for ACL predicates
29fbd72 is described below
commit 29fbd72e95e4c34984e191176d02fed6d89ea8d3
Author: Dedeepya T <de...@yahoo.co.in>
AuthorDate: Thu Oct 15 13:01:00 2020 +0530
QPID-8478:[Broker-J]Added null check for ACL predicates
This closes #67
---
.../qpid/server/security/access/config/AclAction.java | 6 ++++--
.../server/security/access/config/AclActionTest.java | 14 ++++++++++++++
.../jms_1_1/extensions/acl/MessagingACLTest.java | 16 ++++++++++++++++
3 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/config/AclAction.java b/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/config/AclAction.java
index 89a09bc..48452e2 100644
--- a/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/config/AclAction.java
+++ b/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/config/AclAction.java
@@ -18,6 +18,7 @@
*/
package org.apache.qpid.server.security.access.config;
+import java.util.Collections;
import java.util.Map;
import java.util.Objects;
@@ -28,7 +29,8 @@ public class AclAction
public AclAction(LegacyOperation operation, ObjectType object, AclRulePredicates predicates)
{
- _action = new Action(operation, object, predicates.getObjectProperties());
+ ObjectProperties properties = (predicates ==null) ? ObjectProperties.EMPTY : predicates.getObjectProperties();
+ _action = new Action(operation, object, properties);
_predicates = predicates;
}
@@ -98,7 +100,7 @@ public class AclAction
public Map<ObjectProperties.Property, String> getAttributes()
{
- return _predicates.getParsedProperties();
+ return _predicates == null ? Collections.emptyMap() : _predicates.getParsedProperties();
}
}
diff --git a/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/config/AclActionTest.java b/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/config/AclActionTest.java
index 5e53f0b..45980aa 100644
--- a/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/config/AclActionTest.java
+++ b/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/config/AclActionTest.java
@@ -20,15 +20,18 @@ package org.apache.qpid.server.security.access.config;
import static org.hamcrest.CoreMatchers.allOf;
import static org.hamcrest.Matchers.aMapWithSize;
+import static org.hamcrest.Matchers.anEmptyMap;
import static org.hamcrest.Matchers.hasEntry;
import static org.junit.Assert.assertFalse;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.Map;
+import org.hamcrest.Matchers;
import org.junit.Test;
import org.apache.qpid.server.security.access.firewall.FirewallRule;
@@ -86,6 +89,17 @@ public class AclActionTest extends UnitTestBase
hasEntry(ObjectProperties.Property.NAME, getTestName())));
}
+ @Test
+ public void testGetAttributesWithoutPredicates()
+ {
+ final ObjectType objectType = ObjectType.VIRTUALHOST;
+ final LegacyOperation operation = LegacyOperation.ACCESS;
+ final AclAction aclAction = new AclAction(operation, objectType, (AclRulePredicates) null);
+ final Map<ObjectProperties.Property, String> attributes = aclAction.getAttributes();
+ assertNotNull(attributes);
+ assertThat(attributes, Matchers.anEmptyMap());
+ }
+
private AclRulePredicates createAclRulePredicates()
{
AclRulePredicates predicates = mock(AclRulePredicates.class);
diff --git a/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/extensions/acl/MessagingACLTest.java b/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/extensions/acl/MessagingACLTest.java
index cb591e8..d568372 100644
--- a/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/extensions/acl/MessagingACLTest.java
+++ b/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/extensions/acl/MessagingACLTest.java
@@ -732,6 +732,22 @@ public class MessagingACLTest extends JmsTestBase
}
@Test
+ public void testAllAllowed() throws Exception
+ {
+ configureACL("ACL ALLOW ALL ALL");
+
+ Connection connection = getConnectionBuilder().setUsername(USER1).setPassword(USER1_PASSWORD).build();
+ try
+ {
+ assertConnection(connection);
+ }
+ finally
+ {
+ connection.close();
+ }
+ }
+
+ @Test
public void testFirewallDeny() throws Exception
{
configureACL(String.format("ACL DENY %s ACCESS VIRTUALHOST from_network=\"127.0.0.1\"", USER1));
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org