use of com.thinkbiganalytics.metadata.jpa.feed.security.JpaFeedOpsAclEntry in project kylo by Teradata.
the class FeedAclIndexQueryAugmentor method generateExistsExpression.
/**
* Generates the Exist expression for the feed to feedacl table
*
* @return exists expression
*/
private static BooleanExpression generateExistsExpression(QOpsManagerFeedId feedId) {
LOG.debug("FeedAclIndexQueryAugmentor.generateExistsExpression(QOpsManagerFeedId)");
RoleSetExposingSecurityExpressionRoot userCxt = getUserContext();
QJpaFeedOpsAclEntry aclEntry = QJpaFeedOpsAclEntry.jpaFeedOpsAclEntry;
JPQLQuery<JpaFeedOpsAclEntry> subquery = JPAExpressions.selectFrom(aclEntry).where(aclEntry.feed.id.eq(feedId).and(aclEntry.principalName.in(userCxt.getGroups()).and(aclEntry.principalType.eq(FeedOpsAclEntry.PrincipalType.GROUP)).or(aclEntry.principalName.eq(userCxt.getName()).and(aclEntry.principalType.eq(FeedOpsAclEntry.PrincipalType.USER)))));
return subquery.exists();
}
use of com.thinkbiganalytics.metadata.jpa.feed.security.JpaFeedOpsAclEntry in project kylo by Teradata.
the class FeedHealthRepositoryTest method findAll_NoMatchingGroupAclEntry.
@WithMockJaasUser(username = "dladmin", password = "secret", authorities = { "admin", "user" })
@Test
public void findAll_NoMatchingGroupAclEntry() throws Exception {
UUID uuid = UUID.randomUUID();
JpaOpsManagerFeedHealth health = new JpaOpsManagerFeedHealth();
health.setFeedId(new JpaOpsManagerFeedHealth.OpsManagerFeedHealthFeedId(uuid));
repo.save(health);
BaseFeed.FeedId healthId = new BaseFeed.FeedId(uuid);
JpaFeedOpsAclEntry nonMatching = new JpaFeedOpsAclEntry(healthId, "NON_MATCHING", JpaFeedOpsAclEntry.PrincipalType.GROUP);
aclRepo.save(nonMatching);
Iterable<JpaOpsManagerFeedHealth> all = repo.findAll();
Assert.assertFalse(StreamSupport.stream(all.spliterator(), false).anyMatch(it -> it.getFeedId().getUuid().equals(uuid)));
}
use of com.thinkbiganalytics.metadata.jpa.feed.security.JpaFeedOpsAclEntry in project kylo by Teradata.
the class FeedHealthRepositoryTest method findAll_WithMatchingUserAclEntry.
@WithMockJaasUser(username = "dladmin", password = "secret", authorities = { "admin", "user" })
@Test
public void findAll_WithMatchingUserAclEntry() throws Exception {
UUID uuid = UUID.randomUUID();
JpaOpsManagerFeedHealth health = new JpaOpsManagerFeedHealth();
health.setFeedId(new JpaOpsManagerFeedHealth.OpsManagerFeedHealthFeedId(uuid));
repo.save(health);
BaseFeed.FeedId healthId = new BaseFeed.FeedId(uuid);
JpaFeedOpsAclEntry nonMatching = new JpaFeedOpsAclEntry(healthId, "dladmin", JpaFeedOpsAclEntry.PrincipalType.USER);
aclRepo.save(nonMatching);
Iterable<JpaOpsManagerFeedHealth> all = repo.findAll();
Assert.assertTrue(StreamSupport.stream(all.spliterator(), false).anyMatch(it -> it.getFeedId().getUuid().equals(uuid)));
}
use of com.thinkbiganalytics.metadata.jpa.feed.security.JpaFeedOpsAclEntry in project kylo by Teradata.
the class OpsManagerFeedRepositoryTest method findAllFilter_NoMatchingGroupMatchingUserAclEntry.
@WithMockJaasUser(username = "dladmin", password = "secret", authorities = { "admin", "user" })
@Test
public void findAllFilter_NoMatchingGroupMatchingUserAclEntry() throws Exception {
JpaOpsManagerFeed feed = new JpaOpsManagerFeed(OpsManagerFeedId.create(), "feed-name");
repo.save(feed);
BaseFeed.FeedId feedId = new BaseFeed.FeedId(feed.getId().getUuid());
JpaFeedOpsAclEntry dladminUserAcl = new JpaFeedOpsAclEntry(feedId, "dladmin", JpaFeedOpsAclEntry.PrincipalType.USER);
aclRepo.save(dladminUserAcl);
JpaFeedOpsAclEntry nonMatching = new JpaFeedOpsAclEntry(feedId, "NON_MATCHING", JpaFeedOpsAclEntry.PrincipalType.GROUP);
aclRepo.save(nonMatching);
QJpaOpsManagerFeed qFeed = QJpaOpsManagerFeed.jpaOpsManagerFeed;
Iterable<JpaOpsManagerFeed> all = repo.findAll(GenericQueryDslFilter.buildFilter(qFeed, "name: feed-name"));
Assert.assertTrue(StreamSupport.stream(all.spliterator(), false).allMatch(it -> it.getName().equals("feed-name")));
}
use of com.thinkbiganalytics.metadata.jpa.feed.security.JpaFeedOpsAclEntry in project kylo by Teradata.
the class OpsManagerFeedRepositoryTest method count_ShouldCountOnlyPermittedFeeds.
@WithMockJaasUser(username = "dladmin", password = "secret", authorities = { "admin", "user" })
@Test
public void count_ShouldCountOnlyPermittedFeeds() throws Exception {
JpaOpsManagerFeed feed1 = new JpaOpsManagerFeed(OpsManagerFeedId.create(), "feed1-name");
repo.save(feed1);
BaseFeed.FeedId feed1Id = new BaseFeed.FeedId(feed1.getId().getUuid());
JpaFeedOpsAclEntry acl1 = new JpaFeedOpsAclEntry(feed1Id, "admin", JpaFeedOpsAclEntry.PrincipalType.GROUP);
aclRepo.save(acl1);
JpaOpsManagerFeed feed2 = new JpaOpsManagerFeed(OpsManagerFeedId.create(), "feed2-name");
repo.save(feed2);
BaseFeed.FeedId feed2Id = new BaseFeed.FeedId(feed2.getId().getUuid());
JpaFeedOpsAclEntry acl2 = new JpaFeedOpsAclEntry(feed2Id, "user", JpaFeedOpsAclEntry.PrincipalType.GROUP);
aclRepo.save(acl2);
JpaOpsManagerFeed feed3 = new JpaOpsManagerFeed(OpsManagerFeedId.create(), "feed3-name");
repo.save(feed3);
BaseFeed.FeedId feed3Id = new BaseFeed.FeedId(feed3.getId().getUuid());
JpaFeedOpsAclEntry acl3 = new JpaFeedOpsAclEntry(feed3Id, "NON_MATCHING", JpaFeedOpsAclEntry.PrincipalType.GROUP);
aclRepo.save(acl3);
long count = repo.count();
Assert.assertEquals(2, count);
List<JpaOpsManagerFeed> feeds = repo.findAll();
Assert.assertTrue(feeds.stream().anyMatch(it -> it.getName().equals("feed1-name")));
Assert.assertTrue(feeds.stream().anyMatch(it -> it.getName().equals("feed2-name")));
}
Aggregations