use of org.apache.hadoop.yarn.security.AdminACLsManager in project hadoop by apache.
the class TestTimelineDataManager method setup.
@Before
public void setup() throws Exception {
fsPath = new File("target", this.getClass().getSimpleName() + "-tmpDir").getAbsoluteFile();
fsContext = FileContext.getLocalFSFileContext();
fsContext.delete(new Path(fsPath.getAbsolutePath()), true);
Configuration conf = new YarnConfiguration();
conf.set(YarnConfiguration.TIMELINE_SERVICE_LEVELDB_PATH, fsPath.getAbsolutePath());
conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_TTL_ENABLE, false);
store = new LeveldbTimelineStore();
store.init(conf);
store.start();
loadTestEntityData();
loadVerificationEntityData();
loadTestDomainData();
conf.setBoolean(YarnConfiguration.YARN_ACL_ENABLE, false);
aclsManager = new TimelineACLsManager(conf);
aclsManager.setTimelineStore(store);
dataManaer = new TimelineDataManager(store, aclsManager);
conf.setBoolean(YarnConfiguration.YARN_ACL_ENABLE, true);
conf.set(YarnConfiguration.YARN_ADMIN_ACL, "admin");
dataManaer.init(conf);
adminACLsManager = new AdminACLsManager(conf);
}
use of org.apache.hadoop.yarn.security.AdminACLsManager in project hadoop by apache.
the class TestTimelineWebServices method testGetDomainsYarnACLsEnabled.
@Test
public void testGetDomainsYarnACLsEnabled() throws Exception {
AdminACLsManager oldAdminACLsManager = timelineACLsManager.setAdminACLsManager(adminACLsManager);
try {
WebResource r = resource();
ClientResponse response = r.path("ws").path("v1").path("timeline").path("domain").queryParam("user.name", "owner_1").accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, response.getType().toString());
TimelineDomains domains = response.getEntity(TimelineDomains.class);
Assert.assertEquals(2, domains.getDomains().size());
for (int i = 0; i < domains.getDomains().size(); ++i) {
verifyDomain(domains.getDomains().get(i), i == 0 ? "domain_id_4" : "domain_id_1");
}
response = r.path("ws").path("v1").path("timeline").path("domain").queryParam("owner", "owner_1").queryParam("user.name", "tester").accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, response.getType().toString());
domains = response.getEntity(TimelineDomains.class);
Assert.assertEquals(0, domains.getDomains().size());
} finally {
timelineACLsManager.setAdminACLsManager(oldAdminACLsManager);
}
}
use of org.apache.hadoop.yarn.security.AdminACLsManager in project hadoop by apache.
the class TestTimelineWebServices method testPutDomainYarnACLsEnabled.
@Test
public void testPutDomainYarnACLsEnabled() throws Exception {
AdminACLsManager oldAdminACLsManager = timelineACLsManager.setAdminACLsManager(adminACLsManager);
try {
TimelineDomain domain = new TimelineDomain();
domain.setId("test_domain_id_acl");
WebResource r = resource();
ClientResponse response = r.path("ws").path("v1").path("timeline").path("domain").queryParam("user.name", "tester").accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON).put(ClientResponse.class, domain);
assertResponseStatusCode(Status.OK, response.getStatusInfo());
// Update the domain by another user
response = r.path("ws").path("v1").path("timeline").path("domain").queryParam("user.name", "other").accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON).put(ClientResponse.class, domain);
assertResponseStatusCode(Status.FORBIDDEN, response.getStatusInfo());
} finally {
timelineACLsManager.setAdminACLsManager(oldAdminACLsManager);
}
}
use of org.apache.hadoop.yarn.security.AdminACLsManager in project hadoop by apache.
the class TimelineACLsManager method setAdminACLsManager.
@Private
@VisibleForTesting
public AdminACLsManager setAdminACLsManager(AdminACLsManager adminAclsManager) {
AdminACLsManager oldAdminACLsManager = this.adminAclsManager;
this.adminAclsManager = adminAclsManager;
return oldAdminACLsManager;
}
use of org.apache.hadoop.yarn.security.AdminACLsManager in project hadoop by apache.
the class TestTimelineDataManager method testGetEntitiesAclEnabled.
@Test
public void testGetEntitiesAclEnabled() throws Exception {
AdminACLsManager oldAdminACLsManager = aclsManager.setAdminACLsManager(adminACLsManager);
try {
TimelineEntities entities = dataManaer.getEntities("ACL_ENTITY_TYPE_1", null, null, null, null, null, null, 1l, null, UserGroupInformation.createUserForTesting("owner_1", new String[] { "group1" }));
Assert.assertEquals(1, entities.getEntities().size());
Assert.assertEquals("ACL_ENTITY_ID_11", entities.getEntities().get(0).getEntityId());
} finally {
aclsManager.setAdminACLsManager(oldAdminACLsManager);
}
}
Aggregations