[jboss-cvs] JBossAS SVN: r114759 - branches/JBPAPP_5/testsuite/src/main/org/jboss/test/jmx/invoker/authorization.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Mar 13 05:33:58 EDT 2014


Author: jmartisk
Date: 2014-03-13 05:33:58 -0400 (Thu, 13 Mar 2014)
New Revision: 114759

Added:
   branches/JBPAPP_5/testsuite/src/main/org/jboss/test/jmx/invoker/authorization/RolesAuthorizationUnitTestCase.java
Removed:
   branches/JBPAPP_5/testsuite/src/main/org/jboss/test/jmx/invoker/authorization/RolesAuthorizationTestCase.java
Log:
Rename RolesAuthorizationTestCase to RolesAuthorizationUnitTestCase so it is run as part of tests-standard-unit

Deleted: branches/JBPAPP_5/testsuite/src/main/org/jboss/test/jmx/invoker/authorization/RolesAuthorizationTestCase.java
===================================================================
--- branches/JBPAPP_5/testsuite/src/main/org/jboss/test/jmx/invoker/authorization/RolesAuthorizationTestCase.java	2014-03-13 01:49:46 UTC (rev 114758)
+++ branches/JBPAPP_5/testsuite/src/main/org/jboss/test/jmx/invoker/authorization/RolesAuthorizationTestCase.java	2014-03-13 09:33:58 UTC (rev 114759)
@@ -1,136 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2013, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.test.jmx.invoker.authorization;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.security.Principal;
-import java.security.acl.Group;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.security.auth.Subject;
-
-import org.jboss.jmx.connector.invoker.authorization.roles.RolesAuthorization;
-import org.jboss.security.SimpleGroup;
-import org.jboss.security.SimplePrincipal;
-import org.jboss.test.JBossTestCase;
-
-/**
- * @author baranowb, jmartisk
- */
-public class RolesAuthorizationTestCase extends JBossTestCase {
-    private RolesAuthorization authorization;
-
-    /**
-     * @param name
-     */
-    public RolesAuthorizationTestCase(String name) {
-        super(name);
-    }
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        this.authorization = new RolesAuthorization() {
-            @Override
-            protected InputStream getConfigurationStream() throws Exception {
-                return new FileInputStream(new File(".." + File.separator + "src" + File.separator + "main" + File.separator
-                        + "org" + File.separator + "jboss" + File.separator + "test" + File.separator + "jmx" + File.separator
-                        + "invoker" + File.separator + "authorization" + File.separator + super.CONFIGURATION_FILE));
-            }
-
-        };
-    }
-
-    @Override
-    protected void tearDown() throws Exception {
-        this.authorization = null;
-        super.tearDown();
-    }
-
-    public void tryInvocation(String objectName, String opName, String callerPrincipal, Set<String> callerRoles, boolean shouldSucceed) {
-        final Principal caller = new SimplePrincipal(callerPrincipal);
-        final Group group = new SimpleGroup("Roles");
-        for(String role : callerRoles) {
-            group.addMember(new SimplePrincipal(role));
-        }
-        final Set<Principal> callers = new HashSet<Principal>();
-        callers.add(caller);
-        callers.add(group);
-        final Subject subject = new Subject(false, callers, new HashSet(), new HashSet());
-        try {
-            authorization.authorize(caller, subject, objectName, opName);
-            if(!shouldSucceed) {
-                fail("Expected SecurityException!");
-            }
-        } catch(SecurityException ex) {
-            if(shouldSucceed)
-                throw ex;
-        }
-    }
-
-    public void testAuthorization() {
-        tryInvocation("jboss:service=JNDIView", "list", "test", Collections.singleton("Tester"), true);
-    }
-    public void testWildcardMatch() {
-        tryInvocation("jboss:service=NO_BOOM", "list", "test", Collections.singleton("Tester"), true);
-    }
-
-    public void testWildcardMatch2() {
-        tryInvocation("jboss:service=NO_BOOM", "getSomeThingThatDoesNotExist", "test", Collections.singleton("Tester"), true);
-    }
-
-    // two conflicting operation-rules in a single objectname-rule
-    public void testFirstRulePrecedenceInSingleObjectName() {
-        tryInvocation("jboss:service=NO_BOOM", "getSomeThingThatDoesNotExist", "test", Collections.singleton("JBossAdmin"), false);
-    }
-
-    // two conflicting operation-rules, located in two objectname-rules
-    public void testFirstRulePrecedenceInMultipleObjectNames() {
-        tryInvocation("jboss:service=JNDIView", "queryNames", "test", Collections.singleton("JBossAdmin"), true);
-    }
-
-    // two conflicting operation-rules, located in two objectname-rules, the second one would allow invocation, but the first denies it
-    public void testFirstRulePrecedenceInMultipleObjectNames2() {
-        tryInvocation("jboss:service=JNDIView", "queryNames", "test", Collections.singleton("Superman"), false);
-    }
-
-    public void testMethodMatch() {
-        tryInvocation("jboss:type=NO_BOOM", "list", "test", Collections.singleton("JBossAdmin"), false);
-    }
-
-    public void testNoRuleForDomain() {
-        tryInvocation("wicked_domain:service=BOOM", "list", "test", Collections.singleton("JBossAdmin"), false);
-    }
-
-    public void testNoRuleForOperation() {
-        tryInvocation("otherdomain:type=NO_BOOM", "list", "test", Collections.singleton("JBossAdmin"), false);
-    }
-
-    public void testUnauthorized() {
-        tryInvocation("jboss:service=JNDIView", "list", "test", Collections.singleton("IWillBoom"), false);
-    }
-}

Added: branches/JBPAPP_5/testsuite/src/main/org/jboss/test/jmx/invoker/authorization/RolesAuthorizationUnitTestCase.java
===================================================================
--- branches/JBPAPP_5/testsuite/src/main/org/jboss/test/jmx/invoker/authorization/RolesAuthorizationUnitTestCase.java	                        (rev 0)
+++ branches/JBPAPP_5/testsuite/src/main/org/jboss/test/jmx/invoker/authorization/RolesAuthorizationUnitTestCase.java	2014-03-13 09:33:58 UTC (rev 114759)
@@ -0,0 +1,136 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.jmx.invoker.authorization;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.security.Principal;
+import java.security.acl.Group;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.security.auth.Subject;
+
+import org.jboss.jmx.connector.invoker.authorization.roles.RolesAuthorization;
+import org.jboss.security.SimpleGroup;
+import org.jboss.security.SimplePrincipal;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * @author baranowb, jmartisk
+ */
+public class RolesAuthorizationUnitTestCase extends JBossTestCase {
+    private RolesAuthorization authorization;
+
+    /**
+     * @param name
+     */
+    public RolesAuthorizationUnitTestCase(String name) {
+        super(name);
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        this.authorization = new RolesAuthorization() {
+            @Override
+            protected InputStream getConfigurationStream() throws Exception {
+                return new FileInputStream(new File(".." + File.separator + "src" + File.separator + "main" + File.separator
+                        + "org" + File.separator + "jboss" + File.separator + "test" + File.separator + "jmx" + File.separator
+                        + "invoker" + File.separator + "authorization" + File.separator + super.CONFIGURATION_FILE));
+            }
+
+        };
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        this.authorization = null;
+        super.tearDown();
+    }
+
+    public void tryInvocation(String objectName, String opName, String callerPrincipal, Set<String> callerRoles, boolean shouldSucceed) {
+        final Principal caller = new SimplePrincipal(callerPrincipal);
+        final Group group = new SimpleGroup("Roles");
+        for(String role : callerRoles) {
+            group.addMember(new SimplePrincipal(role));
+        }
+        final Set<Principal> callers = new HashSet<Principal>();
+        callers.add(caller);
+        callers.add(group);
+        final Subject subject = new Subject(false, callers, new HashSet(), new HashSet());
+        try {
+            authorization.authorize(caller, subject, objectName, opName);
+            if(!shouldSucceed) {
+                fail("Expected SecurityException!");
+            }
+        } catch(SecurityException ex) {
+            if(shouldSucceed)
+                throw ex;
+        }
+    }
+
+    public void testAuthorization() {
+        tryInvocation("jboss:service=JNDIView", "list", "test", Collections.singleton("Tester"), true);
+    }
+    public void testWildcardMatch() {
+        tryInvocation("jboss:service=NO_BOOM", "list", "test", Collections.singleton("Tester"), true);
+    }
+
+    public void testWildcardMatch2() {
+        tryInvocation("jboss:service=NO_BOOM", "getSomeThingThatDoesNotExist", "test", Collections.singleton("Tester"), true);
+    }
+
+    // two conflicting operation-rules in a single objectname-rule
+    public void testFirstRulePrecedenceInSingleObjectName() {
+        tryInvocation("jboss:service=NO_BOOM", "getSomeThingThatDoesNotExist", "test", Collections.singleton("JBossAdmin"), false);
+    }
+
+    // two conflicting operation-rules, located in two objectname-rules
+    public void testFirstRulePrecedenceInMultipleObjectNames() {
+        tryInvocation("jboss:service=JNDIView", "queryNames", "test", Collections.singleton("JBossAdmin"), true);
+    }
+
+    // two conflicting operation-rules, located in two objectname-rules, the second one would allow invocation, but the first denies it
+    public void testFirstRulePrecedenceInMultipleObjectNames2() {
+        tryInvocation("jboss:service=JNDIView", "queryNames", "test", Collections.singleton("Superman"), false);
+    }
+
+    public void testMethodMatch() {
+        tryInvocation("jboss:type=NO_BOOM", "list", "test", Collections.singleton("JBossAdmin"), false);
+    }
+
+    public void testNoRuleForDomain() {
+        tryInvocation("wicked_domain:service=BOOM", "list", "test", Collections.singleton("JBossAdmin"), false);
+    }
+
+    public void testNoRuleForOperation() {
+        tryInvocation("otherdomain:type=NO_BOOM", "list", "test", Collections.singleton("JBossAdmin"), false);
+    }
+
+    public void testUnauthorized() {
+        tryInvocation("jboss:service=JNDIView", "list", "test", Collections.singleton("IWillBoom"), false);
+    }
+}



More information about the jboss-cvs-commits mailing list