Search in sources :

Example 6 with RMRegistryOperationsService

use of org.apache.hadoop.registry.server.integration.RMRegistryOperationsService in project hadoop by apache.

the class TestSecureRMRegistryOperations method testAnonReadAccess.

@Test
public void testAnonReadAccess() throws Throwable {
    RMRegistryOperationsService rmRegistryOperations = startRMRegistryOperations();
    describe(LOG, "testAnonReadAccess");
    RegistryOperations operations = RegistryOperationsFactory.createAnonymousInstance(zkClientConf);
    addToTeardown(operations);
    operations.start();
    assertFalse("RegistrySecurity.isClientSASLEnabled()==true", RegistrySecurity.isClientSASLEnabled());
    operations.list(PATH_SYSTEM_SERVICES);
}
Also used : RegistryOperations(org.apache.hadoop.registry.client.api.RegistryOperations) RMRegistryOperationsService(org.apache.hadoop.registry.server.integration.RMRegistryOperationsService) Test(org.junit.Test)

Example 7 with RMRegistryOperationsService

use of org.apache.hadoop.registry.server.integration.RMRegistryOperationsService in project hadoop by apache.

the class TestSecureRMRegistryOperations method testDigestAccess.

@Test
public void testDigestAccess() throws Throwable {
    RMRegistryOperationsService registryAdmin = startRMRegistryOperations();
    String id = "username";
    String pass = "password";
    registryAdmin.addWriteAccessor(id, pass);
    List<ACL> clientAcls = registryAdmin.getClientAcls();
    LOG.info("Client ACLS=\n{}", RegistrySecurity.aclsToString(clientAcls));
    String base = "/digested";
    registryAdmin.mknode(base, false);
    List<ACL> baseACLs = registryAdmin.zkGetACLS(base);
    String aclset = RegistrySecurity.aclsToString(baseACLs);
    LOG.info("Base ACLs=\n{}", aclset);
    ACL found = null;
    for (ACL acl : baseACLs) {
        if (ZookeeperConfigOptions.SCHEME_DIGEST.equals(acl.getId().getScheme())) {
            found = acl;
            break;
        }
    }
    assertNotNull("Did not find digest entry in ACLs " + aclset, found);
    zkClientConf.set(KEY_REGISTRY_USER_ACCOUNTS, "sasl:somebody@EXAMPLE.COM, sasl:other");
    RegistryOperations operations = RegistryOperationsFactory.createAuthenticatedInstance(zkClientConf, id, pass);
    addToTeardown(operations);
    operations.start();
    RegistryOperationsClient operationsClient = (RegistryOperationsClient) operations;
    List<ACL> digestClientACLs = operationsClient.getClientAcls();
    LOG.info("digest client ACLs=\n{}", RegistrySecurity.aclsToString(digestClientACLs));
    operations.stat(base);
    operations.mknode(base + "/subdir", false);
    ZKPathDumper pathDumper = registryAdmin.dumpPath(true);
    LOG.info(pathDumper.toString());
}
Also used : ZKPathDumper(org.apache.hadoop.registry.client.impl.zk.ZKPathDumper) RegistryOperationsClient(org.apache.hadoop.registry.client.impl.RegistryOperationsClient) ACL(org.apache.zookeeper.data.ACL) RegistryOperations(org.apache.hadoop.registry.client.api.RegistryOperations) RMRegistryOperationsService(org.apache.hadoop.registry.server.integration.RMRegistryOperationsService) Test(org.junit.Test)

Example 8 with RMRegistryOperationsService

use of org.apache.hadoop.registry.server.integration.RMRegistryOperationsService in project hadoop by apache.

the class TestSecureRMRegistryOperations method testAnonNoWriteAccessOffRoot.

@Test
public void testAnonNoWriteAccessOffRoot() throws Throwable {
    RMRegistryOperationsService rmRegistryOperations = startRMRegistryOperations();
    describe(LOG, "testAnonNoWriteAccessOffRoot");
    RegistryOperations operations = RegistryOperationsFactory.createAnonymousInstance(zkClientConf);
    addToTeardown(operations);
    operations.start();
    assertFalse("mknode(/)", operations.mknode("/", false));
    expectMkNodeFailure(operations, "/sub");
    expectDeleteFailure(operations, PATH_SYSTEM_SERVICES, true);
}
Also used : RegistryOperations(org.apache.hadoop.registry.client.api.RegistryOperations) RMRegistryOperationsService(org.apache.hadoop.registry.server.integration.RMRegistryOperationsService) Test(org.junit.Test)

Example 9 with RMRegistryOperationsService

use of org.apache.hadoop.registry.server.integration.RMRegistryOperationsService in project hadoop by apache.

the class TestSecureRMRegistryOperations method testUserZookeeperHomePathAccess.

@Test
public void testUserZookeeperHomePathAccess() throws Throwable {
    RMRegistryOperationsService rmRegistryOperations = startRMRegistryOperations();
    final String home = rmRegistryOperations.initUserRegistry(ZOOKEEPER);
    describe(LOG, "Creating ZK client");
    RegistryOperations operations = zookeeperUGI.doAs(new PrivilegedExceptionAction<RegistryOperations>() {

        @Override
        public RegistryOperations run() throws Exception {
            RegistryOperations operations = RegistryOperationsFactory.createKerberosInstance(zkClientConf, ZOOKEEPER_CLIENT_CONTEXT);
            addToTeardown(operations);
            operations.start();
            return operations;
        }
    });
    operations.list(home);
    String path = home + "/subpath";
    operations.mknode(path, false);
    operations.delete(path, true);
}
Also used : RegistryOperations(org.apache.hadoop.registry.client.api.RegistryOperations) LoginException(javax.security.auth.login.LoginException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) ServiceStateException(org.apache.hadoop.service.ServiceStateException) PathPermissionException(org.apache.hadoop.fs.PathPermissionException) NoPathPermissionsException(org.apache.hadoop.registry.client.exceptions.NoPathPermissionsException) RMRegistryOperationsService(org.apache.hadoop.registry.server.integration.RMRegistryOperationsService) Test(org.junit.Test)

Example 10 with RMRegistryOperationsService

use of org.apache.hadoop.registry.server.integration.RMRegistryOperationsService in project hadoop by apache.

the class TestSecureRMRegistryOperations method testZookeeperCanWriteUnderSystem.

/**
   * test that ZK can write as itself
   * @throws Throwable
   */
@Test
public void testZookeeperCanWriteUnderSystem() throws Throwable {
    RMRegistryOperationsService rmRegistryOperations = startRMRegistryOperations();
    RegistryOperations operations = rmRegistryOperations;
    operations.mknode(PATH_SYSTEM_SERVICES + "hdfs", false);
    ZKPathDumper pathDumper = rmRegistryOperations.dumpPath(true);
    LOG.info(pathDumper.toString());
}
Also used : ZKPathDumper(org.apache.hadoop.registry.client.impl.zk.ZKPathDumper) RegistryOperations(org.apache.hadoop.registry.client.api.RegistryOperations) RMRegistryOperationsService(org.apache.hadoop.registry.server.integration.RMRegistryOperationsService) Test(org.junit.Test)

Aggregations

RMRegistryOperationsService (org.apache.hadoop.registry.server.integration.RMRegistryOperationsService)12 Test (org.junit.Test)8 RegistryOperations (org.apache.hadoop.registry.client.api.RegistryOperations)7 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 LoginException (javax.security.auth.login.LoginException)2 PathPermissionException (org.apache.hadoop.fs.PathPermissionException)2 NoPathPermissionsException (org.apache.hadoop.registry.client.exceptions.NoPathPermissionsException)2 ZKPathDumper (org.apache.hadoop.registry.client.impl.zk.ZKPathDumper)2 ServiceStateException (org.apache.hadoop.service.ServiceStateException)2 ACL (org.apache.zookeeper.data.ACL)2 RegistryOperationsClient (org.apache.hadoop.registry.client.impl.RegistryOperationsClient)1 Id (org.apache.zookeeper.data.Id)1 Before (org.junit.Before)1