Search in sources :

Example 76 with Order

use of org.junit.jupiter.api.Order in project molgenis by molgenis.

the class DataServiceIT method testIterator.

@WithMockUser(username = USERNAME_READ)
@Test
@Order(10)
public void testIterator() {
    Repository repo = dataService.getRepository(entityType.getId());
    assertTrue(Iterables.any(dataService, e -> repo.getName().equals(e.getName())));
}
Also used : RepositoryCapability(org.molgenis.data.RepositoryCapability) PermissionSet(org.molgenis.security.core.PermissionSet) ATTR_BOOL(org.molgenis.data.EntityTestHarness.ATTR_BOOL) ATTR_CATEGORICAL_MREF(org.molgenis.data.EntityTestHarness.ATTR_CATEGORICAL_MREF) ATTR_INT(org.molgenis.data.EntityTestHarness.ATTR_INT) MolgenisDateFormat.parseLocalDate(org.molgenis.data.util.MolgenisDateFormat.parseLocalDate) Autowired(org.springframework.beans.factory.annotation.Autowired) RunAsSystemAspect.runAsSystem(org.molgenis.security.core.runas.RunAsSystemAspect.runAsSystem) VALIDATE_REFERENCE_CONSTRAINT(org.molgenis.data.RepositoryCapability.VALIDATE_REFERENCE_CONSTRAINT) Collections.singletonList(java.util.Collections.singletonList) ObjectIdentity(org.springframework.security.acls.model.ObjectIdentity) AfterAll(org.junit.jupiter.api.AfterAll) BeforeAll(org.junit.jupiter.api.BeforeAll) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) MANAGABLE(org.molgenis.data.RepositoryCapability.MANAGABLE) EntityTypeIdentity(org.molgenis.data.security.EntityTypeIdentity) EntityTestHarness(org.molgenis.data.EntityTestHarness) MolgenisDateFormat.parseInstant(org.molgenis.data.util.MolgenisDateFormat.parseInstant) Set(java.util.Set) Stream(java.util.stream.Stream) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) TestEntityStaticMetaData(org.molgenis.data.staticentity.TestEntityStaticMetaData) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) EntityIdentity(org.molgenis.data.security.EntityIdentity) Iterables(com.google.common.collect.Iterables) UnknownEntityTypeException(org.molgenis.data.UnknownEntityTypeException) ATTR_DATETIME(org.molgenis.data.EntityTestHarness.ATTR_DATETIME) ATTR_HTML(org.molgenis.data.EntityTestHarness.ATTR_HTML) ATTR_DATE(org.molgenis.data.EntityTestHarness.ATTR_DATE) Commit(org.springframework.test.annotation.Commit) Supplier(java.util.function.Supplier) ATTR_CATEGORICAL(org.molgenis.data.EntityTestHarness.ATTR_CATEGORICAL) PermissionService(org.molgenis.data.security.permission.PermissionService) AggregateResult(org.molgenis.data.aggregation.AggregateResult) ATTR_ID(org.molgenis.data.EntityTestHarness.ATTR_ID) Stream.concat(java.util.stream.Stream.concat) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Sid(org.springframework.security.acls.model.Sid) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Stream.of(java.util.stream.Stream.of) AggregateQuery(org.molgenis.data.aggregation.AggregateQuery) WRITABLE(org.molgenis.data.RepositoryCapability.WRITABLE) ATTR_LONG(org.molgenis.data.EntityTestHarness.ATTR_LONG) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) AbstractMockitoSpringContextTests(org.molgenis.test.AbstractMockitoSpringContextTests) ContextConfiguration(org.springframework.test.context.ContextConfiguration) Entity(org.molgenis.data.Entity) AggregateQueryImpl(org.molgenis.data.support.AggregateQueryImpl) Permission(org.molgenis.data.security.permission.model.Permission) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) LoggerFactory(org.slf4j.LoggerFactory) ATTR_HYPERLINK(org.molgenis.data.EntityTestHarness.ATTR_HYPERLINK) Order(org.junit.jupiter.api.Order) Fetch(org.molgenis.data.Fetch) ATTR_COMPOUND_CHILD_INT(org.molgenis.data.EntityTestHarness.ATTR_COMPOUND_CHILD_INT) ATTR_SCRIPT(org.molgenis.data.EntityTestHarness.ATTR_SCRIPT) FileMetaFactory(org.molgenis.data.file.model.FileMetaFactory) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) Sort(org.molgenis.data.Sort) ATTR_EMAIL(org.molgenis.data.EntityTestHarness.ATTR_EMAIL) MethodSource(org.junit.jupiter.params.provider.MethodSource) Collections.emptyList(java.util.Collections.emptyList) IndexJobScheduler(org.molgenis.data.index.job.IndexJobScheduler) FILE_META(org.molgenis.data.file.model.FileMetaMetadata.FILE_META) Instant(java.time.Instant) EntityType(org.molgenis.data.meta.model.EntityType) TestEntityStatic(org.molgenis.data.staticentity.TestEntityStatic) Test(org.junit.jupiter.api.Test) List(java.util.List) LocalDate(java.time.LocalDate) Entry(java.util.Map.Entry) Repository(org.molgenis.data.Repository) EntityTypePermissionDeniedException(org.molgenis.data.security.exception.EntityTypePermissionDeniedException) QUERYABLE(org.molgenis.data.RepositoryCapability.QUERYABLE) EntityUtils(org.molgenis.data.util.EntityUtils) SidUtils(org.molgenis.security.core.SidUtils) HashMap(java.util.HashMap) QueryImpl(org.molgenis.data.support.QueryImpl) AbstractMolgenisIntegrationTests.cleanupUserPermissions(org.molgenis.integrationtest.utils.AbstractMolgenisIntegrationTests.cleanupUserPermissions) ValueReferencedException(org.molgenis.data.ValueReferencedException) ATTR_STRING(org.molgenis.data.EntityTestHarness.ATTR_STRING) ATTR_XREF(org.molgenis.data.EntityTestHarness.ATTR_XREF) Logger(org.slf4j.Logger) ATTR_MREF(org.molgenis.data.EntityTestHarness.ATTR_MREF) TestRefEntityStaticMetaData(org.molgenis.data.staticentity.TestRefEntityStaticMetaData) ApplicationContext(org.springframework.context.ApplicationContext) ATTR_DECIMAL(org.molgenis.data.EntityTestHarness.ATTR_DECIMAL) TestTransaction(org.springframework.test.context.transaction.TestTransaction) FileMeta(org.molgenis.data.file.model.FileMeta) Collectors.toList(java.util.stream.Collectors.toList) DataService(org.molgenis.data.DataService) ATTR_ENUM(org.molgenis.data.EntityTestHarness.ATTR_ENUM) OrderAnnotation(org.junit.jupiter.api.MethodOrderer.OrderAnnotation) Transactional(org.springframework.transaction.annotation.Transactional) Repository(org.molgenis.data.Repository) WithMockUser(org.springframework.security.test.context.support.WithMockUser) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 77 with Order

use of org.junit.jupiter.api.Order in project strimzi by strimzi.

the class OauthAuthorizationIsolatedST method testTeamBWriteToTopic.

@Description("As a member of team B, I should be able to write and read from topics that starts with b-")
@ParallelTest
@Order(4)
void testTeamBWriteToTopic(ExtensionContext extensionContext) {
    String clusterName = mapWithClusterNames.get(extensionContext.getDisplayName());
    String topicName = mapWithTestTopics.get(extensionContext.getDisplayName());
    String consumerGroup = "x-" + clusterName;
    String teamBProducerName = TEAM_B_PRODUCER_NAME + "-" + clusterName;
    String teamBConsumerName = TEAM_B_CONSUMER_NAME + "-" + clusterName;
    resourceManager.createResource(extensionContext, KafkaTopicTemplates.topic(oauthClusterName, topicName, INFRA_NAMESPACE).build());
    KafkaOauthClients teamBOauthClientJob = new KafkaOauthClientsBuilder().withNamespaceName(INFRA_NAMESPACE).withProducerName(teamBProducerName).withConsumerName(teamBConsumerName).withBootstrapAddress(KafkaResources.tlsBootstrapAddress(oauthClusterName)).withTopicName(topicName).withMessageCount(MESSAGE_COUNT).withConsumerGroup(consumerGroup).withOauthClientId(TEAM_B_CLIENT).withOauthClientSecret(TEAM_B_CLIENT_SECRET).withOauthTokenEndpointUri(keycloakInstance.getOauthTokenEndpointUri()).build();
    LOGGER.info("Sending {} messages to broker with topic name {}", MESSAGE_COUNT, TOPIC_NAME);
    // Producer will not produce messages because authorization topic will failed. Team A can write only to topic starting with 'x-'
    resourceManager.createResource(extensionContext, teamBOauthClientJob.producerStrimziOauthTls(oauthClusterName));
    JobUtils.waitForJobFailure(teamBProducerName, INFRA_NAMESPACE, 30_000);
    JobUtils.deleteJobWithWait(INFRA_NAMESPACE, teamBProducerName);
    LOGGER.info("Sending {} messages to broker with topic name {}", MESSAGE_COUNT, TOPIC_B);
    teamBOauthClientJob = new KafkaOauthClientsBuilder(teamBOauthClientJob).withConsumerGroup("x-consumer_group_b-" + clusterName).withTopicName(TOPIC_B).build();
    resourceManager.createResource(extensionContext, teamBOauthClientJob.producerStrimziOauthTls(oauthClusterName));
    resourceManager.createResource(extensionContext, teamBOauthClientJob.consumerStrimziOauthTls(oauthClusterName));
    ClientUtils.waitTillContinuousClientsFinish(teamBProducerName, teamBConsumerName, INFRA_NAMESPACE, MESSAGE_COUNT);
}
Also used : KafkaOauthClientsBuilder(io.strimzi.systemtest.kafkaclients.internalClients.KafkaOauthClientsBuilder) KafkaOauthClients(io.strimzi.systemtest.kafkaclients.internalClients.KafkaOauthClients) Order(org.junit.jupiter.api.Order) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Description(io.vertx.core.cli.annotations.Description) ParallelTest(io.strimzi.systemtest.annotations.ParallelTest)

Example 78 with Order

use of org.junit.jupiter.api.Order in project strimzi by strimzi.

the class OauthAuthorizationIsolatedST method testTeamAWriteToTopic.

@Description("As a member of team A, I should be able to write to topics that starts with x- on any cluster and " + "and should also write and read to topics starting with 'a-'")
@ParallelTest
@Order(2)
void testTeamAWriteToTopic(ExtensionContext extensionContext) {
    String clusterName = mapWithClusterNames.get(extensionContext.getDisplayName());
    String teamAProducerName = TEAM_A_PRODUCER_NAME + "-" + clusterName;
    String teamAConsumerName = TEAM_A_CONSUMER_NAME + "-" + clusterName;
    String topicName = mapWithTestTopics.get(extensionContext.getDisplayName());
    String consumerGroup = "a-consumer_group-" + clusterName;
    resourceManager.createResource(extensionContext, KafkaTopicTemplates.topic(oauthClusterName, topicName, INFRA_NAMESPACE).build());
    KafkaOauthClients teamAOauthClientJob = new KafkaOauthClientsBuilder().withNamespaceName(INFRA_NAMESPACE).withProducerName(teamAProducerName).withConsumerName(teamAConsumerName).withBootstrapAddress(KafkaResources.tlsBootstrapAddress(oauthClusterName)).withTopicName(topicName).withMessageCount(MESSAGE_COUNT).withConsumerGroup(consumerGroup).withOauthClientId(TEAM_A_CLIENT).withOauthClientSecret(TEAM_A_CLIENT_SECRET).withOauthTokenEndpointUri(keycloakInstance.getOauthTokenEndpointUri()).build();
    LOGGER.info("Sending {} messages to broker with topic name {}", MESSAGE_COUNT, topicName);
    LOGGER.info("Producer will not produce messages because authorization topic will failed. Team A can write only to topic starting with 'x-'");
    resourceManager.createResource(extensionContext, teamAOauthClientJob.producerStrimziOauthTls(oauthClusterName));
    JobUtils.waitForJobFailure(teamAProducerName, INFRA_NAMESPACE, 30_000);
    JobUtils.deleteJobWithWait(INFRA_NAMESPACE, teamAProducerName);
    String topicXName = TOPIC_X + "-" + clusterName;
    LOGGER.info("Sending {} messages to broker with topic name {}", MESSAGE_COUNT, topicXName);
    teamAOauthClientJob = new KafkaOauthClientsBuilder(teamAOauthClientJob).withConsumerGroup(consumerGroup).withTopicName(topicXName).build();
    resourceManager.createResource(extensionContext, teamAOauthClientJob.producerStrimziOauthTls(oauthClusterName));
    JobUtils.waitForJobFailure(teamAProducerName, INFRA_NAMESPACE, 30_000);
    JobUtils.deleteJobWithWait(INFRA_NAMESPACE, teamAProducerName);
    // Team A can not create topic starting with 'x-' only write to existing on
    resourceManager.createResource(extensionContext, KafkaTopicTemplates.topic(oauthClusterName, topicXName, INFRA_NAMESPACE).build());
    resourceManager.createResource(extensionContext, teamAOauthClientJob.producerStrimziOauthTls(oauthClusterName));
    ClientUtils.waitForClientSuccess(teamAProducerName, INFRA_NAMESPACE, MESSAGE_COUNT);
    JobUtils.deleteJobWithWait(INFRA_NAMESPACE, teamAProducerName);
    String topicAName = TOPIC_A + "-" + clusterName;
    LOGGER.info("Sending {} messages to broker with topic name {}", MESSAGE_COUNT, topicAName);
    teamAOauthClientJob = new KafkaOauthClientsBuilder(teamAOauthClientJob).withConsumerGroup(consumerGroup).withTopicName(topicAName).build();
    resourceManager.createResource(extensionContext, teamAOauthClientJob.producerStrimziOauthTls(oauthClusterName));
    ClientUtils.waitForClientSuccess(teamAProducerName, INFRA_NAMESPACE, MESSAGE_COUNT);
}
Also used : KafkaOauthClientsBuilder(io.strimzi.systemtest.kafkaclients.internalClients.KafkaOauthClientsBuilder) KafkaOauthClients(io.strimzi.systemtest.kafkaclients.internalClients.KafkaOauthClients) Order(org.junit.jupiter.api.Order) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Description(io.vertx.core.cli.annotations.Description) ParallelTest(io.strimzi.systemtest.annotations.ParallelTest)

Example 79 with Order

use of org.junit.jupiter.api.Order in project strimzi by strimzi.

the class OauthAuthorizationIsolatedST method testTeamAWriteToTopicStartingWithXAndTeamBReadFromTopicStartingWithX.

@Description("As a member of team A, I can write to topics starting with 'x-' and " + "as a member of team B can read from topics starting with 'x-'")
@ParallelTest
@Order(5)
void testTeamAWriteToTopicStartingWithXAndTeamBReadFromTopicStartingWithX(ExtensionContext extensionContext) {
    String clusterName = mapWithClusterNames.get(extensionContext.getDisplayName());
    String teamAProducerName = TEAM_A_PRODUCER_NAME + "-" + clusterName;
    String teamAConsumerName = TEAM_A_CONSUMER_NAME + "-" + clusterName;
    String teamBProducerName = TEAM_B_PRODUCER_NAME + "-" + clusterName;
    String teamBConsumerName = TEAM_B_CONSUMER_NAME + "-" + clusterName;
    // only write means that Team A can not create new topic 'x-.*'
    String topicXName = TOPIC_X + mapWithTestTopics.get(extensionContext.getDisplayName());
    String consumerGroup = "x-" + clusterName;
    resourceManager.createResource(extensionContext, KafkaTopicTemplates.topic(oauthClusterName, topicXName, INFRA_NAMESPACE).build());
    KafkaOauthClients teamAOauthClientJob = new KafkaOauthClientsBuilder().withNamespaceName(INFRA_NAMESPACE).withProducerName(teamAProducerName).withConsumerName(teamAConsumerName).withBootstrapAddress(KafkaResources.tlsBootstrapAddress(oauthClusterName)).withTopicName(topicXName).withMessageCount(MESSAGE_COUNT).withConsumerGroup(consumerGroup).withOauthClientId(TEAM_A_CLIENT).withOauthClientSecret(TEAM_A_CLIENT_SECRET).withOauthTokenEndpointUri(keycloakInstance.getOauthTokenEndpointUri()).build();
    teamAOauthClientJob = new KafkaOauthClientsBuilder(teamAOauthClientJob).withConsumerGroup("a-consumer_group" + clusterName).withTopicName(topicXName).build();
    resourceManager.createResource(extensionContext, teamAOauthClientJob.producerStrimziOauthTls(oauthClusterName));
    ClientUtils.waitForClientSuccess(teamAProducerName, INFRA_NAMESPACE, MESSAGE_COUNT);
    KafkaOauthClients teamBOauthClientJob = new KafkaOauthClientsBuilder().withNamespaceName(INFRA_NAMESPACE).withProducerName(teamBProducerName).withConsumerName(teamBConsumerName).withBootstrapAddress(KafkaResources.tlsBootstrapAddress(oauthClusterName)).withTopicName(topicXName).withMessageCount(MESSAGE_COUNT).withConsumerGroup("x-consumer_group_b-" + clusterName).withOauthClientId(TEAM_B_CLIENT).withOauthClientSecret(TEAM_B_CLIENT_SECRET).withOauthTokenEndpointUri(keycloakInstance.getOauthTokenEndpointUri()).build();
    resourceManager.createResource(extensionContext, teamBOauthClientJob.consumerStrimziOauthTls(oauthClusterName));
    ClientUtils.waitForClientSuccess(teamBConsumerName, INFRA_NAMESPACE, MESSAGE_COUNT);
}
Also used : KafkaOauthClientsBuilder(io.strimzi.systemtest.kafkaclients.internalClients.KafkaOauthClientsBuilder) KafkaOauthClients(io.strimzi.systemtest.kafkaclients.internalClients.KafkaOauthClients) Order(org.junit.jupiter.api.Order) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Description(io.vertx.core.cli.annotations.Description) ParallelTest(io.strimzi.systemtest.annotations.ParallelTest)

Example 80 with Order

use of org.junit.jupiter.api.Order in project strimzi by strimzi.

the class OauthAuthorizationIsolatedST method testTeamAReadFromTopic.

@Description("As a member of team A, I should be able only read from consumer that starts with a_")
@ParallelTest
@Order(3)
void testTeamAReadFromTopic(ExtensionContext extensionContext) {
    String clusterName = mapWithClusterNames.get(extensionContext.getDisplayName());
    String teamAProducerName = TEAM_A_PRODUCER_NAME + "-" + clusterName;
    String teamAConsumerName = TEAM_A_CONSUMER_NAME + "-" + clusterName;
    String topicAName = TOPIC_A + "-" + mapWithTestTopics.get(extensionContext.getDisplayName());
    String consumerGroup = "a-consumer_group-" + clusterName;
    resourceManager.createResource(extensionContext, KafkaTopicTemplates.topic(oauthClusterName, topicAName, INFRA_NAMESPACE).build());
    KafkaOauthClients teamAOauthClientJob = new KafkaOauthClientsBuilder().withNamespaceName(INFRA_NAMESPACE).withProducerName(teamAProducerName).withConsumerName(teamAConsumerName).withBootstrapAddress(KafkaResources.tlsBootstrapAddress(oauthClusterName)).withTopicName(topicAName).withMessageCount(MESSAGE_COUNT).withConsumerGroup(consumerGroup).withOauthClientId(TEAM_A_CLIENT).withOauthClientSecret(TEAM_A_CLIENT_SECRET).withOauthTokenEndpointUri(keycloakInstance.getOauthTokenEndpointUri()).build();
    LOGGER.info("Sending {} messages to broker with topic name {}", MESSAGE_COUNT, topicAName);
    resourceManager.createResource(extensionContext, teamAOauthClientJob.producerStrimziOauthTls(oauthClusterName));
    ClientUtils.waitForClientSuccess(teamAProducerName, INFRA_NAMESPACE, MESSAGE_COUNT);
    JobUtils.deleteJobWithWait(INFRA_NAMESPACE, teamAProducerName);
    // team A client shouldn't be able to consume messages with wrong consumer group
    teamAOauthClientJob = new KafkaOauthClientsBuilder(teamAOauthClientJob).withConsumerGroup("bad_consumer_group" + clusterName).withTopicName(topicAName).build();
    resourceManager.createResource(extensionContext, teamAOauthClientJob.consumerStrimziOauthTls(oauthClusterName));
    JobUtils.waitForJobFailure(teamAConsumerName, INFRA_NAMESPACE, 30_000);
    JobUtils.deleteJobWithWait(INFRA_NAMESPACE, teamAProducerName);
    // team A client should be able to consume messages with correct consumer group
    teamAOauthClientJob = new KafkaOauthClientsBuilder(teamAOauthClientJob).withConsumerGroup("a-correct_consumer_group" + clusterName).withTopicName(topicAName).build();
    resourceManager.createResource(extensionContext, teamAOauthClientJob.producerStrimziOauthTls(oauthClusterName));
    ClientUtils.waitForClientSuccess(teamAProducerName, INFRA_NAMESPACE, MESSAGE_COUNT);
}
Also used : KafkaOauthClientsBuilder(io.strimzi.systemtest.kafkaclients.internalClients.KafkaOauthClientsBuilder) KafkaOauthClients(io.strimzi.systemtest.kafkaclients.internalClients.KafkaOauthClients) Order(org.junit.jupiter.api.Order) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Description(io.vertx.core.cli.annotations.Description) ParallelTest(io.strimzi.systemtest.annotations.ParallelTest)

Aggregations

Order (org.junit.jupiter.api.Order)194 Test (org.junit.jupiter.api.Test)184 TestMethodOrder (org.junit.jupiter.api.TestMethodOrder)179 lombok.val (lombok.val)67 WithMockUser (org.springframework.security.test.context.support.WithMockUser)31 CasConfigurationProperties (org.apereo.cas.configuration.CasConfigurationProperties)30 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)24 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)24 Launch (io.quarkus.test.junit.main.Launch)23 Service (org.apereo.cas.authentication.principal.Service)23 CLIResult (org.keycloak.it.junit5.extension.CLIResult)23 DistributionTest (org.keycloak.it.junit5.extension.DistributionTest)23 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)21 Entity (org.molgenis.data.Entity)16 File (java.io.File)12 FileWriter (java.io.FileWriter)12 UnknownEntityTypeException (org.molgenis.data.UnknownEntityTypeException)11 EntityType (org.molgenis.data.meta.model.EntityType)11 JSONObject (net.minidev.json.JSONObject)9 MockTicketGrantingTicket (org.apereo.cas.mock.MockTicketGrantingTicket)9