summaryrefslogtreecommitdiff
path: root/qpid/java/broker-plugins/access-control/src/test
diff options
context:
space:
mode:
authorRobert Gemmell <robbie@apache.org>2012-10-12 11:44:13 +0000
committerRobert Gemmell <robbie@apache.org>2012-10-12 11:44:13 +0000
commit65cba5397294ddd5349bdb9837c4a10d91f2ca0b (patch)
tree5ac98649e42a8d48ca46e94cae1120dde99044dc /qpid/java/broker-plugins/access-control/src/test
parenta0b7800e8d8554f76dcd8715768b08b6e8b9c507 (diff)
downloadqpid-python-65cba5397294ddd5349bdb9837c4a10d91f2ca0b.tar.gz
QPID-4335, QPID-4353: Refactored broker plugins to use simplified ServiceLoader-based model rather than embedding Felix to use OSGi.
Removed the ability to reload security configuration because this feature is not very useful in its current form and was making our code hard to refactor. Modified all tests to use jars rather than classes. This makes them closer to real-world deployments, e.g. the META-INF/services file is read from within the jar. Also moved various system tests from their respective modules into "systests". This removes the need for most modules to depend on systests, thus simplifying our dependency graph. Applied patch from myself, Keith Wall and Phil Harvey <phil@philharveyonline.com> git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1397519 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/broker-plugins/access-control/src/test')
-rw-r--r--qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControlTest.java (renamed from qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/AccessControlTest.java)48
1 files changed, 6 insertions, 42 deletions
diff --git a/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/AccessControlTest.java b/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControlTest.java
index a65c442bcf..a8406308c0 100644
--- a/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/AccessControlTest.java
+++ b/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControlTest.java
@@ -30,7 +30,6 @@ import javax.security.auth.Subject;
import junit.framework.TestCase;
import org.apache.commons.configuration.ConfigurationException;
-import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin;
import org.apache.qpid.server.logging.UnitTestMessageLogger;
import org.apache.qpid.server.logging.actors.CurrentActor;
import org.apache.qpid.server.logging.actors.TestLogActor;
@@ -45,20 +44,16 @@ import org.apache.qpid.server.security.access.config.RuleSet;
import org.apache.qpid.server.security.auth.TestPrincipalUtils;
/**
- * Unit test for ACL V2 plugin.
- *
- * This unit test tests the AccessControl class and it collaboration with {@link RuleSet},
- * {@link SecurityManager} and {@link CurrentActor}. The ruleset is configured programmatically,
- * rather than from an external file.
+ * In these tests, the ruleset is configured programmatically rather than from an external file.
*
* @see RuleSetTest
*/
-public class AccessControlTest extends TestCase
+public class DefaultAccessControlTest extends TestCase
{
private static final String ALLOWED_GROUP = "allowed_group";
private static final String DENIED_GROUP = "denied_group";
- private AccessControl _plugin = null; // Class under test
+ private DefaultAccessControl _plugin = null; // Class under test
private final UnitTestMessageLogger messageLogger = new UnitTestMessageLogger();
private void setUpGroupAccessControl() throws ConfigurationException
@@ -68,7 +63,7 @@ public class AccessControlTest extends TestCase
private void configureAccessControl(final RuleSet rs) throws ConfigurationException
{
- _plugin = (AccessControl) AccessControl.FACTORY.newInstance(createConfiguration(rs));
+ _plugin = new DefaultAccessControl(rs);
SecurityManager.setThreadSubject(null);
CurrentActor.set(new TestLogActor(messageLogger));
}
@@ -207,12 +202,11 @@ public class AccessControlTest extends TestCase
SecurityManager.setThreadSubject(subject);
RuleSet mockRuleSet = mock(RuleSet.class);
- ConfigurationPlugin accessControlConfiguration = createConfiguration(mockRuleSet);
InetAddress inetAddress = InetAddress.getLocalHost();
InetSocketAddress inetSocketAddress = new InetSocketAddress(inetAddress, 1);
- AccessControl accessControl = AccessControl.FACTORY.newInstance(accessControlConfiguration);
+ DefaultAccessControl accessControl = new DefaultAccessControl(mockRuleSet);
accessControl.access(ObjectType.VIRTUALHOST, inetSocketAddress);
@@ -235,9 +229,7 @@ public class AccessControlTest extends TestCase
ObjectProperties.EMPTY,
inetAddress)).thenThrow(new RuntimeException());
- ConfigurationPlugin accessControlConfiguration = createConfiguration(mockRuleSet);
-
- AccessControl accessControl = AccessControl.FACTORY.newInstance(accessControlConfiguration);
+ DefaultAccessControl accessControl = new DefaultAccessControl(mockRuleSet);
Result result = accessControl.access(ObjectType.VIRTUALHOST, inetSocketAddress);
assertEquals(Result.DENIED, result);
@@ -373,32 +365,4 @@ public class AccessControlTest extends TestCase
Result result = _plugin.authorise(Operation.ACCESS, ObjectType.VIRTUALHOST, ObjectProperties.EMPTY);
assertEquals(expectedResult, result);
}
-
- /**
- * Creates a configuration plugin for the {@link AccessControl} plugin.
- */
- private ConfigurationPlugin createConfiguration(final RuleSet rs)
- {
- final ConfigurationPlugin cp = new ConfigurationPlugin()
- {
- @SuppressWarnings("unchecked")
- public AccessControlConfiguration getConfiguration(final String plugin)
- {
- return new AccessControlConfiguration()
- {
- public RuleSet getRuleSet()
- {
- return rs;
- }
- };
- }
-
- public String[] getElementsProcessed()
- {
- throw new UnsupportedOperationException();
- }
- };
-
- return cp;
- }
}