Skip to content

Commit 1c8a613

Browse files
authored
Merge pull request #53 from devondragon/dependabot/gradle/springBootVersion-3.5.0
Bump springBootVersion from 3.4.5 to 3.5.0
2 parents 2a7a319 + b089d62 commit 1c8a613

14 files changed

Lines changed: 209 additions & 120 deletions

build.gradle

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ group 'com.digitalsanctuary.cf.turnstile'
2020
description = 'SpringBoot Cloudflare Turnstile Library'
2121

2222
ext {
23-
springBootVersion = '3.4.5'
23+
springBootVersion = '3.5.0'
2424
lombokVersion = '1.18.38'
2525
}
2626

@@ -52,6 +52,9 @@ dependencies {
5252
testImplementation "org.springframework.boot:spring-boot-starter-web:$springBootVersion"
5353
testImplementation "org.springframework.boot:spring-boot-starter-test:$springBootVersion"
5454
testImplementation "org.springframework.boot:spring-boot-starter-actuator:$springBootVersion"
55+
56+
testImplementation 'org.junit.jupiter:junit-jupiter:5.12.2'
57+
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
5558
}
5659

5760
test {
@@ -154,7 +157,7 @@ publishing {
154157
// Code Quality Configurations
155158

156159
checkstyle {
157-
toolVersion = '10.14.2'
160+
// toolVersion = '10.14.2'
158161
configFile = project.file("config/checkstyle/checkstyle.xml")
159162
configProperties = [
160163
'baseDir': rootDir
@@ -172,7 +175,7 @@ tasks.withType(Checkstyle) {
172175
}
173176

174177
pmd {
175-
toolVersion = '6.55.0'
178+
// toolVersion = '6.55.0'
176179
consoleOutput = true
177180
ruleSetFiles = files(project.file("config/pmd/ruleset.xml"))
178181
ruleSets = []
@@ -189,7 +192,7 @@ tasks.withType(Pmd) {
189192
}
190193

191194
jacoco {
192-
toolVersion = '0.8.11'
195+
// toolVersion = '0.8.11'
193196
}
194197

195198
jacocoTestReport {
@@ -237,19 +240,19 @@ tasks.register("debugCI") {
237240
println "Working directory: ${System.getProperty('user.dir')}"
238241
println "Project directory: ${project.projectDir.absolutePath}"
239242
println "Root directory: ${rootDir.absolutePath}"
240-
243+
241244
def checkstyleFile = project.file("config/checkstyle/checkstyle.xml")
242245
println "Checkstyle file exists: ${checkstyleFile.exists()}"
243246
if (checkstyleFile.exists()) {
244247
println "Checkstyle file path: ${checkstyleFile.absolutePath}"
245248
}
246-
249+
247250
def pmdFile = project.file("config/pmd/ruleset.xml")
248251
println "PMD file exists: ${pmdFile.exists()}"
249252
if (pmdFile.exists()) {
250253
println "PMD file path: ${pmdFile.absolutePath}"
251254
}
252-
255+
253256
println "Directory contents:"
254257
project.file("config").listFiles().each { file ->
255258
println " - ${file.name}"

config/pmd/ruleset.xml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
<exclude name="JUnitTestContainsTooManyAsserts"/>
1313
<exclude name="JUnitTestsShouldIncludeAssert"/>
1414
<exclude name="JUnitAssertionsShouldIncludeMessage"/>
15+
<exclude name="JUnit5TestShouldBePackagePrivate"/>
1516
</rule>
16-
17+
18+
1719
<!-- Code Style -->
1820
<rule ref="category/java/codestyle.xml">
1921
<exclude name="AtLeastOneConstructor"/>
@@ -28,7 +30,7 @@
2830
<exclude name="CallSuperInConstructor"/>
2931
<exclude name="UselessParentheses"/>
3032
</rule>
31-
33+
3234
<!-- Design -->
3335
<rule ref="category/java/design.xml">
3436
<exclude name="LawOfDemeter"/>
@@ -37,32 +39,33 @@
3739
<exclude name="DataClass"/>
3840
<exclude name="TooManyMethods"/>
3941
</rule>
40-
42+
4143
<!-- Documentation -->
4244
<rule ref="category/java/documentation.xml">
4345
<exclude name="CommentSize"/>
4446
</rule>
45-
47+
4648
<!-- Error Prone -->
4749
<rule ref="category/java/errorprone.xml">
48-
<exclude name="BeanMembersShouldSerialize"/>
4950
<exclude name="DataflowAnomalyAnalysis"/>
5051
<exclude name="AvoidFieldNameMatchingMethodName"/>
5152
<exclude name="AvoidLiteralsInIfCondition"/>
5253
<exclude name="NullAssignment"/>
5354
<exclude name="MissingSerialVersionUID"/>
5455
<exclude name="AssignmentInOperand"/>
5556
</rule>
56-
57+
5758
<!-- Multithreading -->
5859
<rule ref="category/java/multithreading.xml">
5960
<exclude name="UseConcurrentHashMap"/>
6061
<exclude name="DoNotUseThreads"/>
6162
</rule>
62-
63+
6364
<!-- Performance -->
6465
<rule ref="category/java/performance.xml">
6566
<exclude name="AvoidInstantiatingObjectsInLoops"/>
6667
<exclude name="SimplifyStartsWith"/>
6768
</rule>
68-
</ruleset>
69+
70+
71+
</ruleset>

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.1-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

src/main/java/com/digitalsanctuary/cf/turnstile/config/TurnstileHealthIndicator.java

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@
1313
/**
1414
* Health indicator for the Cloudflare Turnstile service.
1515
* <p>
16-
* This component provides health check information for the Cloudflare Turnstile service.
17-
* It checks if the service is properly configured and if the service has not exceeded
18-
* the configured error threshold. The health indicator can be disabled through configuration.
16+
* This component provides health check information for the Cloudflare Turnstile service. It checks if the service is properly configured and if the
17+
* service has not exceeded the configured error threshold. The health indicator can be disabled through configuration.
1918
* </p>
2019
*/
2120
@Slf4j
@@ -43,19 +42,15 @@ public Health health() {
4342
double errorRate = validationService.getErrorRate();
4443
int errorThreshold = properties.getMetrics().getErrorThreshold();
4544

46-
Health.Builder builder = Health.up()
47-
.withDetail("url", properties.getUrl())
48-
.withDetail("validationCount", validationService.getValidationCount())
49-
.withDetail("successCount", validationService.getSuccessCount())
50-
.withDetail("errorCount", validationService.getErrorCount())
51-
.withDetail("errorRate", String.format("%.2f%%", errorRate))
52-
.withDetail("responseTimeAvg", String.format("%.2fms", validationService.getAverageResponseTime()));
45+
Health.Builder builder =
46+
Health.up().withDetail("url", properties.getUrl()).withDetail("validationCount", validationService.getValidationCount())
47+
.withDetail("successCount", validationService.getSuccessCount())
48+
.withDetail("errorCount", validationService.getErrorCount()).withDetail("errorRate", String.format("%.2f%%", errorRate))
49+
.withDetail("responseTimeAvg", String.format("%.2fms", validationService.getAverageResponseTime()));
5350

5451
// If error rate exceeds threshold, report as DOWN
5552
if (errorRate > errorThreshold) {
56-
return builder.down()
57-
.withDetail("reason", "Error rate exceeded threshold: " + errorRate + "% > " + errorThreshold + "%")
58-
.build();
53+
return builder.down().withDetail("reason", "Error rate exceeded threshold: " + errorRate + "% > " + errorThreshold + "%").build();
5954
}
6055

6156
return builder.build();
@@ -64,4 +59,4 @@ public Health health() {
6459
return Health.down(e).withDetail("reason", "Error checking service health: " + e.getMessage()).build();
6560
}
6661
}
67-
}
62+
}

src/main/java/com/digitalsanctuary/cf/turnstile/config/TurnstileMetricsConfig.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@
1515
/**
1616
* Configuration for Turnstile metrics and monitoring.
1717
* <p>
18-
* This class configures the metrics for Cloudflare Turnstile service. It sets up common
19-
* tags and filters for all metrics related to the Turnstile service. The metrics are only
20-
* configured if micrometer-core is on the classpath and metrics are enabled in the configuration.
18+
* This class configures the metrics for Cloudflare Turnstile service. It sets up common tags and filters for all metrics related to the Turnstile
19+
* service. The metrics are only configured if micrometer-core is on the classpath and metrics are enabled in the configuration.
2120
* </p>
2221
*/
2322
@Slf4j
@@ -29,8 +28,7 @@ public class TurnstileMetricsConfig {
2928
/**
3029
* Customizes the meter registry for Turnstile metrics.
3130
* <p>
32-
* Adds a common tag 'component:turnstile' to all Turnstile-related metrics
33-
* and configures a prefix for all Turnstile metrics.
31+
* Adds a common tag 'component:turnstile' to all Turnstile-related metrics and configures a prefix for all Turnstile metrics.
3432
* </p>
3533
*
3634
* @return a MeterRegistryCustomizer to customize the MeterRegistry
@@ -40,9 +38,8 @@ public MeterRegistryCustomizer<MeterRegistry> turnstileMeterRegistryCustomizer()
4038
log.info("Configuring Turnstile metrics");
4139
return registry -> {
4240
// Add a common tag to all turnstile metrics
43-
registry.config()
44-
.meterFilter(MeterFilter.acceptNameStartsWith("turnstile"))
41+
registry.config().meterFilter(MeterFilter.acceptNameStartsWith("turnstile"))
4542
.meterFilter(MeterFilter.commonTags(Collections.singletonList(Tag.of("component", "turnstile"))));
4643
};
4744
}
48-
}
45+
}

src/main/java/com/digitalsanctuary/cf/turnstile/dto/TurnstileResponse.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
/**
88
* Data Transfer Object (DTO) representing the response from Cloudflare's Turnstile API.
99
* <p>
10-
* This class maps to the JSON response returned by Cloudflare's Turnstile verification endpoint.
11-
* It contains information about whether the verification was successful, when the challenge was
12-
* completed, what hostname it was completed on, and any error codes if the verification failed.
10+
* This class maps to the JSON response returned by Cloudflare's Turnstile verification endpoint. It contains information about whether the
11+
* verification was successful, when the challenge was completed, what hostname it was completed on, and any error codes if the verification failed.
1312
* </p>
1413
* <p>
1514
* Example successful JSON response:
1615
* </p>
16+
*
1717
* <pre>
1818
* {
1919
* "success": true,
@@ -25,13 +25,14 @@
2525
* <p>
2626
* Example failed JSON response:
2727
* </p>
28+
*
2829
* <pre>
2930
* {
3031
* "success": false,
3132
* "error-codes": ["invalid-input-response", "timeout-or-duplicate"]
3233
* }
3334
* </pre>
34-
*
35+
*
3536
* @see <a href="https://developers.cloudflare.com/turnstile/get-started/server-side-validation/">Cloudflare Turnstile Server-Side Validation</a>
3637
*/
3738
@Data
@@ -58,4 +59,3 @@ public class TurnstileResponse {
5859
@JsonProperty("error-codes")
5960
private List<String> errorCodes;
6061
}
61-

0 commit comments

Comments
 (0)