karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject git commit: [KARAF-2934]Role-based security for Shell/Console commands - backport to 2.x branch-add ShellCommandSecurityTest
Date Wed, 07 May 2014 05:56:54 GMT
Repository: karaf
Updated Branches:
  refs/heads/karaf-2.x a08c8e1b7 -> e14acd0c8


[KARAF-2934]Role-based security for Shell/Console commands - backport to 2.x branch-add ShellCommandSecurityTest


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/e14acd0c
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/e14acd0c
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/e14acd0c

Branch: refs/heads/karaf-2.x
Commit: e14acd0c874fca2ed9ce3a5bf93b4eafa348df6f
Parents: a08c8e1
Author: Freeman Fang <freeman.fang@gmail.com>
Authored: Wed May 7 13:56:40 2014 +0800
Committer: Freeman Fang <freeman.fang@gmail.com>
Committed: Wed May 7 13:56:40 2014 +0800

----------------------------------------------------------------------
 .../karaf/itests/ShellCommandSecurityTest.java  | 48 ++++++++++++++++++++
 1 file changed, 48 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/e14acd0c/itests/src/test/java/org/apache/karaf/itests/ShellCommandSecurityTest.java
----------------------------------------------------------------------
diff --git a/itests/src/test/java/org/apache/karaf/itests/ShellCommandSecurityTest.java b/itests/src/test/java/org/apache/karaf/itests/ShellCommandSecurityTest.java
new file mode 100644
index 0000000..d365211
--- /dev/null
+++ b/itests/src/test/java/org/apache/karaf/itests/ShellCommandSecurityTest.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed 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.karaf.itests;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+
+/**
+ * This test exercises the Shell Command ACL for the shell scope commands as defined in
+ * /framework/src/main/resources/resources/etc/org.apache.karaf.command.acl.shell.cfg
+ */
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public class ShellCommandSecurityTest extends SshCommandTestBase {
+    private static int counter = 0;
+    @Test
+    public void testShellCommandSecurityViaSsh() throws Exception {
+        String vieweruser = "view" + System.nanoTime() + "_" + counter++;
+
+        addViewer(vieweruser);
+
+        assertCommand(vieweruser, "shell:date", Result.OK);
+        assertCommand(vieweruser, "shell:edit", Result.NOT_FOUND);
+        assertCommand(vieweruser, "shell:exec", Result.NOT_FOUND);
+        assertCommand(vieweruser, "shell:new", Result.NOT_FOUND);
+        assertCommand(vieweruser, "shell:java", Result.NOT_FOUND);
+
+        assertCommand("karaf", "shell:date", Result.OK);
+        assertCommand("karaf", "shell:edit", Result.OK);
+        assertCommand("karaf", "shell:exec", Result.OK);
+        assertCommand("karaf", "shell:new", Result.OK);
+        assertCommand("karaf", "shell:java", Result.OK);
+    }
+}


Mime
View raw message