Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge develop to master #310

Merged
merged 48 commits into from
Jul 26, 2024
Merged
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
dde536e
Fix #264: Set develop version to 1.10.0-SNAPSHOT (#270)
banterCZ Feb 23, 2024
d6d6b8e
Update GitHub Actions to JDK 21
banterCZ Mar 7, 2024
b2b00df
Merge pull request #271 from wultra/issues/gha-jdk-21
banterCZ Mar 8, 2024
3d446b5
Fix #272: Change the order of audit cleanup to keep data integrity (#…
banterCZ Mar 21, 2024
45817c0
Fix #274: Remove powerauth prefix from audit properties
banterCZ Mar 21, 2024
212e741
Merge pull request #275 from wultra/issues/274-audit-properties
banterCZ Mar 22, 2024
d57a4a2
Bump spring-boot.version from 3.2.3 to 3.2.4
dependabot[bot] Mar 25, 2024
f9cbefa
Bump org.apache.maven.plugins:maven-compiler-plugin
dependabot[bot] Mar 25, 2024
bed3c3a
Merge pull request #276 from wultra/dependabot/maven/spring-boot.vers…
dependabot[bot] Mar 26, 2024
fa32d9d
Merge pull request #277 from wultra/dependabot/maven/org.apache.maven…
dependabot[bot] Mar 26, 2024
36a3c78
Downgrade JDK for Coverity GHA to 17
banterCZ Mar 28, 2024
ff155d5
Merge pull request #278 from wultra/issues/gha-coverity-jdk-17
banterCZ Mar 28, 2024
e2a7b4d
Fix #279: Remove com.google.code.findbugs dependency
banterCZ Apr 2, 2024
948749c
Fix #281: Specify enforcer plugin version
banterCZ Apr 2, 2024
ebfce80
Merge pull request #282 from wultra/issues/281-enforcer-version
banterCZ Apr 3, 2024
dff6b4e
Merge pull request #280 from wultra/issues/279-remove-google-findbugs
banterCZ Apr 3, 2024
42fe8f0
Bump org.apache.maven.plugins:maven-source-plugin from 3.3.0 to 3.3.1
dependabot[bot] Apr 8, 2024
c2e4200
Merge pull request #283 from wultra/dependabot/maven/org.apache.maven…
dependabot[bot] Apr 9, 2024
e62de78
Disable CodeQL GitHub Action on pull requests
banterCZ Apr 15, 2024
883f22b
Merge pull request #284 from wultra/issues/limit-codeql
banterCZ Apr 16, 2024
1b5b2c2
Bump spring-boot.version from 3.2.4 to 3.2.5
dependabot[bot] Apr 22, 2024
c94df55
Merge pull request #285 from wultra/dependabot/maven/spring-boot.vers…
dependabot[bot] Apr 23, 2024
3b36151
Bump org.apache.maven.plugins:maven-deploy-plugin from 3.1.1 to 3.1.2
dependabot[bot] Apr 29, 2024
cc74350
Merge pull request #286 from wultra/dependabot/maven/org.apache.maven…
dependabot[bot] Apr 30, 2024
f301d3b
Add dependabot configuration for github-actions
banterCZ May 16, 2024
97f7c44
Merge pull request #289 from wultra/issues/dependabot-gha
banterCZ May 16, 2024
a31f1e3
Bump spring-boot.version from 3.2.5 to 3.3.0
dependabot[bot] May 27, 2024
c4d25ec
Merge pull request #291 from wultra/dependabot/maven/spring-boot.vers…
dependabot[bot] May 28, 2024
e6529d9
Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.6.3 to 3.7.0
dependabot[bot] Jun 3, 2024
3887395
Bump org.apache.maven.plugins:maven-enforcer-plugin from 3.4.1 to 3.5.0
dependabot[bot] Jun 3, 2024
6e3f4d5
Merge pull request #293 from wultra/dependabot/maven/org.apache.maven…
dependabot[bot] Jun 4, 2024
d01caec
Merge pull request #292 from wultra/dependabot/maven/org.apache.maven…
dependabot[bot] Jun 4, 2024
1c952d3
Fix #287: GHA config for release (#288)
banterCZ Jun 4, 2024
9f915e6
Fix #301: Change transaction propagation of DatabaseAuditWriter#flush…
banterCZ Jun 13, 2024
cca6ec0
Merge pull request #302 from wultra/issues/301-audit-writer-new-trans…
banterCZ Jun 14, 2024
c628d0c
Fix #303: Pending acquire queue has reached its maximum size (#304)
banterCZ Jun 17, 2024
8b0c02d
Bump org.apache.maven.plugins:maven-surefire-plugin from 3.2.5 to 3.3.0
dependabot[bot] Jun 17, 2024
b64bf77
Merge pull request #305 from wultra/dependabot/maven/org.apache.maven…
dependabot[bot] Jun 18, 2024
7f1c5f2
Bump spring-boot.version from 3.3.0 to 3.3.1
dependabot[bot] Jun 24, 2024
3359563
Merge pull request #307 from wultra/dependabot/maven/spring-boot.vers…
dependabot[bot] Jun 25, 2024
d67b45d
Fix #308: Set release version to 1.10.0
banterCZ Jun 25, 2024
8f6c850
Bump org.apache.maven.plugins:maven-surefire-plugin from 3.3.0 to 3.3.1
dependabot[bot] Jul 15, 2024
e921e3e
Merge pull request #312 from wultra/dependabot/maven/org.apache.maven…
dependabot[bot] Jul 16, 2024
05a0aa4
Bump spring-boot.version from 3.3.1 to 3.3.2
dependabot[bot] Jul 22, 2024
60e3486
Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.7.0 to 3.8.0
dependabot[bot] Jul 22, 2024
493d3d7
Merge pull request #314 from wultra/dependabot/maven/org.apache.maven…
dependabot[bot] Jul 23, 2024
d5af560
Merge pull request #313 from wultra/dependabot/maven/spring-boot.vers…
dependabot[bot] Jul 23, 2024
6eaf339
Merge pull request #311 from wultra/issues/308-version-1.10.0
banterCZ Jul 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix #272: Change the order of audit cleanup to keep data integrity (#273
)

* Fix #272: Change the order of audit cleanup to keep data integrity
banterCZ authored Mar 21, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 3d446b5ff79863dfe75b579d45b532ec97318f5a
Original file line number Diff line number Diff line change
@@ -258,11 +258,11 @@ public void cleanup() {
final LocalDateTime cleanupLimit = LocalDateTime.now().minusDays(cleanupDays);
synchronized (CLEANUP_LOCK) {
transactionTemplate.executeWithoutResult(status -> {
jdbcTemplate.execute("DELETE FROM " + tableNameAudit + " WHERE timestamp_created < ?", (PreparedStatementCallback<Boolean>) ps -> {
jdbcTemplate.execute("DELETE FROM " + tableNameParam + " WHERE timestamp_created < ?", (PreparedStatementCallback<Boolean>) ps -> {
ps.setTimestamp(1, Timestamp.valueOf(cleanupLimit));
return ps.execute();
});
jdbcTemplate.execute("DELETE FROM " + tableNameParam + " WHERE timestamp_created < ?", (PreparedStatementCallback<Boolean>) ps -> {
jdbcTemplate.execute("DELETE FROM " + tableNameAudit + " WHERE timestamp_created < ?", (PreparedStatementCallback<Boolean>) ps -> {
ps.setTimestamp(1, Timestamp.valueOf(cleanupLimit));
return ps.execute();
});
Original file line number Diff line number Diff line change
@@ -33,7 +33,11 @@

import static org.junit.jupiter.api.Assertions.*;

@SpringBootTest(classes = TestApplication.class, properties = {"audit.db.table.param.enabled=true"})
@SpringBootTest(classes = TestApplication.class, properties = {
"audit.db.table.param.enabled=true",
"audit.db.cleanup.days=-1", // time shift to the future to enable cleanup test
"powerauth.audit.cleanup.delay.initial=60000" // delay the job start due to slow builds
})
@Sql(scripts = "/db_schema.sql")
class AuditParamEnabledTest {

@@ -122,4 +126,33 @@ void testAuditMoreParams() {
assertEquals(new JsonUtil().serializeObject(timestamp), rs3.getString("param_value"));
}

@Test
void testAuditCleanup() {
final Audit audit = auditFactory.getAudit();
audit.info("test message", AuditDetail.builder().param("my_id", "test_id").build());
audit.flush();

assertEquals(1, countAuditLogs());
assertEquals(1, countAuditParams());

audit.cleanup();

assertEquals(0, countAuditLogs());
assertEquals(0, countAuditParams());
}

private int countAuditLogs() {
return count("audit_log");
}

private int countAuditParams() {
return count("audit_param");
}

private int count(final String tableName) {
final SqlRowSet rs = jdbcTemplate.queryForRowSet("SELECT COUNT(*) FROM " + tableName);
assertTrue(rs.next());
return rs.getInt(1);
}

}
12 changes: 12 additions & 0 deletions audit-base/src/test/java/com/wultra/core/audit/base/AuditTest.java
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@

import com.wultra.core.audit.base.model.AuditDetail;
import com.wultra.core.audit.base.model.AuditLevel;
import org.awaitility.Awaitility;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
@@ -26,6 +27,7 @@
import org.springframework.test.context.jdbc.Sql;

import java.sql.Timestamp;
import java.time.Duration;

import static org.junit.jupiter.api.Assertions.*;

@@ -219,4 +221,14 @@ void testAuditTrace() {
assertTrue(rs.next());
assertEquals(0, rs.getInt(1));
}

@Test
void testScheduledFlush() {
Audit audit = auditFactory.getAudit();
audit.info("test message");

Awaitility.await()
.atMost(Duration.ofSeconds(5))
.until(() -> jdbcTemplate.queryForRowSet("SELECT * FROM audit_log").next());
}
}