From e188e17130f6b10b837aa1b27c7468c9e14dbdc2 Mon Sep 17 00:00:00 2001 From: Igor Dianov Date: Mon, 18 Dec 2023 19:00:42 -0800 Subject: [PATCH] AAE-17000 Upgrade Activiti Cloud to Spring Boot 3.2 and Spring Cloud 2023.0.0 (#1224) * update activiti.version to 0.0.1-PR-4448-1485-SNAPSHOT * update to SB 3.2.0-M3 and SC 2023.0.0-M2 * update H2 version to 2.2.224 * temporary shim JdbcMetadataStore to fix broken count query on start * update Snakeyaml version to 2.2 as required by Spring 6.1 * apply Prettier formatting to JdbcMetadataStore * Refactor AuthorizationConfigurer to use HttpSecurity lambda customizer * refactor deprecated ResponseEntity getStatusCodeValue() to getStatusCode().value() * remove deprecated Spring MVC setUseTrailingSlashMatch configurer * refactor deprecated Java class newInstance() to getDeclaredConstructor().newInstance() * update activiti.version to 0.0.1-PR-4448-1500-SNAPSHOT * update activiti.version to 0.0.1-PR-4448-1501-SNAPSHOT * update spring-boot.version to 3.2.0-RC1 * update activiti.version to 0.0.1-PR-4448-1550-SNAPSHOT * update spring-boot.version to 2023.0.0-RC2 * update activiti.version to 0.0.1-PR-4448-1562-SNAPSHOT * update activiti.version to 0.0.1-PR-4448-1565-SNAPSHOT * update spring-boot.version to 3.2.0 * update activiti.version to 0.0.1-PR-4448-1618-SNAPSHOT * AAE-16343 Enable CSRF security * update liquibase.version to 4.24.0 * revert JdbcMetadataStore override fix * Add Temporal Timestamp JPA date qualifier for Query entities * Update graphql-jpa-query.version to 1.2.1 * update activiti.version to 0.0.1-PR-4448-1646-SNAPSHOT * update spring-cloud.version to 2023.0.0 * update activiti.version to 0.0.1-PR-4448-1675-SNAPSHOT * remove Spring Milestones repository from pom.xml * revert everit-json-schema.version to 1.14.3 * add assertions for Date to Timestamp coercing to serialized values * update hibernate.version to 6.3.1.Final * Add missing Temporal import * update activiti.version to 0.0.1-PR-4448-1690-SNAPSHOT * Remove reference to Spring Milestones * fix(version): update org.activiti:activiti-dependencies to 8.2.0-alpha.13 --------- Co-authored-by: Elias Ricken de Medeiros <26007058+erdemedeiros@users.noreply.github.com> --- activiti-cloud-api/pom.xml | 2 +- .../AuditEventsControllerImplIT.java | 2 +- .../pom.xml | 10 ++--- .../CloudConnectorConsumerChannels.java | 2 +- .../channels/ProcessRuntimeChannels.java | 4 +- .../starter/test/it/RuntimeMockStreams.java | 6 +-- .../activiti-cloud-query/pom.xml | 2 +- .../config/MessagesCoreAutoConfiguration.java | 1 - activiti-cloud-modeling-service/pom.xml | 2 +- .../pom.xml | 2 +- ...ctivitiGraphQLSchemaAutoConfiguration.java | 14 +------ ...itiGraphQLSchemaAutoConfigurationTest.java | 30 +++++++------ .../query/model/AbstractVariableEntity.java | 5 +++ .../query/model/BPMNSequenceFlowEntity.java | 10 ++++- .../query/model/BaseBPMNActivityEntity.java | 6 +++ .../query/model/IntegrationContextEntity.java | 6 +++ .../query/model/ProcessInstanceEntity.java | 11 +++++ .../services/query/model/TaskEntity.java | 17 ++++++++ .../CustomizedTaskRepositoryImpl.java | 2 +- .../pom.xml | 6 +++ activiti-cloud-query-service/pom.xml | 2 +- .../tests/helper/TaskRestTemplate.java | 4 +- .../cloud/starter/tests/runtime/TasksIT.java | 14 +++---- activiti-cloud-runtime-bundle-service/pom.xml | 2 +- .../AuthorizationConfigurer.java | 9 ++-- .../CommonSecurityAutoConfiguration.java | 42 +++++++------------ .../AuthorizationConfigurerTest.java | 31 +++++++++++--- .../config/AlfrescoWebAutoConfiguration.java | 9 ---- .../TrailingSlashRedirectFilterTest.java | 13 ++---- activiti-cloud-service-common/pom.xml | 2 +- pom.xml | 2 +- 31 files changed, 157 insertions(+), 113 deletions(-) diff --git a/activiti-cloud-api/pom.xml b/activiti-cloud-api/pom.xml index ffe366384f9..208bf35458f 100644 --- a/activiti-cloud-api/pom.xml +++ b/activiti-cloud-api/pom.xml @@ -12,7 +12,7 @@ Activiti Cloud :: Runtime API Parent pom - 8.2.0-alpha.12 + 8.2.0-alpha.13 activiti-cloud-api-dependencies diff --git a/activiti-cloud-audit-service/activiti-cloud-services-audit-jpa/src/test/java/org/activiti/cloud/services/audit/jpa/controller/AuditEventsControllerImplIT.java b/activiti-cloud-audit-service/activiti-cloud-services-audit-jpa/src/test/java/org/activiti/cloud/services/audit/jpa/controller/AuditEventsControllerImplIT.java index b9f29baa6bd..22c3ebb2fd7 100644 --- a/activiti-cloud-audit-service/activiti-cloud-services-audit-jpa/src/test/java/org/activiti/cloud/services/audit/jpa/controller/AuditEventsControllerImplIT.java +++ b/activiti-cloud-audit-service/activiti-cloud-services-audit-jpa/src/test/java/org/activiti/cloud/services/audit/jpa/controller/AuditEventsControllerImplIT.java @@ -331,7 +331,7 @@ private MessageAuditEventEntity messageAuditEventEntity( Class clazz, BPMNMessageEvent.MessageEvents eventType ) throws Exception { - MessageAuditEventEntity eventEntity = clazz.newInstance(); + MessageAuditEventEntity eventEntity = clazz.getDeclaredConstructor().newInstance(); eventEntity.setEventId("eventId"); eventEntity.setTimestamp(System.currentTimeMillis()); diff --git a/activiti-cloud-build/activiti-cloud-build-dependencies-parent/pom.xml b/activiti-cloud-build/activiti-cloud-build-dependencies-parent/pom.xml index 97e4aa016bf..84a2a80c1e6 100644 --- a/activiti-cloud-build/activiti-cloud-build-dependencies-parent/pom.xml +++ b/activiti-cloud-build/activiti-cloud-build-dependencies-parent/pom.xml @@ -12,13 +12,13 @@ pom Activiti Cloud :: Dependencies Parent - 2022.0.4 + 2023.0.0 1.19.1 - 2.2.220 + 2.2.224 21.3 42.5.1 - 4.20.0 - 6.2.7.Final + 4.24.0 + 6.3.1.Final @@ -79,7 +79,7 @@ org.yaml snakeyaml - 2.0 + 2.2 org.apache.commons diff --git a/activiti-cloud-connectors/activiti-cloud-starter-connector/src/test/java/org/activiti/cloud/connectors/starter/channels/CloudConnectorConsumerChannels.java b/activiti-cloud-connectors/activiti-cloud-starter-connector/src/test/java/org/activiti/cloud/connectors/starter/channels/CloudConnectorConsumerChannels.java index ffc11538ca5..df8896933c3 100644 --- a/activiti-cloud-connectors/activiti-cloud-starter-connector/src/test/java/org/activiti/cloud/connectors/starter/channels/CloudConnectorConsumerChannels.java +++ b/activiti-cloud-connectors/activiti-cloud-starter-connector/src/test/java/org/activiti/cloud/connectors/starter/channels/CloudConnectorConsumerChannels.java @@ -24,6 +24,6 @@ public interface CloudConnectorConsumerChannels { @InputBinding(INTEGRATION_EVENT_CONSUMER) default SubscribableChannel integrationEventsConsumer() { - return MessageChannels.publishSubscribe(INTEGRATION_EVENT_CONSUMER).get(); + return MessageChannels.publishSubscribe(INTEGRATION_EVENT_CONSUMER).getObject(); } } diff --git a/activiti-cloud-connectors/activiti-cloud-starter-connector/src/test/java/org/activiti/cloud/connectors/starter/channels/ProcessRuntimeChannels.java b/activiti-cloud-connectors/activiti-cloud-starter-connector/src/test/java/org/activiti/cloud/connectors/starter/channels/ProcessRuntimeChannels.java index ebdcd9b61e6..98102d05a6d 100644 --- a/activiti-cloud-connectors/activiti-cloud-starter-connector/src/test/java/org/activiti/cloud/connectors/starter/channels/ProcessRuntimeChannels.java +++ b/activiti-cloud-connectors/activiti-cloud-starter-connector/src/test/java/org/activiti/cloud/connectors/starter/channels/ProcessRuntimeChannels.java @@ -27,11 +27,11 @@ public interface ProcessRuntimeChannels { @OutputBinding(RUNTIME_CMD_PRODUCER) default MessageChannel runtimeCmdProducer() { - return MessageChannels.direct(RUNTIME_CMD_PRODUCER).get(); + return MessageChannels.direct(RUNTIME_CMD_PRODUCER).getObject(); } @InputBinding(RUNTIME_CMD_RESULTS) default SubscribableChannel runtimeCmdResults() { - return MessageChannels.publishSubscribe(RUNTIME_CMD_RESULTS).get(); + return MessageChannels.publishSubscribe(RUNTIME_CMD_RESULTS).getObject(); } } diff --git a/activiti-cloud-connectors/activiti-cloud-starter-connector/src/test/java/org/activiti/cloud/connectors/starter/test/it/RuntimeMockStreams.java b/activiti-cloud-connectors/activiti-cloud-starter-connector/src/test/java/org/activiti/cloud/connectors/starter/test/it/RuntimeMockStreams.java index a26f9f7980e..eb27615f6a7 100644 --- a/activiti-cloud-connectors/activiti-cloud-starter-connector/src/test/java/org/activiti/cloud/connectors/starter/test/it/RuntimeMockStreams.java +++ b/activiti-cloud-connectors/activiti-cloud-starter-connector/src/test/java/org/activiti/cloud/connectors/starter/test/it/RuntimeMockStreams.java @@ -28,16 +28,16 @@ public interface RuntimeMockStreams { @InputBinding(INTEGRATION_RESULT_CONSUMER) default SubscribableChannel integrationResultsConsumer() { - return MessageChannels.publishSubscribe(INTEGRATION_RESULT_CONSUMER).get(); + return MessageChannels.publishSubscribe(INTEGRATION_RESULT_CONSUMER).getObject(); } @OutputBinding(INTEGRATION_EVENT_PRODUCER) default MessageChannel integrationEventsProducer() { - return MessageChannels.direct(INTEGRATION_EVENT_PRODUCER).get(); + return MessageChannels.direct(INTEGRATION_EVENT_PRODUCER).getObject(); } @InputBinding(INTEGRATION_ERROR_CONSUMER) default SubscribableChannel integrationErrorConsumer() { - return MessageChannels.publishSubscribe(INTEGRATION_ERROR_CONSUMER).get(); + return MessageChannels.publishSubscribe(INTEGRATION_ERROR_CONSUMER).getObject(); } } diff --git a/activiti-cloud-examples/activiti-cloud-query/pom.xml b/activiti-cloud-examples/activiti-cloud-query/pom.xml index 568c77e6510..b99b0e33e39 100644 --- a/activiti-cloud-examples/activiti-cloud-query/pom.xml +++ b/activiti-cloud-examples/activiti-cloud-query/pom.xml @@ -13,7 +13,7 @@ org.activiti.cloud.query.QueryApplication - 19.4 + 21.1 diff --git a/activiti-cloud-messages-service/services/core/src/main/java/org/activiti/cloud/services/messages/core/config/MessagesCoreAutoConfiguration.java b/activiti-cloud-messages-service/services/core/src/main/java/org/activiti/cloud/services/messages/core/config/MessagesCoreAutoConfiguration.java index fe9558323f4..3619b69821d 100644 --- a/activiti-cloud-messages-service/services/core/src/main/java/org/activiti/cloud/services/messages/core/config/MessagesCoreAutoConfiguration.java +++ b/activiti-cloud-messages-service/services/core/src/main/java/org/activiti/cloud/services/messages/core/config/MessagesCoreAutoConfiguration.java @@ -60,7 +60,6 @@ import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.config.EnableIntegrationManagement; import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.dsl.MessageChannels; import org.springframework.integration.handler.MessageProcessor; import org.springframework.integration.handler.advice.IdempotentReceiverInterceptor; diff --git a/activiti-cloud-modeling-service/pom.xml b/activiti-cloud-modeling-service/pom.xml index 7c701cee8f0..a9c82210359 100644 --- a/activiti-cloud-modeling-service/pom.xml +++ b/activiti-cloud-modeling-service/pom.xml @@ -19,7 +19,7 @@ activiti-cloud-acceptance-tests-modeling - 8.2.0-alpha.12 + 8.2.0-alpha.13 1.14.3 4.4 20231013 diff --git a/activiti-cloud-notifications-graphql-service/pom.xml b/activiti-cloud-notifications-graphql-service/pom.xml index d4f1e2236c9..007d7bf1801 100644 --- a/activiti-cloud-notifications-graphql-service/pom.xml +++ b/activiti-cloud-notifications-graphql-service/pom.xml @@ -12,7 +12,7 @@ Activiti Cloud Notifications GraphQL Service :: Parent pom - 1.1.5 + 1.2.1 diff --git a/activiti-cloud-notifications-graphql-service/services/jpa-query/src/main/java/org/activiti/cloud/services/notifications/graphql/jpa/query/ActivitiGraphQLSchemaAutoConfiguration.java b/activiti-cloud-notifications-graphql-service/services/jpa-query/src/main/java/org/activiti/cloud/services/notifications/graphql/jpa/query/ActivitiGraphQLSchemaAutoConfiguration.java index a7da83c2e1f..f5c3485a71f 100644 --- a/activiti-cloud-notifications-graphql-service/services/jpa-query/src/main/java/org/activiti/cloud/services/notifications/graphql/jpa/query/ActivitiGraphQLSchemaAutoConfiguration.java +++ b/activiti-cloud-notifications-graphql-service/services/jpa-query/src/main/java/org/activiti/cloud/services/notifications/graphql/jpa/query/ActivitiGraphQLSchemaAutoConfiguration.java @@ -22,10 +22,8 @@ import com.introproventures.graphql.jpa.query.autoconfigure.GraphQLSchemaBuilderAutoConfiguration; import com.introproventures.graphql.jpa.query.schema.JavaScalars; import graphql.GraphQL; -import java.util.Date; import org.activiti.cloud.services.query.model.ProcessInstanceEntity; import org.activiti.cloud.services.query.model.VariableValue; -import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; @@ -44,9 +42,7 @@ public class ActivitiGraphQLSchemaAutoConfiguration { @Bean - GraphQLJPASchemaBuilderCustomizer graphQLJPASchemaBuilderCustomizer( - @Value("${activiti.cloud.graphql.jpa-query.date-format:yyyy-MM-dd'T'HH:mm:ss.SSSX}") String dateFormatString - ) { + GraphQLJPASchemaBuilderCustomizer graphQLJPASchemaBuilderCustomizer() { return builder -> builder .name("Query") @@ -58,14 +54,6 @@ GraphQLJPASchemaBuilderCustomizer graphQLJPASchemaBuilderCustomizer( .description("VariableValue type") .coercing(new JavaScalars.GraphQLObjectCoercing()) .build() - ) - .scalar( - Date.class, - newScalar() - .name("Date") - .description("Date type with '" + dateFormatString + "' format") - .coercing(new JavaScalars.GraphQLDateCoercing(dateFormatString)) - .build() ); } } diff --git a/activiti-cloud-notifications-graphql-service/services/jpa-query/src/test/java/org/activiti/cloud/services/notifications/graphql/jpa/query/ActivitiGraphQLSchemaAutoConfigurationTest.java b/activiti-cloud-notifications-graphql-service/services/jpa-query/src/test/java/org/activiti/cloud/services/notifications/graphql/jpa/query/ActivitiGraphQLSchemaAutoConfigurationTest.java index ecef9882021..069bc5eac0c 100644 --- a/activiti-cloud-notifications-graphql-service/services/jpa-query/src/test/java/org/activiti/cloud/services/notifications/graphql/jpa/query/ActivitiGraphQLSchemaAutoConfigurationTest.java +++ b/activiti-cloud-notifications-graphql-service/services/jpa-query/src/test/java/org/activiti/cloud/services/notifications/graphql/jpa/query/ActivitiGraphQLSchemaAutoConfigurationTest.java @@ -24,7 +24,6 @@ import graphql.schema.GraphQLSchema; import java.time.Instant; import java.util.Date; -import java.util.TimeZone; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -128,20 +127,25 @@ void correctlyDerivesPageableSchemaFromGivenEntities() { @Test void correctlyCoercesDateToISO8601FormatWithTimeAndZoneOffset() { - TimeZone timeZone = TimeZone.getDefault(); - TimeZone.setDefault(TimeZone.getTimeZone("UTC")); + // given + Coercing subject = JavaScalars.of(Date.class).getCoercing(); - try { - // given - Coercing subject = JavaScalars.of(Date.class).getCoercing(); + // when + Object result = subject.serialize(Date.from(Instant.EPOCH)); - // when - Object result = subject.parseValue(Date.from(Instant.EPOCH)); + // then + assertThat(result).asString().isEqualTo("1970-01-01T00:00:00Z"); + + // when + result = subject.serialize(Date.from(Instant.parse("1970-01-01T00:00:00.000Z"))); + + // then + assertThat(result).asString().isEqualTo("1970-01-01T00:00:00Z"); + + // when + result = subject.serialize(Date.from(Instant.parse("1970-01-01T00:00:00.001Z"))); - // then - assertThat(result).isEqualTo("1970-01-01T00:00:00.000Z"); - } finally { - TimeZone.setDefault(timeZone); - } + // then + assertThat(result).asString().isEqualTo("1970-01-01T00:00:00.001Z"); } } diff --git a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-model/src/main/java/org/activiti/cloud/services/query/model/AbstractVariableEntity.java b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-model/src/main/java/org/activiti/cloud/services/query/model/AbstractVariableEntity.java index d5b9455f6cd..b326ec0b4f6 100644 --- a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-model/src/main/java/org/activiti/cloud/services/query/model/AbstractVariableEntity.java +++ b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-model/src/main/java/org/activiti/cloud/services/query/model/AbstractVariableEntity.java @@ -15,6 +15,8 @@ */ package org.activiti.cloud.services.query.model; +import static jakarta.persistence.TemporalType.TIMESTAMP; + import com.fasterxml.jackson.annotation.JsonIgnore; import jakarta.persistence.Basic; import jakarta.persistence.Column; @@ -24,6 +26,7 @@ import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; import jakarta.persistence.MappedSuperclass; +import jakarta.persistence.Temporal; import java.util.Date; import java.util.Objects; import org.activiti.cloud.api.model.shared.CloudVariableInstance; @@ -37,9 +40,11 @@ public abstract class AbstractVariableEntity extends ActivitiEntityMetadata impl private String name; @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) + @Temporal(TIMESTAMP) private Date createTime; @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) + @Temporal(TIMESTAMP) private Date lastUpdatedTime; private String executionId; diff --git a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-model/src/main/java/org/activiti/cloud/services/query/model/BPMNSequenceFlowEntity.java b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-model/src/main/java/org/activiti/cloud/services/query/model/BPMNSequenceFlowEntity.java index fef4723747e..ad020e21405 100644 --- a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-model/src/main/java/org/activiti/cloud/services/query/model/BPMNSequenceFlowEntity.java +++ b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-model/src/main/java/org/activiti/cloud/services/query/model/BPMNSequenceFlowEntity.java @@ -15,7 +15,14 @@ */ package org.activiti.cloud.services.query.model; -import jakarta.persistence.*; +import static jakarta.persistence.TemporalType.TIMESTAMP; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Index; +import jakarta.persistence.Table; +import jakarta.persistence.Temporal; import java.util.Date; import java.util.Objects; import org.activiti.api.process.model.BPMNSequenceFlow; @@ -52,6 +59,7 @@ public class BPMNSequenceFlowEntity extends ActivitiEntityMetadata implements BP /** The date/time of the sequence flow was taken */ @Column(name = "taken_date") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) + @Temporal(TIMESTAMP) private Date date; /** The XML tag of the source activity as in the process file */ diff --git a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-model/src/main/java/org/activiti/cloud/services/query/model/BaseBPMNActivityEntity.java b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-model/src/main/java/org/activiti/cloud/services/query/model/BaseBPMNActivityEntity.java index d13da822c1f..cada01e4a84 100644 --- a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-model/src/main/java/org/activiti/cloud/services/query/model/BaseBPMNActivityEntity.java +++ b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-model/src/main/java/org/activiti/cloud/services/query/model/BaseBPMNActivityEntity.java @@ -15,10 +15,13 @@ */ package org.activiti.cloud.services.query.model; +import static jakarta.persistence.TemporalType.TIMESTAMP; + import jakarta.persistence.EnumType; import jakarta.persistence.Enumerated; import jakarta.persistence.Id; import jakarta.persistence.MappedSuperclass; +import jakarta.persistence.Temporal; import java.util.Date; import java.util.Objects; import org.activiti.cloud.api.process.model.CloudBPMNActivity.BPMNActivityStatus; @@ -54,12 +57,15 @@ public abstract class BaseBPMNActivityEntity extends ActivitiEntityMetadata { private BPMNActivityStatus status; @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) + @Temporal(TIMESTAMP) private Date startedDate; @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) + @Temporal(TIMESTAMP) private Date completedDate; @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) + @Temporal(TIMESTAMP) private Date cancelledDate; /** The associated process definition key of the activity as in the process file */ diff --git a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-model/src/main/java/org/activiti/cloud/services/query/model/IntegrationContextEntity.java b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-model/src/main/java/org/activiti/cloud/services/query/model/IntegrationContextEntity.java index 4c06d402805..a2e74f4b4fb 100644 --- a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-model/src/main/java/org/activiti/cloud/services/query/model/IntegrationContextEntity.java +++ b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-model/src/main/java/org/activiti/cloud/services/query/model/IntegrationContextEntity.java @@ -15,6 +15,8 @@ */ package org.activiti.cloud.services.query.model; +import static jakarta.persistence.TemporalType.TIMESTAMP; + import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat.Shape; import com.fasterxml.jackson.annotation.JsonIgnore; @@ -31,6 +33,7 @@ import jakarta.persistence.MapsId; import jakarta.persistence.OneToOne; import jakarta.persistence.Table; +import jakarta.persistence.Temporal; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -90,12 +93,15 @@ public class IntegrationContextEntity extends ActivitiEntityMetadata implements private String connectorType; @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) + @Temporal(TIMESTAMP) private Date requestDate; @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) + @Temporal(TIMESTAMP) private Date resultDate; @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) + @Temporal(TIMESTAMP) private Date errorDate; private String errorCode; diff --git a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-model/src/main/java/org/activiti/cloud/services/query/model/ProcessInstanceEntity.java b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-model/src/main/java/org/activiti/cloud/services/query/model/ProcessInstanceEntity.java index 9de4890a13e..7417eabe04f 100644 --- a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-model/src/main/java/org/activiti/cloud/services/query/model/ProcessInstanceEntity.java +++ b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-model/src/main/java/org/activiti/cloud/services/query/model/ProcessInstanceEntity.java @@ -15,6 +15,8 @@ */ package org.activiti.cloud.services.query.model; +import static jakarta.persistence.TemporalType.TIMESTAMP; + import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonView; import com.querydsl.core.annotations.PropertyType; @@ -33,6 +35,7 @@ import jakarta.persistence.NamedSubgraph; import jakarta.persistence.OneToMany; import jakarta.persistence.Table; +import jakarta.persistence.Temporal; import jakarta.persistence.Transient; import java.util.Date; import java.util.LinkedHashSet; @@ -81,6 +84,7 @@ public class ProcessInstanceEntity extends ActivitiEntityMetadata implements Clo private String initiator; @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) + @Temporal(TIMESTAMP) private Date startDate; private String businessKey; @@ -92,30 +96,37 @@ public class ProcessInstanceEntity extends ActivitiEntityMetadata implements Clo private String processDefinitionName; @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) + @Temporal(TIMESTAMP) private Date completedDate; @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) + @Temporal(TIMESTAMP) private Date suspendedDate; @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) + @Temporal(TIMESTAMP) private Date lastModified; @JsonIgnore @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) + @Temporal(TIMESTAMP) private Date lastModifiedTo; @JsonIgnore @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) + @Temporal(TIMESTAMP) private Date lastModifiedFrom; @JsonIgnore @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) @QueryType(PropertyType.DATETIME) + @Temporal(TIMESTAMP) private Date startFrom; @JsonIgnore @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) @QueryType(PropertyType.DATETIME) + @Temporal(TIMESTAMP) private Date startTo; @JsonIgnore diff --git a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-model/src/main/java/org/activiti/cloud/services/query/model/TaskEntity.java b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-model/src/main/java/org/activiti/cloud/services/query/model/TaskEntity.java index 5127dbd7953..8c71f3c4efb 100644 --- a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-model/src/main/java/org/activiti/cloud/services/query/model/TaskEntity.java +++ b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-model/src/main/java/org/activiti/cloud/services/query/model/TaskEntity.java @@ -15,6 +15,8 @@ */ package org.activiti.cloud.services.query.model; +import static jakarta.persistence.TemporalType.TIMESTAMP; + import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonView; import com.querydsl.core.annotations.PropertyType; @@ -34,6 +36,7 @@ import jakarta.persistence.ManyToOne; import jakarta.persistence.OneToMany; import jakarta.persistence.Table; +import jakarta.persistence.Temporal; import jakarta.persistence.Transient; import java.io.Serializable; import java.util.Collections; @@ -81,12 +84,15 @@ public class TaskEntity extends ActivitiEntityMetadata implements QueryCloudTask private String description; @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) + @Temporal(TIMESTAMP) private Date createdDate; @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) + @Temporal(TIMESTAMP) private Date dueDate; @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) + @Temporal(TIMESTAMP) private Date claimedDate; private int priority; @@ -111,50 +117,61 @@ public class TaskEntity extends ActivitiEntityMetadata implements QueryCloudTask private Long duration; @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) + @Temporal(TIMESTAMP) private Date lastModified; @JsonIgnore @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) + @Temporal(TIMESTAMP) private Date createdTo; @JsonIgnore @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) + @Temporal(TIMESTAMP) private Date createdFrom; @JsonIgnore @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) + @Temporal(TIMESTAMP) private Date lastModifiedTo; @JsonIgnore @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) + @Temporal(TIMESTAMP) private Date lastModifiedFrom; @JsonIgnore @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) + @Temporal(TIMESTAMP) private Date lastClaimedTo; @JsonIgnore @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) + @Temporal(TIMESTAMP) private Date lastClaimedFrom; @JsonIgnore @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) + @Temporal(TIMESTAMP) private Date completedTo; @JsonIgnore @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) + @Temporal(TIMESTAMP) private Date completedFrom; @JsonIgnore @Transient @QueryType(PropertyType.DATETIME) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) + @Temporal(TIMESTAMP) private Date dueDateTo; @JsonIgnore @Transient @QueryType(PropertyType.DATETIME) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) + @Temporal(TIMESTAMP) private Date dueDateFrom; @JsonIgnore diff --git a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-repo/src/main/java/org/activiti/cloud/services/query/app/repository/CustomizedTaskRepositoryImpl.java b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-repo/src/main/java/org/activiti/cloud/services/query/app/repository/CustomizedTaskRepositoryImpl.java index edf14446d69..98079207f24 100644 --- a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-repo/src/main/java/org/activiti/cloud/services/query/app/repository/CustomizedTaskRepositoryImpl.java +++ b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-repo/src/main/java/org/activiti/cloud/services/query/app/repository/CustomizedTaskRepositoryImpl.java @@ -52,7 +52,7 @@ public Page findByVariableNameAndValue( Predicate condition = variableEntity.name .eq(name) - .and(Expressions.booleanTemplate("{0} like {1}", variableEntity.value, value)); + .and(Expressions.booleanTemplate("{0} = {1}", variableEntity.value, value)); JPQLQuery from = from(taskEntity) .innerJoin(taskEntity.variables, variableEntity) diff --git a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/pom.xml b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/pom.xml index a7160262c62..aab7fedda5b 100644 --- a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/pom.xml +++ b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/pom.xml @@ -235,6 +235,12 @@ spring-security-test test + + org.activiti.cloud + activiti-cloud-services-query-liquibase + test + + diff --git a/activiti-cloud-query-service/pom.xml b/activiti-cloud-query-service/pom.xml index f2c8d836823..207d7a0a859 100644 --- a/activiti-cloud-query-service/pom.xml +++ b/activiti-cloud-query-service/pom.xml @@ -18,7 +18,7 @@ activiti-cloud-starter-query - 8.2.0-alpha.12 + 8.2.0-alpha.13 diff --git a/activiti-cloud-runtime-bundle-service/activiti-cloud-starter-runtime-bundle/src/test/java/org/activiti/cloud/starter/tests/helper/TaskRestTemplate.java b/activiti-cloud-runtime-bundle-service/activiti-cloud-starter-runtime-bundle/src/test/java/org/activiti/cloud/starter/tests/helper/TaskRestTemplate.java index e2904898966..6df4139958e 100644 --- a/activiti-cloud-runtime-bundle-service/activiti-cloud-starter-runtime-bundle/src/test/java/org/activiti/cloud/starter/tests/helper/TaskRestTemplate.java +++ b/activiti-cloud-runtime-bundle-service/activiti-cloud-starter-runtime-bundle/src/test/java/org/activiti/cloud/starter/tests/helper/TaskRestTemplate.java @@ -92,7 +92,7 @@ private ResponseEntity complete(Task task, String baseURL, CompleteTa : new HttpEntity<>(CONTENT_TYPE_HEADER), TASK_RESPONSE_TYPE ); - assertThat(responseEntity.getStatusCodeValue()).isEqualTo(HttpStatus.OK.value()); + assertThat(responseEntity.getStatusCode().value()).isEqualTo(HttpStatus.OK.value()); return responseEntity; } @@ -111,7 +111,7 @@ private ResponseEntity delete(Task task, String taskVarRelativeUrl) { null, TASK_RESPONSE_TYPE ); - assertThat(responseEntity.getStatusCodeValue()).isEqualTo(HttpStatus.OK.value()); + assertThat(responseEntity.getStatusCode().value()).isEqualTo(HttpStatus.OK.value()); return responseEntity; } diff --git a/activiti-cloud-runtime-bundle-service/activiti-cloud-starter-runtime-bundle/src/test/java/org/activiti/cloud/starter/tests/runtime/TasksIT.java b/activiti-cloud-runtime-bundle-service/activiti-cloud-starter-runtime-bundle/src/test/java/org/activiti/cloud/starter/tests/runtime/TasksIT.java index f6b24544426..752c7d48a4e 100644 --- a/activiti-cloud-runtime-bundle-service/activiti-cloud-starter-runtime-bundle/src/test/java/org/activiti/cloud/starter/tests/runtime/TasksIT.java +++ b/activiti-cloud-runtime-bundle-service/activiti-cloud-starter-runtime-bundle/src/test/java/org/activiti/cloud/starter/tests/runtime/TasksIT.java @@ -348,7 +348,7 @@ public void shouldBeAbleToDeleteTask() { ResponseEntity delete = taskRestTemplate.delete(standaloneTask); //then - assertThat(delete.getStatusCodeValue()).isEqualTo(HttpStatus.OK.value()); + assertThat(delete.getStatusCode().value()).isEqualTo(HttpStatus.OK.value()); } @Test @@ -362,7 +362,7 @@ public void adminShouldBeAbleToDeleteTask() { ResponseEntity delete = taskRestTemplate.adminDelete(standaloneTask); //then - assertThat(delete.getStatusCodeValue()).isEqualTo(HttpStatus.OK.value()); + assertThat(delete.getStatusCode().value()).isEqualTo(HttpStatus.OK.value()); } @Test @@ -447,7 +447,7 @@ public void shouldCompleteATask() { ResponseEntity responseEntity = taskRestTemplate.complete(task); //then - assertThat(responseEntity.getStatusCodeValue()).isEqualTo(HttpStatus.OK.value()); + assertThat(responseEntity.getStatusCode().value()).isEqualTo(HttpStatus.OK.value()); } @Test @@ -463,7 +463,7 @@ public void adminShouldCompleteATask() { ResponseEntity responseEntity = taskRestTemplate.adminComplete(task); //then - assertThat(responseEntity.getStatusCodeValue()).isEqualTo(HttpStatus.OK.value()); + assertThat(responseEntity.getStatusCode().value()).isEqualTo(HttpStatus.OK.value()); } @Test @@ -485,7 +485,7 @@ public void shouldCompleteATaskPassingInputVariables() { ResponseEntity responseEntity = taskRestTemplate.complete(task, completeTaskPayload); //then - assertThat(responseEntity.getStatusCodeValue()).isEqualTo(HttpStatus.OK.value()); + assertThat(responseEntity.getStatusCode().value()).isEqualTo(HttpStatus.OK.value()); } @Test @@ -722,7 +722,7 @@ public void shouldSaveATask() throws Exception { ResponseEntity responseEntity = taskRestTemplate.save(task, saveTaskPayload); //then - assertThat(responseEntity.getStatusCodeValue()).isEqualTo(HttpStatus.OK.value()); + assertThat(responseEntity.getStatusCode().value()).isEqualTo(HttpStatus.OK.value()); // when ResponseEntity> variablesResponse = taskRestTemplate.getVariables( @@ -759,7 +759,7 @@ public void shouldNotSaveATaskWithEmptyPayload() { ResponseEntity responseEntity = taskRestTemplate.save(task, saveTaskPayload); //then - assertThat(responseEntity.getStatusCodeValue()).isEqualTo(HttpStatus.BAD_REQUEST.value()); + assertThat(responseEntity.getStatusCode().value()).isEqualTo(HttpStatus.BAD_REQUEST.value()); // cleanup processInstanceRestTemplate.delete(processInstanceEntity); diff --git a/activiti-cloud-runtime-bundle-service/pom.xml b/activiti-cloud-runtime-bundle-service/pom.xml index 7de6750e5a7..87ac00aff3d 100644 --- a/activiti-cloud-runtime-bundle-service/pom.xml +++ b/activiti-cloud-runtime-bundle-service/pom.xml @@ -18,7 +18,7 @@ activiti-cloud-starter-runtime-bundle-it - 8.2.0-alpha.12 + 8.2.0-alpha.13 1.5 diff --git a/activiti-cloud-service-common/activiti-cloud-services-common-security/src/main/java/org/activiti/cloud/security/authorization/AuthorizationConfigurer.java b/activiti-cloud-service-common/activiti-cloud-services-common-security/src/main/java/org/activiti/cloud/security/authorization/AuthorizationConfigurer.java index 3c5a46d063e..c638960bab4 100644 --- a/activiti-cloud-service-common/activiti-cloud-services-common-security/src/main/java/org/activiti/cloud/security/authorization/AuthorizationConfigurer.java +++ b/activiti-cloud-service-common/activiti-cloud-services-common-security/src/main/java/org/activiti/cloud/security/authorization/AuthorizationConfigurer.java @@ -16,6 +16,7 @@ package org.activiti.cloud.security.authorization; import static java.util.function.Predicate.not; +import static org.springframework.security.config.Customizer.withDefaults; import jakarta.annotation.PostConstruct; import java.util.ArrayList; @@ -78,7 +79,7 @@ public void configure(HttpSecurity http) throws Exception { String[] roles = securityConstraint.getAuthRoles(); configureAuthorization(http, roles, securityConstraint.getSecurityCollections()); } - http.anonymous(); + http.anonymous(withDefaults()); } private void configureAuthorization(HttpSecurity http, String[] roles, SecurityCollection[] securityCollection) @@ -106,10 +107,10 @@ private void buildAntMatchers( if (isNotEmpty(securityCollection.getOmittedMethods())) { List methods = getAllowedMethods(securityCollection.getOmittedMethods()); for (HttpMethod method : methods) { - f.accept(http.authorizeHttpRequests().requestMatchers(method, patterns)); + http.authorizeHttpRequests(spec -> f.accept(spec.requestMatchers(method, patterns))); } } else { - f.accept(http.authorizeHttpRequests().requestMatchers(patterns)); + http.authorizeHttpRequests(spec -> f.accept(spec.requestMatchers(patterns))); } } } @@ -144,7 +145,7 @@ private String[] getPatterns(String[] patterns) { } private List getAllowedMethods(String[] omittedMethods) { - List httpMethods = Stream.of(omittedMethods).map(HttpMethod::resolve).collect(Collectors.toList()); + List httpMethods = Stream.of(omittedMethods).map(HttpMethod::valueOf).toList(); return Stream.of(HttpMethod.values()).filter(not(httpMethods::contains)).collect(Collectors.toList()); } diff --git a/activiti-cloud-service-common/activiti-cloud-services-common-security/src/main/java/org/activiti/cloud/services/common/security/config/CommonSecurityAutoConfiguration.java b/activiti-cloud-service-common/activiti-cloud-services-common-security/src/main/java/org/activiti/cloud/services/common/security/config/CommonSecurityAutoConfiguration.java index 74e12c9d306..8dc78ff9225 100644 --- a/activiti-cloud-service-common/activiti-cloud-services-common-security/src/main/java/org/activiti/cloud/services/common/security/config/CommonSecurityAutoConfiguration.java +++ b/activiti-cloud-service-common/activiti-cloud-services-common-security/src/main/java/org/activiti/cloud/services/common/security/config/CommonSecurityAutoConfiguration.java @@ -206,32 +206,22 @@ public RequestInterceptor tokenRelayRequestInterceptor(SecurityContextTokenProvi public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { authorizationConfigurer.configure(http); return http - .authorizeHttpRequests() - .requestMatchers(actuatorEndpointsMatcher()) - .authenticated() - .and() - .authorizeHttpRequests() - .anyRequest() - .permitAll() - .and() - .cors() - .configurationSource(request -> { - CorsConfiguration corsConfiguration = new CorsConfiguration(); - corsConfiguration.setAllowedMethods(List.of("GET", "HEAD", "OPTION", "POST", "PUT", "DELETE")); - corsConfiguration.setAllowedOrigins(allowedOrigins); - return corsConfiguration.applyPermitDefaultValues(); - }) - .and() - .exceptionHandling() - .accessDeniedHandler(new CustomBearerTokenAccessDeniedHandler(new BearerTokenAccessDeniedHandler())) - .and() - .httpBasic() - .disable() - .oauth2ResourceServer() - .jwt() - .jwtAuthenticationConverter(jwtAuthenticationConverter) - .and() - .and() + .authorizeHttpRequests(spec -> + spec.requestMatchers(actuatorEndpointsMatcher()).authenticated().anyRequest().permitAll() + ) + .cors(spec -> + spec.configurationSource(request -> { + CorsConfiguration corsConfiguration = new CorsConfiguration(); + corsConfiguration.setAllowedMethods(List.of("GET", "HEAD", "OPTION", "POST", "PUT", "DELETE")); + corsConfiguration.setAllowedOrigins(allowedOrigins); + return corsConfiguration.applyPermitDefaultValues(); + }) + ) + .exceptionHandling(spec -> + spec.accessDeniedHandler(new CustomBearerTokenAccessDeniedHandler(new BearerTokenAccessDeniedHandler())) + ) + .httpBasic(spec -> spec.disable()) + .oauth2ResourceServer(spec -> spec.jwt(jwt -> jwt.jwtAuthenticationConverter(jwtAuthenticationConverter))) .build(); } diff --git a/activiti-cloud-service-common/activiti-cloud-services-common-security/src/test/java/org/activiti/cloud/security/authorization/AuthorizationConfigurerTest.java b/activiti-cloud-service-common/activiti-cloud-services-common-security/src/test/java/org/activiti/cloud/security/authorization/AuthorizationConfigurerTest.java index b200a8f02a1..a3133becee1 100644 --- a/activiti-cloud-service-common/activiti-cloud-services-common-security/src/test/java/org/activiti/cloud/security/authorization/AuthorizationConfigurerTest.java +++ b/activiti-cloud-service-common/activiti-cloud-services-common-security/src/test/java/org/activiti/cloud/security/authorization/AuthorizationConfigurerTest.java @@ -16,7 +16,8 @@ package org.activiti.cloud.security.authorization; import static java.util.Arrays.asList; -import static org.mockito.Mockito.any; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.eq; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.when; @@ -30,10 +31,13 @@ import org.activiti.cloud.security.authorization.AuthorizationProperties.SecurityConstraint; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.ArgumentCaptor; +import org.mockito.Captor; import org.mockito.InOrder; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.http.HttpMethod; +import org.springframework.security.config.Customizer; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configurers.AuthorizeHttpRequestsConfigurer; @@ -49,6 +53,12 @@ class AuthorizationConfigurerTest { @Mock private AuthorizeHttpRequestsConfigurer.AuthorizedUrl authorizedUrl; + @Captor + private ArgumentCaptor.AuthorizationManagerRequestMatcherRegistry>> authorizeHttpRequestsCustomizer; + + @Captor + private ArgumentCaptor requestMatchers; + @Test public void should_configureAuth_when_everythingIsAuthenticated() throws Exception { AuthorizationProperties authorizationProperties = new AuthorizationProperties(); @@ -60,11 +70,14 @@ public void should_configureAuth_when_everythingIsAuthenticated() throws Excepti ); AuthorizationConfigurer authorizationConfigurer = new AuthorizationConfigurer(authorizationProperties, null); - when(http.authorizeHttpRequests()).thenReturn(authorizeRequests); - when(authorizeRequests.requestMatchers(any(String[].class))).thenReturn(authorizedUrl); + when(http.authorizeHttpRequests(authorizeHttpRequestsCustomizer.capture())).thenReturn(http); + when(authorizeRequests.requestMatchers(requestMatchers.capture())).thenReturn(authorizedUrl); authorizationConfigurer.configure(http); + assertThat(authorizeHttpRequestsCustomizer.getAllValues()).hasSize(2); + authorizeHttpRequestsCustomizer.getAllValues().forEach($ -> $.customize(authorizeRequests)); + InOrder inOrder = inOrder(authorizeRequests, authorizedUrl); inOrder.verify(authorizeRequests).requestMatchers(eq("/c")); @@ -85,11 +98,14 @@ public void should_configureAuth_when_aURLiSPublic() throws Exception { ); AuthorizationConfigurer authorizationConfigurer = new AuthorizationConfigurer(authorizationProperties, null); - when(http.authorizeHttpRequests()).thenReturn(authorizeRequests); - when(authorizeRequests.requestMatchers(any(String.class))).thenReturn(authorizedUrl); + when(http.authorizeHttpRequests(authorizeHttpRequestsCustomizer.capture())).thenReturn(http); + when(authorizeRequests.requestMatchers(requestMatchers.capture())).thenReturn(authorizedUrl); authorizationConfigurer.configure(http); + assertThat(authorizeHttpRequestsCustomizer.getAllValues()).hasSize(2); + authorizeHttpRequestsCustomizer.getAllValues().forEach($ -> $.customize(authorizeRequests)); + InOrder inOrder = inOrder(authorizeRequests, authorizedUrl); //URLs with permitAll must be defined first in order to avoid being overridden @@ -114,11 +130,14 @@ public void should_configureAuth_when_everythingIsAuthenticatedMethods() throws ); AuthorizationConfigurer authorizationConfigurer = new AuthorizationConfigurer(authorizationProperties, null); - when(http.authorizeHttpRequests()).thenReturn(authorizeRequests); + when(http.authorizeHttpRequests(authorizeHttpRequestsCustomizer.capture())).thenReturn(http); when(authorizeRequests.requestMatchers(any(HttpMethod.class), any(String.class))).thenReturn(authorizedUrl); authorizationConfigurer.configure(http); + assertThat(authorizeHttpRequestsCustomizer.getAllValues()).hasSize(5); + authorizeHttpRequestsCustomizer.getAllValues().forEach($ -> $.customize(authorizeRequests)); + InOrder inOrder = inOrder(authorizeRequests, authorizedUrl); inOrder.verify(authorizeRequests).requestMatchers(eq(GET), eq("/c")); diff --git a/activiti-cloud-service-common/activiti-cloud-services-dbp-rest/src/main/java/org/activiti/cloud/alfresco/config/AlfrescoWebAutoConfiguration.java b/activiti-cloud-service-common/activiti-cloud-services-dbp-rest/src/main/java/org/activiti/cloud/alfresco/config/AlfrescoWebAutoConfiguration.java index 5f03c76d553..1d9cf1d7652 100644 --- a/activiti-cloud-service-common/activiti-cloud-services-dbp-rest/src/main/java/org/activiti/cloud/alfresco/config/AlfrescoWebAutoConfiguration.java +++ b/activiti-cloud-service-common/activiti-cloud-services-dbp-rest/src/main/java/org/activiti/cloud/alfresco/config/AlfrescoWebAutoConfiguration.java @@ -41,7 +41,6 @@ import org.springframework.http.MediaType; import org.springframework.http.converter.HttpMessageConverter; import org.springframework.web.method.support.HandlerMethodArgumentResolver; -import org.springframework.web.servlet.config.annotation.PathMatchConfigurer; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.util.UriComponents; @@ -49,9 +48,6 @@ @PropertySource("classpath:config/alfresco-rest-config.properties") public class AlfrescoWebAutoConfiguration implements WebMvcConfigurer { - @Value("${SPRING_MVC_REST_USE_TRAILING_SLASH_MATCH:false}") - private boolean useTrailingSlashMatch; - private final PageableHandlerMethodArgumentResolver pageableHandlerMethodArgumentResolver; private final int defaultPageSize; @@ -63,11 +59,6 @@ public AlfrescoWebAutoConfiguration( this.defaultPageSize = defaultPageSize; } - @Override - public void configurePathMatch(PathMatchConfigurer configurer) { - configurer.setUseTrailingSlashMatch(useTrailingSlashMatch); - } - @Override public void addArgumentResolvers(List resolvers) { resolvers.add( diff --git a/activiti-cloud-service-common/activiti-cloud-services-dbp-rest/src/test/java/org/activiti/cloud/alfresco/filter/TrailingSlashRedirectFilterTest.java b/activiti-cloud-service-common/activiti-cloud-services-dbp-rest/src/test/java/org/activiti/cloud/alfresco/filter/TrailingSlashRedirectFilterTest.java index 2fcfadc6384..c4601f3422f 100644 --- a/activiti-cloud-service-common/activiti-cloud-services-dbp-rest/src/test/java/org/activiti/cloud/alfresco/filter/TrailingSlashRedirectFilterTest.java +++ b/activiti-cloud-service-common/activiti-cloud-services-dbp-rest/src/test/java/org/activiti/cloud/alfresco/filter/TrailingSlashRedirectFilterTest.java @@ -28,10 +28,7 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.web.servlet.MockMvc; -@SpringBootTest( - webEnvironment = SpringBootTest.WebEnvironment.MOCK, - properties = "SPRING_MVC_REST_USE_TRAILING_SLASH_MATCH=true" -) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.MOCK) @AutoConfigureMockMvc class TrailingSlashRedirectFilterTest { @@ -61,18 +58,14 @@ void testGreetingWithRequestParams() throws Exception { @Test void testGreetingTrailingSlashWithFilter() throws Exception { - mvc - .perform(get(BASEURL + "/greeting/").accept(APPLICATION_JSON_VALUE)) - .andExpect(status().isOk()) - .andExpect(content().string("Hello, World!")); + mvc.perform(get(BASEURL + "/greeting/").accept(APPLICATION_JSON_VALUE)).andExpect(status().isNotFound()); } @Test void testGreetingTrailingSlashAndRequestQueryParameter() throws Exception { mvc .perform(get(BASEURL + "/greeting/?query=Bar").accept(APPLICATION_JSON_VALUE)) - .andExpect(status().isOk()) - .andExpect(content().string("Hello, Bar!")); + .andExpect(status().isNotFound()); } @Test diff --git a/activiti-cloud-service-common/pom.xml b/activiti-cloud-service-common/pom.xml index c40910f2c90..345bfd1f3b4 100644 --- a/activiti-cloud-service-common/pom.xml +++ b/activiti-cloud-service-common/pom.xml @@ -34,7 +34,7 @@ activiti-cloud-service-messaging-starter - 8.2.0-alpha.12 + 8.2.0-alpha.13 1.9.4 1.10 2.6 diff --git a/pom.xml b/pom.xml index b6794994d95..edd46c551ba 100644 --- a/pom.xml +++ b/pom.xml @@ -196,7 +196,7 @@ activiti-cloud 2020 - 3.1.6 + 3.2.0 ${project.build.directory}/generated-test-sources/assertions