use of org.apache.tez.dag.api.records.DAGProtos.ACLInfo in project tez by apache.
the class TestDAGVerify method testDAGAccessControls.
@Test(timeout = 5000)
public void testDAGAccessControls() {
DAG dag = DAG.create("testDag");
ProcessorDescriptor pd1 = ProcessorDescriptor.create("processor1").setUserPayload(UserPayload.create(ByteBuffer.wrap("processor1Bytes".getBytes())));
Vertex v1 = Vertex.create("v1", pd1, 10, Resource.newInstance(1024, 1));
dag.addVertex(v1);
DAGAccessControls dagAccessControls = new DAGAccessControls();
dagAccessControls.setUsersWithViewACLs(Arrays.asList("u1")).setUsersWithModifyACLs(Arrays.asList("*")).setGroupsWithViewACLs(Arrays.asList("g1")).setGroupsWithModifyACLs(Arrays.asList("g2"));
dag.setAccessControls(dagAccessControls);
Configuration conf = new Configuration(false);
DAGPlan dagPlan = dag.createDag(conf, null, null, null, true);
Assert.assertNull(conf.get(TezConstants.TEZ_DAG_VIEW_ACLS));
Assert.assertNull(conf.get(TezConstants.TEZ_DAG_MODIFY_ACLS));
ACLInfo aclInfo = dagPlan.getAclInfo();
Assert.assertEquals(Collections.singletonList("u1"), aclInfo.getUsersWithViewAccessList());
Assert.assertEquals(Collections.singletonList("g1"), aclInfo.getGroupsWithViewAccessList());
Assert.assertEquals(Collections.singletonList("*"), aclInfo.getUsersWithModifyAccessList());
Assert.assertEquals(Collections.singletonList("g2"), aclInfo.getGroupsWithModifyAccessList());
}
use of org.apache.tez.dag.api.records.DAGProtos.ACLInfo in project tez by apache.
the class TestDagTypeConverters method testAclConversions.
@Test
public void testAclConversions() {
DAGAccessControls dagAccessControls = new DAGAccessControls("u1,u2 g1,g2", "u3,u4 g3,g4");
ACLInfo aclInfo = DagTypeConverters.convertDAGAccessControlsToProto(dagAccessControls);
assertSame(dagAccessControls, aclInfo);
assertSame(DagTypeConverters.convertDAGAccessControlsFromProto(aclInfo), aclInfo);
dagAccessControls = new DAGAccessControls("u1 ", "u2 ");
aclInfo = DagTypeConverters.convertDAGAccessControlsToProto(dagAccessControls);
assertSame(dagAccessControls, aclInfo);
assertSame(DagTypeConverters.convertDAGAccessControlsFromProto(aclInfo), aclInfo);
dagAccessControls = new DAGAccessControls(" g1", " g3,g4");
aclInfo = DagTypeConverters.convertDAGAccessControlsToProto(dagAccessControls);
assertSame(dagAccessControls, aclInfo);
assertSame(DagTypeConverters.convertDAGAccessControlsFromProto(aclInfo), aclInfo);
dagAccessControls = new DAGAccessControls("*", "*");
aclInfo = DagTypeConverters.convertDAGAccessControlsToProto(dagAccessControls);
assertSame(dagAccessControls, aclInfo);
assertSame(DagTypeConverters.convertDAGAccessControlsFromProto(aclInfo), aclInfo);
}
Aggregations