Search in sources :

Example 6 with JpaFeedOpsAclEntry

use of com.thinkbiganalytics.metadata.jpa.feed.security.JpaFeedOpsAclEntry in project kylo by Teradata.

the class OpsManagerFeedRepositoryTest method findAllFilter_MatchingGroupButNoMatchingFilter.

@WithMockJaasUser(username = "dladmin", password = "secret", authorities = { "admin", "user" })
@Test
public void findAllFilter_MatchingGroupButNoMatchingFilter() 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, "admin", JpaFeedOpsAclEntry.PrincipalType.GROUP);
    aclRepo.save(nonMatching);
    QJpaOpsManagerFeed qFeed = QJpaOpsManagerFeed.jpaOpsManagerFeed;
    Iterable<JpaOpsManagerFeed> all = repo.findAll(GenericQueryDslFilter.buildFilter(qFeed, "name==non-matching-feed-name"));
    Assert.assertFalse(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")));
}
Also used : FeedOpsAccessControlRepository(com.thinkbiganalytics.metadata.jpa.feed.security.FeedOpsAccessControlRepository) RunWith(org.junit.runner.RunWith) Autowired(org.springframework.beans.factory.annotation.Autowired) FeedOpsAccessControlConfig(com.thinkbiganalytics.metadata.jpa.feed.security.FeedOpsAccessControlConfig) JpaFeedOpsAclEntry(com.thinkbiganalytics.metadata.jpa.feed.security.JpaFeedOpsAclEntry) GenericQueryDslFilter(com.thinkbiganalytics.metadata.jpa.support.GenericQueryDslFilter) WithMockJaasUser(com.thinkbiganalytics.test.security.WithMockJaasUser) SpringJUnit4ClassRunner(org.springframework.test.context.junit4.SpringJUnit4ClassRunner) AccessController(com.thinkbiganalytics.security.AccessController) CommonsSpringConfiguration(com.thinkbiganalytics.spring.CommonsSpringConfiguration) Pageable(org.springframework.data.domain.Pageable) StreamSupport(java.util.stream.StreamSupport) PageRequest(org.springframework.data.domain.PageRequest) Test(org.junit.Test) TestPropertySource(org.springframework.test.context.TestPropertySource) Page(org.springframework.data.domain.Page) TestJpaConfiguration(com.thinkbiganalytics.metadata.jpa.TestJpaConfiguration) Configuration(org.springframework.context.annotation.Configuration) Mockito(org.mockito.Mockito) OperationalMetadataConfig(com.thinkbiganalytics.metadata.config.OperationalMetadataConfig) List(java.util.List) SpringApplicationConfiguration(org.springframework.boot.test.SpringApplicationConfiguration) Bean(org.springframework.context.annotation.Bean) Assert(org.junit.Assert) BaseFeed(com.thinkbiganalytics.metadata.core.feed.BaseFeed) Transactional(org.springframework.transaction.annotation.Transactional) BaseFeed(com.thinkbiganalytics.metadata.core.feed.BaseFeed) JpaFeedOpsAclEntry(com.thinkbiganalytics.metadata.jpa.feed.security.JpaFeedOpsAclEntry) Test(org.junit.Test) WithMockJaasUser(com.thinkbiganalytics.test.security.WithMockJaasUser)

Example 7 with JpaFeedOpsAclEntry

use of com.thinkbiganalytics.metadata.jpa.feed.security.JpaFeedOpsAclEntry 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")));
}
Also used : FeedOpsAccessControlRepository(com.thinkbiganalytics.metadata.jpa.feed.security.FeedOpsAccessControlRepository) RunWith(org.junit.runner.RunWith) Autowired(org.springframework.beans.factory.annotation.Autowired) FeedOpsAccessControlConfig(com.thinkbiganalytics.metadata.jpa.feed.security.FeedOpsAccessControlConfig) JpaFeedOpsAclEntry(com.thinkbiganalytics.metadata.jpa.feed.security.JpaFeedOpsAclEntry) GenericQueryDslFilter(com.thinkbiganalytics.metadata.jpa.support.GenericQueryDslFilter) WithMockJaasUser(com.thinkbiganalytics.test.security.WithMockJaasUser) SpringJUnit4ClassRunner(org.springframework.test.context.junit4.SpringJUnit4ClassRunner) AccessController(com.thinkbiganalytics.security.AccessController) CommonsSpringConfiguration(com.thinkbiganalytics.spring.CommonsSpringConfiguration) Pageable(org.springframework.data.domain.Pageable) StreamSupport(java.util.stream.StreamSupport) PageRequest(org.springframework.data.domain.PageRequest) Test(org.junit.Test) TestPropertySource(org.springframework.test.context.TestPropertySource) Page(org.springframework.data.domain.Page) TestJpaConfiguration(com.thinkbiganalytics.metadata.jpa.TestJpaConfiguration) Configuration(org.springframework.context.annotation.Configuration) Mockito(org.mockito.Mockito) OperationalMetadataConfig(com.thinkbiganalytics.metadata.config.OperationalMetadataConfig) List(java.util.List) SpringApplicationConfiguration(org.springframework.boot.test.SpringApplicationConfiguration) Bean(org.springframework.context.annotation.Bean) Assert(org.junit.Assert) BaseFeed(com.thinkbiganalytics.metadata.core.feed.BaseFeed) Transactional(org.springframework.transaction.annotation.Transactional) BaseFeed(com.thinkbiganalytics.metadata.core.feed.BaseFeed) JpaFeedOpsAclEntry(com.thinkbiganalytics.metadata.jpa.feed.security.JpaFeedOpsAclEntry) Test(org.junit.Test) WithMockJaasUser(com.thinkbiganalytics.test.security.WithMockJaasUser)

Example 8 with JpaFeedOpsAclEntry

use of com.thinkbiganalytics.metadata.jpa.feed.security.JpaFeedOpsAclEntry 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());
}
Also used : BaseFeed(com.thinkbiganalytics.metadata.core.feed.BaseFeed) JpaFeedOpsAclEntry(com.thinkbiganalytics.metadata.jpa.feed.security.JpaFeedOpsAclEntry) Test(org.junit.Test) WithMockJaasUser(com.thinkbiganalytics.test.security.WithMockJaasUser)

Example 9 with JpaFeedOpsAclEntry

use of com.thinkbiganalytics.metadata.jpa.feed.security.JpaFeedOpsAclEntry in project kylo by Teradata.

the class OpsManagerFeedRepositoryTest method findFeedNames_MultipleMatchingFeedsAndGroups.

@WithMockJaasUser(username = "dladmin", password = "secret", authorities = { "admin", "user" })
@Test
public void findFeedNames_MultipleMatchingFeedsAndGroups() throws Exception {
    JpaOpsManagerFeed feed1 = new JpaOpsManagerFeed(OpsManagerFeedId.create(), "feed1-name");
    repo.save(feed1);
    BaseFeed.FeedId feedId = new BaseFeed.FeedId(feed1.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);
    JpaOpsManagerFeed feed2 = new JpaOpsManagerFeed(OpsManagerFeedId.create(), "feed2-name");
    repo.save(feed2);
    BaseFeed.FeedId feedId2 = new BaseFeed.FeedId(feed2.getId().getUuid());
    JpaFeedOpsAclEntry userGroupAcl = new JpaFeedOpsAclEntry(feedId2, "user", JpaFeedOpsAclEntry.PrincipalType.GROUP);
    aclRepo.save(userGroupAcl);
    List<String> feedNames = repo.getFeedNames();
    Assert.assertEquals(2, feedNames.size());
    Assert.assertTrue(feedNames.contains("feed1-name"));
    Assert.assertTrue(feedNames.contains("feed2-name"));
}
Also used : BaseFeed(com.thinkbiganalytics.metadata.core.feed.BaseFeed) JpaFeedOpsAclEntry(com.thinkbiganalytics.metadata.jpa.feed.security.JpaFeedOpsAclEntry) Test(org.junit.Test) WithMockJaasUser(com.thinkbiganalytics.test.security.WithMockJaasUser)

Example 10 with JpaFeedOpsAclEntry

use of com.thinkbiganalytics.metadata.jpa.feed.security.JpaFeedOpsAclEntry 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));
}
Also used : BaseFeed(com.thinkbiganalytics.metadata.core.feed.BaseFeed) JpaFeedOpsAclEntry(com.thinkbiganalytics.metadata.jpa.feed.security.JpaFeedOpsAclEntry) Test(org.junit.Test) WithMockJaasUser(com.thinkbiganalytics.test.security.WithMockJaasUser)

Aggregations

JpaFeedOpsAclEntry (com.thinkbiganalytics.metadata.jpa.feed.security.JpaFeedOpsAclEntry)20 BaseFeed (com.thinkbiganalytics.metadata.core.feed.BaseFeed)19 WithMockJaasUser (com.thinkbiganalytics.test.security.WithMockJaasUser)19 Test (org.junit.Test)19 OperationalMetadataConfig (com.thinkbiganalytics.metadata.config.OperationalMetadataConfig)10 TestJpaConfiguration (com.thinkbiganalytics.metadata.jpa.TestJpaConfiguration)10 FeedOpsAccessControlConfig (com.thinkbiganalytics.metadata.jpa.feed.security.FeedOpsAccessControlConfig)10 FeedOpsAccessControlRepository (com.thinkbiganalytics.metadata.jpa.feed.security.FeedOpsAccessControlRepository)10 AccessController (com.thinkbiganalytics.security.AccessController)10 CommonsSpringConfiguration (com.thinkbiganalytics.spring.CommonsSpringConfiguration)10 StreamSupport (java.util.stream.StreamSupport)10 Assert (org.junit.Assert)10 RunWith (org.junit.runner.RunWith)10 Mockito (org.mockito.Mockito)10 SpringApplicationConfiguration (org.springframework.boot.test.SpringApplicationConfiguration)10 Bean (org.springframework.context.annotation.Bean)10 Configuration (org.springframework.context.annotation.Configuration)10 TestPropertySource (org.springframework.test.context.TestPropertySource)10 SpringJUnit4ClassRunner (org.springframework.test.context.junit4.SpringJUnit4ClassRunner)10 Transactional (org.springframework.transaction.annotation.Transactional)10