Search in sources :

Example 11 with WithMockJaasUser

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));
}
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 12 with WithMockJaasUser

use of com.thinkbiganalytics.test.security.WithMockJaasUser in project kylo by Teradata.

the class JpaBatchJobExecutionTest method testJobStatusCountFromNow.

@WithMockJaasUser(username = "dladmin", password = "secret", authorities = { "admin" })
@Test
public void testJobStatusCountFromNow() {
    operationalMetadataAccess.read(() -> {
        Period period = DateTimeUtil.period("3Y");
        List<JobStatusCount> counts = jobExecutionProvider.getJobStatusCountByDateFromNow(period, null);
        return counts;
    });
}
Also used : Period(org.joda.time.Period) JobStatusCount(com.thinkbiganalytics.metadata.api.jobrepo.job.JobStatusCount) Test(org.junit.Test) WithMockJaasUser(com.thinkbiganalytics.test.security.WithMockJaasUser)

Example 13 with WithMockJaasUser

use of com.thinkbiganalytics.test.security.WithMockJaasUser in project kylo by Teradata.

the class JpaBatchJobExecutionTest method testPaging.

@WithMockJaasUser(username = "dladmin", password = "secret", authorities = { "admin" })
@Test
public void testPaging() {
    operationalMetadataAccess.read(() -> {
        String filter = "jobInstance.feed.feedType==FEED,jobInstance.feed.name==movies.new_releases";
        // String feed = "movies.new_releases";
        Page<? extends BatchJobExecution> page = jobExecutionProvider.findAll(filter, new PageRequest(0, 10, Sort.Direction.DESC, "jobExecutionId"));
        return page;
    });
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) Test(org.junit.Test) WithMockJaasUser(com.thinkbiganalytics.test.security.WithMockJaasUser)

Example 14 with WithMockJaasUser

use of com.thinkbiganalytics.test.security.WithMockJaasUser 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)));
}
Also used : FeedOpsAccessControlRepository(com.thinkbiganalytics.metadata.jpa.feed.security.FeedOpsAccessControlRepository) RunWith(org.junit.runner.RunWith) Test(org.junit.Test) TestPropertySource(org.springframework.test.context.TestPropertySource) UUID(java.util.UUID) TestJpaConfiguration(com.thinkbiganalytics.metadata.jpa.TestJpaConfiguration) FeedOpsAccessControlConfig(com.thinkbiganalytics.metadata.jpa.feed.security.FeedOpsAccessControlConfig) JpaFeedOpsAclEntry(com.thinkbiganalytics.metadata.jpa.feed.security.JpaFeedOpsAclEntry) WithMockJaasUser(com.thinkbiganalytics.test.security.WithMockJaasUser) Configuration(org.springframework.context.annotation.Configuration) Inject(javax.inject.Inject) Mockito(org.mockito.Mockito) OperationalMetadataConfig(com.thinkbiganalytics.metadata.config.OperationalMetadataConfig) SpringJUnit4ClassRunner(org.springframework.test.context.junit4.SpringJUnit4ClassRunner) SpringApplicationConfiguration(org.springframework.boot.test.SpringApplicationConfiguration) AccessController(com.thinkbiganalytics.security.AccessController) CommonsSpringConfiguration(com.thinkbiganalytics.spring.CommonsSpringConfiguration) StreamSupport(java.util.stream.StreamSupport) 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) UUID(java.util.UUID) Test(org.junit.Test) WithMockJaasUser(com.thinkbiganalytics.test.security.WithMockJaasUser)

Example 15 with WithMockJaasUser

use of com.thinkbiganalytics.test.security.WithMockJaasUser 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)));
}
Also used : FeedOpsAccessControlRepository(com.thinkbiganalytics.metadata.jpa.feed.security.FeedOpsAccessControlRepository) RunWith(org.junit.runner.RunWith) Test(org.junit.Test) TestPropertySource(org.springframework.test.context.TestPropertySource) UUID(java.util.UUID) TestJpaConfiguration(com.thinkbiganalytics.metadata.jpa.TestJpaConfiguration) FeedOpsAccessControlConfig(com.thinkbiganalytics.metadata.jpa.feed.security.FeedOpsAccessControlConfig) JpaFeedOpsAclEntry(com.thinkbiganalytics.metadata.jpa.feed.security.JpaFeedOpsAclEntry) WithMockJaasUser(com.thinkbiganalytics.test.security.WithMockJaasUser) Configuration(org.springframework.context.annotation.Configuration) Inject(javax.inject.Inject) Mockito(org.mockito.Mockito) OperationalMetadataConfig(com.thinkbiganalytics.metadata.config.OperationalMetadataConfig) SpringJUnit4ClassRunner(org.springframework.test.context.junit4.SpringJUnit4ClassRunner) SpringApplicationConfiguration(org.springframework.boot.test.SpringApplicationConfiguration) AccessController(com.thinkbiganalytics.security.AccessController) CommonsSpringConfiguration(com.thinkbiganalytics.spring.CommonsSpringConfiguration) StreamSupport(java.util.stream.StreamSupport) 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) UUID(java.util.UUID) Test(org.junit.Test) WithMockJaasUser(com.thinkbiganalytics.test.security.WithMockJaasUser)

Aggregations

WithMockJaasUser (com.thinkbiganalytics.test.security.WithMockJaasUser)24 Test (org.junit.Test)24 BaseFeed (com.thinkbiganalytics.metadata.core.feed.BaseFeed)19 JpaFeedOpsAclEntry (com.thinkbiganalytics.metadata.jpa.feed.security.JpaFeedOpsAclEntry)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 PageRequest (org.springframework.data.domain.PageRequest)10 TestPropertySource (org.springframework.test.context.TestPropertySource)10 SpringJUnit4ClassRunner (org.springframework.test.context.junit4.SpringJUnit4ClassRunner)10