From bbf1afa0ddbcff717e64621a69b8313f81dd7122 Mon Sep 17 00:00:00 2001 From: Eric Evans Date: Wed, 6 Oct 2010 15:19:19 +0000 Subject: [PATCH] CF access test for SimpleAuthority Patch by eevans; reviewed by Stu Hood for CASSANDRA-1554 git-svn-id: https://svn.apache.org/repos/asf/cassandra/trunk@1005081 13f79535-47bb-0310-9956-ffa450edef68 --- test/conf/access.properties | 5 +++-- .../apache/cassandra/auth/SimpleAuthorityTest.java | 13 ++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/test/conf/access.properties b/test/conf/access.properties index 0a5e1bd35d..ef6c8c43fe 100644 --- a/test/conf/access.properties +++ b/test/conf/access.properties @@ -24,5 +24,6 @@ # list of keyspaces: all users will be able to view the list of keyspaces. =user1 -Keyspace1.=user1,user2 -Keyspace1.=user1,user2 +Keyspace1.=user1,user2 +Keyspace1.Standard1.=user2 +Keyspace1.Standard1.=user1 diff --git a/test/unit/org/apache/cassandra/auth/SimpleAuthorityTest.java b/test/unit/org/apache/cassandra/auth/SimpleAuthorityTest.java index 0660954531..cc1384c5d0 100644 --- a/test/unit/org/apache/cassandra/auth/SimpleAuthorityTest.java +++ b/test/unit/org/apache/cassandra/auth/SimpleAuthorityTest.java @@ -23,7 +23,6 @@ import java.util.Arrays; import java.util.EnumSet; import java.util.List; -import org.junit.Before; import org.junit.Test; import static org.junit.Assert.assertEquals; @@ -38,6 +37,10 @@ public class SimpleAuthorityTest private final List KEYSPACES_RESOURCE = Arrays.asList(Resources.ROOT, Resources.KEYSPACES); private final List KEYSPACE1_RESOURCE = Arrays.asList(Resources.ROOT, Resources.KEYSPACES, "Keyspace1"); private final List KEYSPACE2_RESOURCE = Arrays.asList(Resources.ROOT, Resources.KEYSPACES, "Keyspace2"); + private final List STANDARD1_RESOURCE = Arrays.asList(Resources.ROOT, + Resources.KEYSPACES, + "Keyspace1", + "Standard1"); @Test public void testValidateConfiguration() throws Exception @@ -70,4 +73,12 @@ public class SimpleAuthorityTest EnumSet.of(Permission.READ), authority.authorize(USER3, KEYSPACES_RESOURCE)); } + + @Test + public void testAuthorizeColumnFamily() throws Exception + { + assertEquals(Permission.ALL, authority.authorize(USER1, STANDARD1_RESOURCE)); + assertEquals(EnumSet.of(Permission.READ), authority.authorize(USER2, STANDARD1_RESOURCE)); + assertEquals(Permission.NONE, authority.authorize(USER3, STANDARD1_RESOURCE)); + } }