diff --git a/docs/Configuration-Properties.md b/docs/Configuration-Properties.md index 65111fe3c..cd1c9857c 100644 --- a/docs/Configuration-Properties.md +++ b/docs/Configuration-Properties.md @@ -106,8 +106,9 @@ In certain scenarios, repeatedly attempting to dispatch callback events may be p receiver's side. To address this, if multiple callback events with the same configuration fail consecutively, the service temporarily halts further dispatch attempts and marks these events as failed without retrying. The number of consecutive failures allowed before stopping dispatch is defined by the `failureThreshold` property, while the halt -period is configurable via the `resetTimeout` property. After this period, a callback dispatch attempt will be made again -to check the receiver's availability. +period is configurable via the `failureResetTimeout` property. After this period, a callback dispatch attempt will be +made again to check the receiver's availability. If the `failureThreshold` is set to `-1`, the functionality is not +enabled. PowerAuth dispatches a callback as soon as a change in operation or activation status is detected. Each newly created callback is passed to a configurable thread pool executor for dispatch. Even if the thread pool's queue is full, the @@ -132,8 +133,8 @@ to callback events with max attempts set to 1, such callback events are never sc | `powerauth.service.callbacks.threadPoolMaxSize` | `2` | Maximum number of threads in the thread pool used by the executor. | | `powerauth.service.callbacks.threadPoolQueueCapacity` | `1000` | Queue capacity of the thread pool used by the executor. | | `powerauth.service.callbacks.forceRerunPeriod` | | Time period after which a currently processed callback event is considered stale and should be scheduled to rerun. | -| `powerauth.service.callbacks.failureThreshold` | `200` | The number of consecutive failures allowed for callback events with the same configuration. | -| `powerauth.service.callbacks.resetTimeout` | `60s` | Time period after which a Callback URL Event will be dispatched, even if failure threshold has been reached. | +| `powerauth.service.callbacks.failureThreshold` | `200` | The number of consecutive failures allowed for callback events with the same configuration. If set to `-1`, unlimited number of failures is allowed. | +| `powerauth.service.callbacks.failureResetTimeout` | `60s` | Time period after which a Callback URL Event will be dispatched, even if failure threshold has been reached. | | `powerauth.service.callbacks.clients.cache.refreshAfterWrite` | `5m` | Callback REST clients are cached and automatically evicted if updated through the Callback Management API on a single node. Time-based refreshing mechanism is a fallback in clustered environments. | The backoff period after the `N-th` attempt is calculated as follows: diff --git a/docs/Database-Structure.md b/docs/Database-Structure.md index 075c967ed..51267d0fc 100644 --- a/docs/Database-Structure.md +++ b/docs/Database-Structure.md @@ -185,8 +185,6 @@ Stores callback URLs - per-application endpoints that are notified whenever an a | max_attempts | INTEGER | - | Maximum number of attempts to dispatch a callback. | | initial_backoff | VARCHAR(64) | - | Initial backoff period before the next send attempt, stored as a ISO 8601 string. | | retention_period | VARCHAR(64) | - | Minimal duration for which is a completed callback event persisted, stored as a ISO 8601 string. | -| timestamp_last_failure | DATETIME | - | The timestamp of the most recent failed callback event associated with this configuration. | -| failure_count | INTEGER | DEFAULT 0 NOT NULL | The number of consecutive failed callback events associated with this configuration. | | enabled | BOOLEAN | - | Indicator specifying whether the Callback URL should be used. | | timestamp_created | DATETIME | DEFAULT NOW() NOT NULL | Timestamp when the record was created. | | timestamp_last_updated | DATETIME | - | Timestamp of the last update of the record via the Callback Management API. | diff --git a/docs/PowerAuth-Server-1.9.0.md b/docs/PowerAuth-Server-1.9.0.md index 0b9b546ee..f623f8478 100644 --- a/docs/PowerAuth-Server-1.9.0.md +++ b/docs/PowerAuth-Server-1.9.0.md @@ -55,13 +55,6 @@ options for the retry strategy with an exponential backoff algorithm. Namely: These settings at the individual callback level overrides the global default settings at the application level. -### Add Columns to Enable Callback Failures Monitoring - -Following columns has been added to the `pa_application_callback` table to enable monitoring of callback dispatch -failures: -- `failure_count` to hold the number of consecutive failed callbacks of the same configuration, and -- `timestamp_last_failure` to store the timestamp of the most recent failed callback attempt. - ### Add Column Indicating If a Callback Is Enabled A new column `enabled` has been added to the `pa_application_callback` table to indicate whether a Callback URL is diff --git a/docs/db/changelog/changesets/powerauth-java-server/1.9.x/20240704-callback-event-table.xml b/docs/db/changelog/changesets/powerauth-java-server/1.9.x/20240704-callback-event-table.xml index 1e533f2c6..e396769b2 100644 --- a/docs/db/changelog/changesets/powerauth-java-server/1.9.x/20240704-callback-event-table.xml +++ b/docs/db/changelog/changesets/powerauth-java-server/1.9.x/20240704-callback-event-table.xml @@ -110,32 +110,6 @@ - - - - - - - Add timestamp_last_failure column to pa_application_callback table. - - - - - - - - - - - - Add failure_count column to pa_application_callback table. - - - - - - - diff --git a/docs/images/arch_db_structure.png b/docs/images/arch_db_structure.png index e36ae7366..b74f6670f 100644 Binary files a/docs/images/arch_db_structure.png and b/docs/images/arch_db_structure.png differ diff --git a/docs/sql/mssql/migration_1.8.0_1.9.0.sql b/docs/sql/mssql/migration_1.8.0_1.9.0.sql index 41ba0168a..c0a960ed6 100644 --- a/docs/sql/mssql/migration_1.8.0_1.9.0.sql +++ b/docs/sql/mssql/migration_1.8.0_1.9.0.sql @@ -58,16 +58,6 @@ GO CREATE SEQUENCE pa_app_callback_event_seq START WITH 1 INCREMENT BY 50; GO --- Changeset powerauth-java-server/1.9.x/20240704-callback-event-table.xml::8::Jan Pesek --- Add timestamp_last_failure column to pa_application_callback table. -ALTER TABLE pa_application_callback ADD timestamp_last_failure datetime2(6); -GO - --- Changeset powerauth-java-server/1.9.x/20240704-callback-event-table.xml::9::Jan Pesek --- Add failure_count column to pa_application_callback table. -ALTER TABLE pa_application_callback ADD failure_count int CONSTRAINT DF_pa_application_callback_failure_count DEFAULT 0 NOT NULL; -GO - -- Changeset powerauth-java-server/1.9.x/20240704-callback-event-table.xml::10::Jan Pesek -- Add enabled column to pa_application_callback table. ALTER TABLE pa_application_callback ADD enabled bit CONSTRAINT DF_pa_application_callback_enabled DEFAULT 1 NOT NULL; diff --git a/docs/sql/oracle/migration_1.8.0_1.9.0.sql b/docs/sql/oracle/migration_1.8.0_1.9.0.sql index 8b31ab505..f0ae2b354 100644 --- a/docs/sql/oracle/migration_1.8.0_1.9.0.sql +++ b/docs/sql/oracle/migration_1.8.0_1.9.0.sql @@ -46,14 +46,6 @@ CREATE INDEX pa_app_cb_event_ts_del_idx ON pa_application_callback_event(timesta -- Create a new sequence pa_app_callback_event_seq CREATE SEQUENCE pa_app_callback_event_seq START WITH 1 INCREMENT BY 50 CACHE 20; --- Changeset powerauth-java-server/1.9.x/20240704-callback-event-table.xml::8::Jan Pesek --- Add timestamp_last_failure column to pa_application_callback table. -ALTER TABLE pa_application_callback ADD timestamp_last_failure TIMESTAMP(6); - --- Changeset powerauth-java-server/1.9.x/20240704-callback-event-table.xml::9::Jan Pesek --- Add failure_count column to pa_application_callback table. -ALTER TABLE pa_application_callback ADD failure_count INTEGER DEFAULT 0 NOT NULL; - -- Changeset powerauth-java-server/1.9.x/20240704-callback-event-table.xml::10::Jan Pesek -- Add enabled column to pa_application_callback table. ALTER TABLE pa_application_callback ADD enabled BOOLEAN DEFAULT 1 NOT NULL; diff --git a/docs/sql/postgresql/migration_1.8.0_1.9.0.sql b/docs/sql/postgresql/migration_1.8.0_1.9.0.sql index aaf935119..cb3327f6d 100644 --- a/docs/sql/postgresql/migration_1.8.0_1.9.0.sql +++ b/docs/sql/postgresql/migration_1.8.0_1.9.0.sql @@ -46,14 +46,6 @@ CREATE INDEX pa_app_cb_event_ts_del_idx ON pa_application_callback_event(timesta -- Create a new sequence pa_app_callback_event_seq CREATE SEQUENCE IF NOT EXISTS pa_app_callback_event_seq START WITH 1 INCREMENT BY 50 CACHE 20; --- Changeset powerauth-java-server/1.9.x/20240704-callback-event-table.xml::8::Jan Pesek --- Add timestamp_last_failure column to pa_application_callback table. -ALTER TABLE pa_application_callback ADD timestamp_last_failure TIMESTAMP(6) WITHOUT TIME ZONE; - --- Changeset powerauth-java-server/1.9.x/20240704-callback-event-table.xml::9::Jan Pesek --- Add failure_count column to pa_application_callback table. -ALTER TABLE pa_application_callback ADD failure_count INTEGER DEFAULT 0 NOT NULL; - -- Changeset powerauth-java-server/1.9.x/20240704-callback-event-table.xml::10::Jan Pesek -- Add enabled column to pa_application_callback table. ALTER TABLE pa_application_callback ADD enabled BOOLEAN DEFAULT TRUE NOT NULL; diff --git a/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/configuration/CacheConfiguration.java b/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/configuration/CacheConfiguration.java index 60aa325cf..dbbb33368 100644 --- a/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/configuration/CacheConfiguration.java +++ b/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/configuration/CacheConfiguration.java @@ -18,11 +18,13 @@ package io.getlime.security.powerauth.app.server.configuration; +import com.github.benmanes.caffeine.cache.Cache; import com.github.benmanes.caffeine.cache.Caffeine; import com.github.benmanes.caffeine.cache.LoadingCache; import io.getlime.security.powerauth.app.server.database.model.entity.CallbackUrlEntity; import io.getlime.security.powerauth.app.server.service.callbacks.CallbackUrlRestClientCacheLoader; import io.getlime.security.powerauth.app.server.service.callbacks.model.CachedRestClient; +import io.getlime.security.powerauth.app.server.service.callbacks.model.FailureStats; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; @@ -56,4 +58,16 @@ public LoadingCache callbackUrlRestClientCache( .build(cacheLoader); } + /** + * Configuration of the cache for gathering failure statistics during callback processing. + * {@link CallbackUrlEntity#getId()} is used as a cache key. + * + * @return Cache for FailureStats. + */ + @Bean + public Cache callbackFailureStatsCache() { + return Caffeine.newBuilder() + .build(); + } + } diff --git a/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/configuration/PowerAuthCallbacksConfiguration.java b/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/configuration/PowerAuthCallbacksConfiguration.java index b8a0df11f..1cb97e2bf 100644 --- a/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/configuration/PowerAuthCallbacksConfiguration.java +++ b/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/configuration/PowerAuthCallbacksConfiguration.java @@ -90,11 +90,11 @@ public class PowerAuthCallbacksConfiguration { * Number of allowed Callback URL Events failures in a row. When the threshold is reached no other * events with the same Callback URL configuration will be posted. */ - private Integer failureThreshold = 200; + private int failureThreshold = 200; /** * Period after which a Callback URL Event will be dispatched even though failure threshold is reached. */ - private Duration resetTimeout = Duration.ofSeconds(60); + private Duration failureResetTimeout = Duration.ofSeconds(60); } diff --git a/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/database/model/entity/CallbackUrlEntity.java b/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/database/model/entity/CallbackUrlEntity.java index db05267da..b84cd5a25 100644 --- a/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/database/model/entity/CallbackUrlEntity.java +++ b/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/database/model/entity/CallbackUrlEntity.java @@ -121,18 +121,6 @@ public class CallbackUrlEntity implements Serializable { @Convert(converter = DurationConverter.class) private Duration retentionPeriod; - /** - * Timestamp of last callback failure. - */ - @Column(name = "timestamp_last_failure") - private LocalDateTime timestampLastFailure; - - /** - * Number of failed callbacks in a row. - */ - @Column(name = "failure_count", nullable = false) - private Integer failureCount; - /** * Whether the callback is enabled and can be used. */ diff --git a/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/database/repository/CallbackUrlRepository.java b/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/database/repository/CallbackUrlRepository.java index c80f8a9ea..36727290c 100644 --- a/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/database/repository/CallbackUrlRepository.java +++ b/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/database/repository/CallbackUrlRepository.java @@ -39,22 +39,6 @@ public interface CallbackUrlRepository extends CrudRepository findByApplicationIdAndTypeOrderByName(String applicationId, CallbackUrlType type); - @Modifying - @Query(""" - UPDATE CallbackUrlEntity c - SET c.failureCount = c.failureCount + 1, c.timestampLastFailure = :timestampLastFailure - WHERE c.id = :id - """) - void incrementFailureCount(String id, LocalDateTime timestampLastFailure); - - @Modifying - @Query(""" - UPDATE CallbackUrlEntity c - SET c.failureCount = 0, c.timestampLastFailure = NULL - WHERE c.id = :id - """) - void resetFailureCount(String id); - @Modifying @Query(""" UPDATE CallbackUrlEntity c diff --git a/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/service/behavior/tasks/CallbackUrlBehavior.java b/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/service/behavior/tasks/CallbackUrlBehavior.java index e9215c998..a169a8289 100644 --- a/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/service/behavior/tasks/CallbackUrlBehavior.java +++ b/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/service/behavior/tasks/CallbackUrlBehavior.java @@ -111,7 +111,6 @@ public CreateCallbackUrlResponse createCallbackUrl(CreateCallbackUrlRequest requ entity.setType(CallbackUrlTypeConverter.convert(request.getType())); entity.setCallbackUrl(request.getCallbackUrl()); entity.setAttributes(request.getAttributes()); - entity.setFailureCount(0); final EncryptableString encrypted = callbackUrlAuthenticationEncryptor.encrypt(request.getAuthentication(), entity.getApplication().getId()); entity.setAuthentication(encrypted.encryptedData()); entity.setEncryptionMode(encrypted.encryptionMode()); diff --git a/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/service/callbacks/CallbackUrlEventResponseHandler.java b/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/service/callbacks/CallbackUrlEventResponseHandler.java index e5a3fa4f3..4f94b2ec2 100644 --- a/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/service/callbacks/CallbackUrlEventResponseHandler.java +++ b/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/service/callbacks/CallbackUrlEventResponseHandler.java @@ -18,13 +18,14 @@ package io.getlime.security.powerauth.app.server.service.callbacks; +import com.github.benmanes.caffeine.cache.Cache; import io.getlime.security.powerauth.app.server.configuration.PowerAuthCallbacksConfiguration; import io.getlime.security.powerauth.app.server.database.model.entity.CallbackUrlEntity; import io.getlime.security.powerauth.app.server.database.model.entity.CallbackUrlEventEntity; import io.getlime.security.powerauth.app.server.database.model.enumeration.CallbackUrlEventStatus; import io.getlime.security.powerauth.app.server.database.repository.CallbackUrlEventRepository; -import io.getlime.security.powerauth.app.server.database.repository.CallbackUrlRepository; import io.getlime.security.powerauth.app.server.service.callbacks.model.CallbackUrlEvent; +import io.getlime.security.powerauth.app.server.service.callbacks.model.FailureStats; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; @@ -47,8 +48,8 @@ public class CallbackUrlEventResponseHandler { private final CallbackUrlEventRepository callbackUrlEventRepository; - private final CallbackUrlRepository callbackUrlRepository; private final PowerAuthCallbacksConfiguration powerAuthCallbacksConfiguration; + private final Cache callbackFailureStatsCache; /** * Handle successful Callback URL Event attempt. @@ -68,7 +69,7 @@ public void handleSuccess(final CallbackUrlEvent callbackUrlEvent) { callbackUrlEventEntity.setAttempts(callbackUrlEventEntity.getAttempts() + 1); callbackUrlEventEntity.setStatus(CallbackUrlEventStatus.COMPLETED); callbackUrlEventRepository.save(callbackUrlEventEntity); - callbackUrlRepository.resetFailureCount(callbackUrlEventEntity.getCallbackUrlEntity().getId()); + resetFailureCount(callbackUrlEventEntity.getCallbackUrlEntity().getId()); } /** @@ -104,7 +105,7 @@ public void handleFailure(final CallbackUrlEvent callbackUrlEvent, final Throwab } callbackUrlEventRepository.save(callbackUrlEventEntity); - callbackUrlRepository.incrementFailureCount(callbackUrlEntity.getId(), LocalDateTime.now()); + incrementFailureCount(callbackUrlEntity.getId()); } /** @@ -125,4 +126,27 @@ private static Duration calculateExponentialBackoffPeriod(final int attempts, fi return Duration.ofMillis(Math.min(backoffMillis, maxBackoff.toMillis())); } + private void incrementFailureCount(final String callbackUrlId) { + final int failureThreshold = powerAuthCallbacksConfiguration.getFailureThreshold(); + if (failureThreshold == -1) { + logger.debug("Failure stats are turned off for Callback URL processing"); + return; + } + + callbackFailureStatsCache.asMap().compute(callbackUrlId, (key, cachedFailureStats) -> { + if (cachedFailureStats == null) { + return new FailureStats(1, LocalDateTime.now()); + } else { + return new FailureStats(cachedFailureStats.failureCount() + 1, LocalDateTime.now()); + } + }); + + } + + private void resetFailureCount(final String callbackUrlId) { + callbackFailureStatsCache.asMap().computeIfPresent(callbackUrlId, + (key, cachedFailureStats) -> new FailureStats(0, cachedFailureStats.timestampLastFailure()) + ); + } + } diff --git a/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/service/callbacks/CallbackUrlEventService.java b/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/service/callbacks/CallbackUrlEventService.java index be07dc6f6..1193491c0 100644 --- a/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/service/callbacks/CallbackUrlEventService.java +++ b/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/service/callbacks/CallbackUrlEventService.java @@ -18,6 +18,7 @@ package io.getlime.security.powerauth.app.server.service.callbacks; +import com.github.benmanes.caffeine.cache.Cache; import com.github.benmanes.caffeine.cache.LoadingCache; import com.wultra.core.rest.client.base.RestClient; import com.wultra.core.rest.client.base.RestClientException; @@ -30,6 +31,7 @@ import io.getlime.security.powerauth.app.server.service.callbacks.model.CachedRestClient; import io.getlime.security.powerauth.app.server.service.callbacks.model.CallbackUrlConvertor; import io.getlime.security.powerauth.app.server.service.callbacks.model.CallbackUrlEvent; +import io.getlime.security.powerauth.app.server.service.callbacks.model.FailureStats; import io.getlime.security.powerauth.app.server.service.util.TransactionUtils; import jakarta.annotation.PostConstruct; import lombok.AllArgsConstructor; @@ -63,6 +65,7 @@ public class CallbackUrlEventService { private final CallbackUrlEventRepository callbackUrlEventRepository; private final CallbackUrlEventResponseHandler callbackUrlEventResponseHandler; private final LoadingCache restClientCache; + private final Cache callbackFailureStatsCache; private final PowerAuthServiceConfiguration powerAuthServiceConfiguration; private final PowerAuthCallbacksConfiguration powerAuthCallbacksConfiguration; @@ -175,13 +178,21 @@ public int obtainMaxAttempts(final CallbackUrlEntity callbackUrlEntity) { * @return True if the callback should be processed, false otherwise. */ public boolean failureThresholdReached(final CallbackUrlEntity callbackUrlEntity) { - final Integer failureThreshold = powerAuthCallbacksConfiguration.getFailureThreshold(); - final Duration resetTimeout = powerAuthCallbacksConfiguration.getResetTimeout(); + final String callbackUrlId = callbackUrlEntity.getId(); + final FailureStats failureStats = callbackFailureStatsCache.getIfPresent(callbackUrlId); + if (failureStats == null) { + logger.debug("No failure stats available yet for Callback URL processing: id={}", callbackUrlId); + return false; + } + + final int failureThreshold = powerAuthCallbacksConfiguration.getFailureThreshold(); + final Duration resetTimeout = powerAuthCallbacksConfiguration.getFailureResetTimeout(); - final Integer failureCount = callbackUrlEntity.getFailureCount(); - final LocalDateTime timestampLastFailure = Objects.requireNonNullElse(callbackUrlEntity.getTimestampLastFailure(), LocalDateTime.MAX); + final int failureCount = failureStats.failureCount(); + final LocalDateTime timestampLastFailure = failureStats.timestampLastFailure(); if (failureCount >= failureThreshold && LocalDateTime.now().minus(resetTimeout).isAfter(timestampLastFailure)) { + logger.debug("Callback URL reached failure threshold, but before specified reset timeout period, id={}", callbackUrlId); return false; } diff --git a/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/service/callbacks/model/FailureStats.java b/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/service/callbacks/model/FailureStats.java new file mode 100644 index 000000000..f4985437f --- /dev/null +++ b/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/service/callbacks/model/FailureStats.java @@ -0,0 +1,31 @@ +/* + * PowerAuth Server and related software components + * Copyright (C) 2024 Wultra s.r.o. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package io.getlime.security.powerauth.app.server.service.callbacks.model; + +import java.time.LocalDateTime; + +/** + * A data class holding failure statistics of a callback processing. + * + * @author Jan Pesek, jan.pesek@wultra.com + */ +public record FailureStats( + int failureCount, + LocalDateTime timestampLastFailure +) { } diff --git a/powerauth-java-server/src/test/java/io/getlime/security/powerauth/app/server/service/behavior/tasks/CallbackUrlBehaviorTest.java b/powerauth-java-server/src/test/java/io/getlime/security/powerauth/app/server/service/behavior/tasks/CallbackUrlBehaviorTest.java index c2edbbf06..eb504111d 100644 --- a/powerauth-java-server/src/test/java/io/getlime/security/powerauth/app/server/service/behavior/tasks/CallbackUrlBehaviorTest.java +++ b/powerauth-java-server/src/test/java/io/getlime/security/powerauth/app/server/service/behavior/tasks/CallbackUrlBehaviorTest.java @@ -100,7 +100,6 @@ void testCreateCallbackUrl() throws Exception { assertNull(entity.getRetentionPeriod()); assertNull(entity.getInitialBackoff()); assertNull(entity.getMaxAttempts()); - assertEquals(0, entity.getFailureCount()); assertTrue(entity.isEnabled()); } diff --git a/powerauth-java-server/src/test/resources/io/getlime/security/powerauth/app/server/service/behavior/tasks/CallbackUrlBehaviorTest.sql b/powerauth-java-server/src/test/resources/io/getlime/security/powerauth/app/server/service/behavior/tasks/CallbackUrlBehaviorTest.sql index 657d5cdbd..fdd7c2a4f 100644 --- a/powerauth-java-server/src/test/resources/io/getlime/security/powerauth/app/server/service/behavior/tasks/CallbackUrlBehaviorTest.sql +++ b/powerauth-java-server/src/test/resources/io/getlime/security/powerauth/app/server/service/behavior/tasks/CallbackUrlBehaviorTest.sql @@ -1,9 +1,9 @@ INSERT INTO pa_application (id, name) VALUES (21, 'PA_Tests'); -INSERT INTO pa_application_callback (id, application_id, name, callback_url, type, failure_count, enabled) VALUES - ('cafec169-28a6-490c-a1d5-c012b9e3c044', 21, 'test-callback', 'http://localhost:8080', 'ACTIVATION_STATUS_CHANGE', 0, true), - ('c3d5083a-ce9f-467c-af2c-0c950c197bba', 21, 'test-callback', 'http://localhost:8080', 'ACTIVATION_STATUS_CHANGE', 0, false); +INSERT INTO pa_application_callback (id, application_id, name, callback_url, type, enabled) VALUES + ('cafec169-28a6-490c-a1d5-c012b9e3c044', 21, 'test-callback', 'http://localhost:8080', 'ACTIVATION_STATUS_CHANGE', true), + ('c3d5083a-ce9f-467c-af2c-0c950c197bba', 21, 'test-callback', 'http://localhost:8080', 'ACTIVATION_STATUS_CHANGE', false); INSERT INTO pa_application_callback_event (id, application_callback_id, callback_data, status, timestamp_created, attempts, idempotency_key) VALUES (1, 'cafec169-28a6-490c-a1d5-c012b9e3c044', '{}', 'COMPLETED', '2020-10-04 12:13:27.599000', 1, '729c3cd9-45e7-46b2-bc24-cd638138ccfe'); diff --git a/powerauth-java-server/src/test/resources/io/getlime/security/powerauth/app/server/service/behavior/tasks/CallbackUrlBehaviorTest.testNotifyCallbackListenersOnActivationChange.sql b/powerauth-java-server/src/test/resources/io/getlime/security/powerauth/app/server/service/behavior/tasks/CallbackUrlBehaviorTest.testNotifyCallbackListenersOnActivationChange.sql index 2b6dc28d7..15df0845c 100644 --- a/powerauth-java-server/src/test/resources/io/getlime/security/powerauth/app/server/service/behavior/tasks/CallbackUrlBehaviorTest.testNotifyCallbackListenersOnActivationChange.sql +++ b/powerauth-java-server/src/test/resources/io/getlime/security/powerauth/app/server/service/behavior/tasks/CallbackUrlBehaviorTest.testNotifyCallbackListenersOnActivationChange.sql @@ -7,7 +7,7 @@ INSERT INTO pa_master_keypair (id, application_id, master_key_private_base64, ma INSERT INTO pa_activation (activation_id, application_id, user_id, activation_name, activation_code, activation_status, activation_otp, activation_otp_validation, blocked_reason, counter, ctr_data, device_public_key_base64, extras, platform, device_info, flags, failed_attempts, max_failed_attempts, server_private_key_base64, server_private_key_encryption, server_public_key_base64, timestamp_activation_expire, timestamp_created, timestamp_last_used, timestamp_last_change, master_keypair_id, version) VALUES ('e43a5dec-afea-4a10-a80b-b2183399f16b', 1, 'testUser', 'test v4', 'PXSNR-E2B46-7TY3G-TMR2Q', 3, null, 0, null, 0, 'D5XibWWPCv+nOOfcdfnUGQ==', 'BF3Sc/vqg8Zk70Y8rbT45xzAIxblGoWgLqknCHuNj7f6QFBNi2UnLbG7yMqf2eWShhyBJdu9zqx7DG2qzlqhbBE=', null, 'unknown', 'backend-tests', '[ "test-flag1", "test-flag2", "test-flag3" ]', 0, 1, 'PUz/He8+RFoOPS1NG6Gw3TDXIQ/DnS1skNBOQWzXX60=', 0, 'BPHJ4N90NUuLDq92FJUPcaKZOMad1KH2HrwQEN9DB5ST5fiJU4baYF1VlK1JHglnnN1miL3/Qb6IyW3YSMBySYM=', '2023-04-03 14:04:06.015000', '2023-04-03 13:59:06.015000', '2023-04-03 13:59:16.293000', '2023-04-03 13:59:16.343000', 1, 3); -INSERT INTO pa_application_callback (id, application_id, name, callback_url, type, failure_count, enabled) VALUES - ('cba5f7aa-889e-4846-b97a-b6ba1bd51ad5', 1, 'test-callback-enabled', 'http://localhost:8080', 'ACTIVATION_STATUS_CHANGE', 0, true), - ('b5446f8f-a994-447e-b637-e7cd171a24b5', 1, 'test-callback-disabled', 'http://localhost:8080', 'ACTIVATION_STATUS_CHANGE', 0, false), - ('be335b28-8474-41a6-82c8-19ff8b7e82d2', 1, 'test-callback-operation', 'http://localhost:8080', 'OPERATION_STATUS_CHANGE', 0, true); +INSERT INTO pa_application_callback (id, application_id, name, callback_url, type, enabled) VALUES + ('cba5f7aa-889e-4846-b97a-b6ba1bd51ad5', 1, 'test-callback-enabled', 'http://localhost:8080', 'ACTIVATION_STATUS_CHANGE', true), + ('b5446f8f-a994-447e-b637-e7cd171a24b5', 1, 'test-callback-disabled', 'http://localhost:8080', 'ACTIVATION_STATUS_CHANGE', false), + ('be335b28-8474-41a6-82c8-19ff8b7e82d2', 1, 'test-callback-operation', 'http://localhost:8080', 'OPERATION_STATUS_CHANGE', true); diff --git a/powerauth-java-server/src/test/resources/io/getlime/security/powerauth/app/server/service/behavior/tasks/CallbackUrlBehaviorTest.testNotifyCallbackListenersOnOperationChange.sql b/powerauth-java-server/src/test/resources/io/getlime/security/powerauth/app/server/service/behavior/tasks/CallbackUrlBehaviorTest.testNotifyCallbackListenersOnOperationChange.sql index e7b6cdd89..1ea4a6d94 100644 --- a/powerauth-java-server/src/test/resources/io/getlime/security/powerauth/app/server/service/behavior/tasks/CallbackUrlBehaviorTest.testNotifyCallbackListenersOnOperationChange.sql +++ b/powerauth-java-server/src/test/resources/io/getlime/security/powerauth/app/server/service/behavior/tasks/CallbackUrlBehaviorTest.testNotifyCallbackListenersOnOperationChange.sql @@ -13,7 +13,7 @@ INSERT INTO pa_operation (id, user_id, external_id, activation_flag, operation_t INSERT INTO pa_operation_application (operation_id, application_id) VALUES ('07e927af-689a-43ac-bd21-291179801912', 1); -INSERT INTO pa_application_callback (id, application_id, name, callback_url, type, failure_count, enabled) VALUES - ('cba5f7aa-889e-4846-b97a-b6ba1bd51ad5', 1, 'test-callback-enabled', 'http://localhost:8080', 'OPERATION_STATUS_CHANGE', 0, true), - ('b5446f8f-a994-447e-b637-e7cd171a24b5', 1, 'test-callback-disabled', 'http://localhost:8080', 'OPERATION_STATUS_CHANGE', 0, false), - ('be335b28-8474-41a6-82c8-19ff8b7e82d2', 1, 'test-callback-activation', 'http://localhost:8080', 'ACTIVATION_STATUS_CHANGE', 0, true); +INSERT INTO pa_application_callback (id, application_id, name, callback_url, type, enabled) VALUES + ('cba5f7aa-889e-4846-b97a-b6ba1bd51ad5', 1, 'test-callback-enabled', 'http://localhost:8080', 'OPERATION_STATUS_CHANGE', true), + ('b5446f8f-a994-447e-b637-e7cd171a24b5', 1, 'test-callback-disabled', 'http://localhost:8080', 'OPERATION_STATUS_CHANGE', false), + ('be335b28-8474-41a6-82c8-19ff8b7e82d2', 1, 'test-callback-activation', 'http://localhost:8080', 'ACTIVATION_STATUS_CHANGE', true);