use of com.thinkbiganalytics.test.security.WithMockJaasUser in project kylo by Teradata.
the class OpsManagerFeedRepositoryTest method findFeedNames_BothMatchingAndNonMatchingGroupsAreSetInAclEntry.
@WithMockJaasUser(username = "dladmin", password = "secret", authorities = { "admin", "user" })
@Test
public void findFeedNames_BothMatchingAndNonMatchingGroupsAreSetInAclEntry() 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);
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.test.security.WithMockJaasUser in project kylo by Teradata.
the class OpsManagerFeedRepositoryTest method findAllFilter_MatchingGroupAndMatchingFilter.
@WithMockJaasUser(username = "dladmin", password = "secret", authorities = { "admin", "user" })
@Test
public void findAllFilter_MatchingGroupAndMatchingFilter() 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 matchingGroup = new JpaFeedOpsAclEntry(feedId, "admin", JpaFeedOpsAclEntry.PrincipalType.GROUP);
aclRepo.save(matchingGroup);
JpaOpsManagerFeed nonMatchingFeed = new JpaOpsManagerFeed(OpsManagerFeedId.create(), "non-matching-feed-name");
repo.save(nonMatchingFeed);
BaseFeed.FeedId nonMatchingFeedId = new BaseFeed.FeedId(nonMatchingFeed.getId().getUuid());
JpaFeedOpsAclEntry dladminUserAcl1 = new JpaFeedOpsAclEntry(nonMatchingFeedId, "dladmin", JpaFeedOpsAclEntry.PrincipalType.USER);
aclRepo.save(dladminUserAcl1);
JpaFeedOpsAclEntry matchingGroup1 = new JpaFeedOpsAclEntry(nonMatchingFeedId, "admin", JpaFeedOpsAclEntry.PrincipalType.GROUP);
aclRepo.save(matchingGroup1);
QJpaOpsManagerFeed qFeed = QJpaOpsManagerFeed.jpaOpsManagerFeed;
Iterable<JpaOpsManagerFeed> all = repo.findAll(GenericQueryDslFilter.buildFilter(qFeed, "name==feed-name"));
Assert.assertTrue(StreamSupport.stream(all.spliterator(), false).anyMatch(it -> it.getName().equals("feed-name")));
Assert.assertFalse(StreamSupport.stream(all.spliterator(), false).anyMatch(it -> it.getName().equals("non-matching-feed-name")));
}
use of com.thinkbiganalytics.test.security.WithMockJaasUser in project kylo by Teradata.
the class OpsManagerFeedRepositoryTest method findFeedNames_NoMatchingGroupMatchingUserAclEntry.
@WithMockJaasUser(username = "dladmin", password = "secret", authorities = { "admin", "user" })
@Test
public void findFeedNames_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);
List<String> feedNames = repo.getFeedNames();
Assert.assertEquals(1, feedNames.size());
}
use of com.thinkbiganalytics.test.security.WithMockJaasUser in project kylo by Teradata.
the class OpsManagerFeedRepositoryTest method findAll_NoMatchingGroupMatchingUserAclEntry.
@WithMockJaasUser(username = "dladmin", password = "secret", authorities = { "admin", "user" })
@Test
public void findAll_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);
Iterable<JpaOpsManagerFeed> all = repo.findAll();
Assert.assertTrue(StreamSupport.stream(all.spliterator(), false).allMatch(it -> it.getName().equals("feed-name")));
}
use of com.thinkbiganalytics.test.security.WithMockJaasUser in project kylo by Teradata.
the class OpsManagerFeedRepositoryTest method findAll_TwoPages.
@WithMockJaasUser(username = "dladmin", password = "secret", authorities = { "admin", "user" })
@Test
public void findAll_TwoPages() 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);
JpaOpsManagerFeed feed4 = new JpaOpsManagerFeed(OpsManagerFeedId.create(), "feed4-name");
repo.save(feed4);
BaseFeed.FeedId feed4Id = new BaseFeed.FeedId(feed4.getId().getUuid());
JpaFeedOpsAclEntry acl4 = new JpaFeedOpsAclEntry(feed4Id, "user", JpaFeedOpsAclEntry.PrincipalType.GROUP);
aclRepo.save(acl4);
JpaOpsManagerFeed feed5 = new JpaOpsManagerFeed(OpsManagerFeedId.create(), "feed5-name");
repo.save(feed5);
BaseFeed.FeedId feed5Id = new BaseFeed.FeedId(feed5.getId().getUuid());
JpaFeedOpsAclEntry acl5 = new JpaFeedOpsAclEntry(feed5Id, "NON_MATCHING", JpaFeedOpsAclEntry.PrincipalType.GROUP);
aclRepo.save(acl5);
JpaOpsManagerFeed feed6 = new JpaOpsManagerFeed(OpsManagerFeedId.create(), "feed6-name");
repo.save(feed6);
BaseFeed.FeedId feed6Id = new BaseFeed.FeedId(feed6.getId().getUuid());
JpaFeedOpsAclEntry acl6 = new JpaFeedOpsAclEntry(feed6Id, "user", JpaFeedOpsAclEntry.PrincipalType.GROUP);
aclRepo.save(acl6);
Pageable page1Request = new PageRequest(0, 2);
Page<JpaOpsManagerFeed> page1 = repo.findAll(page1Request);
Assert.assertEquals(0, page1.getNumber());
Assert.assertEquals(2, page1.getNumberOfElements());
Assert.assertEquals(2, page1.getTotalPages());
Assert.assertEquals(4, page1.getTotalElements());
Pageable page2Request = new PageRequest(1, 2);
Page<JpaOpsManagerFeed> page2 = repo.findAll(page2Request);
Assert.assertEquals(1, page2.getNumber());
Assert.assertEquals(2, page2.getNumberOfElements());
Assert.assertEquals(2, page2.getTotalPages());
Assert.assertEquals(4, page2.getTotalElements());
}
Aggregations