use of com.thinkbiganalytics.metadata.jpa.feed.security.JpaFeedOpsAclEntry in project kylo by Teradata.
the class OpsManagerFeedRepositoryTest method findFeedNames_MatchingGroupAclEntry.
@WithMockJaasUser(username = "dladmin", password = "secret", authorities = { "admin", "user" })
@Test
public void findFeedNames_MatchingGroupAclEntry() 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 adminGroupAcl = new JpaFeedOpsAclEntry(feedId, "admin", JpaFeedOpsAclEntry.PrincipalType.GROUP);
aclRepo.save(adminGroupAcl);
List<String> feedNames = repo.getFeedNames();
Assert.assertEquals(1, feedNames.size());
Assert.assertEquals("feed-name", feedNames.get(0));
}
use of com.thinkbiganalytics.metadata.jpa.feed.security.JpaFeedOpsAclEntry in project kylo by Teradata.
the class OpsManagerFeedRepositoryTest method findFeedNames_NoMatchingGroupAclEntry.
@WithMockJaasUser(username = "dladmin", password = "secret", authorities = { "admin", "user" })
@Test
public void findFeedNames_NoMatchingGroupAclEntry() throws Exception {
JpaOpsManagerFeed feed = new JpaOpsManagerFeed(OpsManagerFeedId.create(), "feed-name");
repo.save(feed);
BaseFeed.FeedId feedId = new BaseFeed.FeedId(feed.getId().getUuid());
JpaFeedOpsAclEntry nonMatching = new JpaFeedOpsAclEntry(feedId, "NON_MATCHING", JpaFeedOpsAclEntry.PrincipalType.GROUP);
aclRepo.save(nonMatching);
List<String> feedNames = repo.getFeedNames();
Assert.assertEquals(0, feedNames.size());
}
use of com.thinkbiganalytics.metadata.jpa.feed.security.JpaFeedOpsAclEntry in project kylo by Teradata.
the class OpsManagerFeedRepositoryTest method findOne.
@WithMockJaasUser(username = "dladmin", password = "secret", authorities = { "admin", "user" })
@Test
public void findOne() 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);
Assert.assertNotNull(repo.findOne(feed1.getId()));
Assert.assertNotNull(repo.findOne(feed2.getId()));
Assert.assertNull(repo.findOne(feed3.getId()));
}
use of com.thinkbiganalytics.metadata.jpa.feed.security.JpaFeedOpsAclEntry in project kylo by Teradata.
the class OpsManagerFeedRepositoryTest method findAllFilter_NoMatchingGroupAclEntry.
@WithMockJaasUser(username = "dladmin", password = "secret", authorities = { "admin", "user" })
@Test
public void findAllFilter_NoMatchingGroupAclEntry() throws Exception {
JpaOpsManagerFeed feed = new JpaOpsManagerFeed(OpsManagerFeedId.create(), "feed-name");
repo.save(feed);
BaseFeed.FeedId feedId = new BaseFeed.FeedId(feed.getId().getUuid());
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.assertFalse(StreamSupport.stream(all.spliterator(), false).anyMatch(it -> it.getName().equals("feed-name")));
}
use of com.thinkbiganalytics.metadata.jpa.feed.security.JpaFeedOpsAclEntry in project kylo by Teradata.
the class OpsManagerFeedRepositoryTest method testCustomMethod_findByName.
@WithMockJaasUser(username = "dladmin", password = "secret", authorities = { "admin", "user" })
@Test
public void testCustomMethod_findByName() 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, "NON_MATCHING", 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);
List<JpaOpsManagerFeed> feeds1 = repo.findByName("feed1-name");
Assert.assertTrue(feeds1.isEmpty());
List<JpaOpsManagerFeed> feeds2 = repo.findByName("feed2-name");
Assert.assertEquals(1, feeds2.size());
Assert.assertEquals("feed2-name", feeds2.get(0).getName());
}
Aggregations