Search in sources :

Example 46 with ACL

use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.data.ACL in project atlas by apache.

the class AtlasZookeeperSecurityPropertiesTest method shouldThrowExceptionForInvalidAclString.

@Test(expectedExceptions = IllegalArgumentException.class)
public void shouldThrowExceptionForInvalidAclString() {
    ACL acl = AtlasZookeeperSecurityProperties.parseAcl("randomAcl");
    fail("Should have thrown exception for null ACL string");
}
Also used : ACL(org.apache.zookeeper.data.ACL) Test(org.testng.annotations.Test)

Example 47 with ACL

use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.data.ACL in project atlas by apache.

the class AtlasZookeeperSecurityPropertiesTest method shouldReturnDefaultAclIfNullOrEmpty.

@Test
public void shouldReturnDefaultAclIfNullOrEmpty() {
    ACL acl = AtlasZookeeperSecurityProperties.parseAcl(null, ZooDefs.Ids.OPEN_ACL_UNSAFE.get(0));
    assertEquals(acl, ZooDefs.Ids.OPEN_ACL_UNSAFE.get(0));
}
Also used : ACL(org.apache.zookeeper.data.ACL) Test(org.testng.annotations.Test)

Example 48 with ACL

use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.data.ACL in project atlas by apache.

the class AtlasZookeeperSecurityPropertiesTest method idsWithColonsAreValid.

@Test
public void idsWithColonsAreValid() {
    ACL acl = AtlasZookeeperSecurityProperties.parseAcl("auth:user:password");
    assertEquals(acl.getId().getScheme(), "auth");
    assertEquals(acl.getId().getId(), "user:password");
}
Also used : ACL(org.apache.zookeeper.data.ACL) Test(org.testng.annotations.Test)

Example 49 with ACL

use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.data.ACL in project atlas by apache.

the class AtlasZookeeperSecurityPropertiesTest method shouldGetAcl.

@Test
public void shouldGetAcl() {
    ACL acl = AtlasZookeeperSecurityProperties.parseAcl("sasl:myclient@EXAMPLE.COM");
    assertEquals(acl.getId().getScheme(), "sasl");
    assertEquals(acl.getId().getId(), "myclient@EXAMPLE.COM");
    assertEquals(acl.getPerms(), ZooDefs.Perms.ALL);
}
Also used : ACL(org.apache.zookeeper.data.ACL) Test(org.testng.annotations.Test)

Example 50 with ACL

use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.data.ACL in project drill by apache.

the class TestZKACL method testNonClusterDiscoveryPaths.

/**
 * Test ACLs on znodes other than ones required to discover the cluster
 *
 * ZK libraries only supports one client instance per-machine per-server and it is cached.
 * This test will fail when run after other ZK tests that setup the client in a way that will cause this test to fail
 */
@Test
public void testNonClusterDiscoveryPaths() {
    try {
        client.create().creatingParentsIfNeeded().forPath(drillUDFPath, udf_data);
        List<ACL> remoteACLs = client.getACL().forPath(drillUDFPath);
        List<ACL> desiredACLs = ((ZKACLProviderDelegate) aclProviderDelegate).aclProvider.getDrillAclForPath(drillUDFPath);
        Assert.assertEquals(remoteACLs.size(), desiredACLs.size());
        for (ACL remote : remoteACLs) {
            boolean found = false;
            for (ACL desired : desiredACLs) {
                // desiredACL list is READ_ACL_UNSAFE (READ, WORLD_ANYONE) + CREATOR_ALL_ACL(ALL, AUTH)
                // AUTH in CREATOR_ALL would translate to SASL, username. Hence the replacement
                // Note: The username("testuser1") should match the username in java.security.auth.login.config
                found = desired.toString().equals(remote.toString().replace("sasl", "auth").replace("testuser1", ""));
                if (found) {
                    break;
                }
            }
            Assert.assertTrue(found);
        }
        // check if the data can be read
        byte[] actual = client.getData().forPath(drillUDFPath);
        Assert.assertArrayEquals("testNonClusterDiscoveryPaths data mismatch", udf_data, actual);
    } catch (Exception e) {
        throw new IllegalStateException("testNonClusterDiscoveryPaths failed");
    }
}
Also used : ACL(org.apache.zookeeper.data.ACL) Test(org.junit.Test) BaseTest(org.apache.drill.test.BaseTest) SecurityTest(org.apache.drill.categories.SecurityTest)

Aggregations

ACL (org.apache.zookeeper.data.ACL)215 Id (org.apache.zookeeper.data.Id)85 ArrayList (java.util.ArrayList)61 Test (org.junit.Test)56 Stat (org.apache.zookeeper.data.Stat)45 KeeperException (org.apache.zookeeper.KeeperException)35 Test (org.testng.annotations.Test)32 CuratorFramework (org.apache.curator.framework.CuratorFramework)20 Test (org.junit.jupiter.api.Test)18 Configuration (org.apache.hadoop.conf.Configuration)17 ZooKeeper (org.apache.zookeeper.ZooKeeper)16 ACLProvider (org.apache.curator.framework.api.ACLProvider)15 List (java.util.List)11 IOException (java.io.IOException)10 CountDownLatch (java.util.concurrent.CountDownLatch)9 ExponentialBackoffRetry (org.apache.curator.retry.ExponentialBackoffRetry)8 TestableZooKeeper (org.apache.zookeeper.TestableZooKeeper)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 HashMap (java.util.HashMap)6 CreateMode (org.apache.zookeeper.CreateMode)6