Update of /var/cvs/tests/cloudcontext/org/mmbase/security/cloudcontext
In directory james.mmbase.org:/tmp/cvs-serv22779

Modified Files:
        CloudContext.java 
Log Message:
not a bug after all. The latency was just a bit bigger than I expected. Also 
testing 'revoke'


See also: 
http://cvs.mmbase.org/viewcvs/tests/cloudcontext/org/mmbase/security/cloudcontext


Index: CloudContext.java
===================================================================
RCS file: 
/var/cvs/tests/cloudcontext/org/mmbase/security/cloudcontext/CloudContext.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- CloudContext.java   16 Dec 2008 18:19:12 -0000      1.7
+++ CloudContext.java   16 Dec 2008 18:33:49 -0000      1.8
@@ -161,7 +161,7 @@
         
     }
 
-    public void testGrant() throws InterruptedException {
+    public void testGrantToUser() throws InterruptedException {
         Cloud cloud = getCloud("foo");
         Node userNode = 
cloud.getNode(cloud.getCloudContext().getAuthentication().getNode(cloud.getUser()));
 
@@ -177,8 +177,8 @@
         //assertFalse(cloud.getUser().isValid());
 
         // a certain latency is allowed
-        Thread.sleep(1000);
-        org.mmbase.cache.CacheManager.getInstance().clear(".*"); //  TODO 
TODO,  this should _NOT_ be necessary.
+        Thread.sleep(5000);
+
         // now foo should be allowed to create new contexts
         cloud = getCloud("foo");
         assertTrue(cloud.getNodeManager("mmbasecontexts").mayCreateNode());
@@ -187,6 +187,34 @@
         n3.setStringValue("name", "testcontextoffoo");
         n3.commit();
     }
+    public void testRevokeFromUser() throws InterruptedException {
+        Cloud cloud = getCloud("foo");
+        Node userNode = 
cloud.getNode(cloud.getCloudContext().getAuthentication().getNode(cloud.getUser()));
+
+        Cloud adminCloud = getCloud();
+        Node contextNode = SearchUtil.findNode(adminCloud, "mmbasecontexts", 
"name", "security");
+        Parameters params = contextNode.createParameters("revoke");
+        params.set("grouporuser", "" + userNode.getNumber());
+        params.set("operation", "" + Operation.CREATE.toString());
+        params.set("user", adminCloud.getUser());
+
+        assertTrue(contextNode.getFunctionValue("revoke", params).toBoolean());
+        // a certain latency is allowed
+        Thread.sleep(5000);
+
+        // now foo should be disallowed to create new contexts again
+        cloud = getCloud("foo");
+        assertFalse(cloud.getNodeManager("mmbasecontexts").mayCreateNode());
+
+        try {
+            Node n3 = cloud.getNodeManager("mmbasecontexts").createNode();
+            n3.setStringValue("name", "testcontextoffoo2");
+            n3.commit();
+            fail("Should not have been allowed to create new mmbase contexts");
+        } catch (SecurityException se) {
+            // ok
+        }
+    }
 
 }
 
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to