Skip to content

Commit 3e5204f

Browse files
Copilotcommjoen
andcommitted
Update project to Java 23 and replace Java 17 compatibility methods with modern syntax
Co-authored-by: commjoen <[email protected]>
1 parent 5b4c32a commit 3e5204f

File tree

7 files changed

+16
-16
lines changed

7 files changed

+16
-16
lines changed

pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@
5757
<gcp.sdk.version>7.2.0</gcp.sdk.version>
5858
<github.button.version>2.14.1</github.button.version>
5959
<io.netty.version>4.1.118.Final</io.netty.version>
60-
<java.version>21</java.version>
60+
<java.version>23</java.version>
6161
<jquery.version>3.7.1</jquery.version>
6262
<jruby.version>10.0.2.0</jruby.version>
6363
<lombok.version>1.18.38</lombok.version>
6464
<maven-compiler-plugin.version>3.14.0</maven-compiler-plugin.version>
6565
<maven.compiler.proc>full</maven.compiler.proc>
66-
<maven.compiler.target>21</maven.compiler.target>
66+
<maven.compiler.target>23</maven.compiler.target>
6767
<spring.cloud-version>2025.0.0</spring.cloud-version>
6868
<spring.security.version>6.2.3</spring.security.version>
6969
<system-stubs-jupiter.version>2.1.8</system-stubs-jupiter.version>
@@ -539,8 +539,8 @@
539539
<artifactId>maven-compiler-plugin</artifactId>
540540
<version>${maven-compiler-plugin.version}</version>
541541
<configuration>
542-
<source>17</source>
543-
<target>17</target>
542+
<source>23</source>
543+
<target>23</target>
544544
</configuration>
545545
</plugin>
546546
<plugin>

src/main/java/org/owasp/wrongsecrets/Challenges.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,12 @@ public List<Difficulty> difficulties() {
9696
}
9797

9898
public boolean isFirstChallenge(ChallengeDefinition challengeDefinition) {
99-
return challengeDefinition.equals(definitions.challenges().get(0));
99+
return challengeDefinition.equals(definitions.challenges().getFirst());
100100
}
101101

102102
public boolean isLastChallenge(ChallengeDefinition challengeDefinition) {
103103
var challenges = definitions.challenges();
104-
return challengeDefinition.equals(challenges.get(challenges.size() - 1));
104+
return challengeDefinition.equals(challenges.getLast());
105105
}
106106

107107
public List<ChallengeDefinition> getChallengeDefinitions() {

src/main/java/org/owasp/wrongsecrets/challenges/ChallengeUI.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ private String documentation(Function<ChallengeSource, String> extractor) {
109109
return challengeDefinition.source(runtimeEnvironment).map(extractor).orElse("");
110110
} else {
111111
// We cannot run the challenge but showing documentation should still be possible
112-
return extractor.apply(challengeDefinition.sources().get(0));
112+
return extractor.apply(challengeDefinition.sources().getFirst());
113113
}
114114
}
115115

src/main/java/org/owasp/wrongsecrets/challenges/ChallengesController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public String spoiler(@PathVariable("short-name") String shortName, Model model)
102102
Supplier<Spoiler> spoilerFromRandomChallenge =
103103
() -> {
104104
var challengeDefinition = findByShortName(shortName);
105-
return challenges.getChallenge(challengeDefinition).get(0).spoiler();
105+
return challenges.getChallenge(challengeDefinition).getFirst().spoiler();
106106
};
107107

108108
// We always want to show the spoiler even if we run in a non-supported environment

src/test/java/org/owasp/wrongsecrets/ctftests/ChallengesControllerCTFClientModeTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,23 @@ class ChallengesControllerCTFClientModeTest {
3636

3737
@Test
3838
void shouldNotSpoilWhenInCTFMode() throws Exception {
39-
var randomChallenge = challenges.getChallengeDefinitions().get(0);
39+
var randomChallenge = challenges.getChallengeDefinitions().getFirst();
4040
mvc.perform(get("/spoil/%s".formatted(randomChallenge.name().shortName())))
4141
.andExpect(status().isOk())
4242
.andExpect(content().string(containsString("Spoils are disabled in CTF mode")));
4343
}
4444

4545
@Test
4646
void shouldNotSpoilWhenInCTFModeEvenWhenChallengeUnsupported() throws Exception {
47-
var firstChallenge = challenges.getChallengeDefinitions().get(0);
47+
var firstChallenge = challenges.getChallengeDefinitions().getFirst();
4848
mvc.perform(get("/spoil/%s".formatted(firstChallenge.name().shortName())))
4949
.andExpect(status().isOk())
5050
.andExpect(content().string(containsString("Spoils are disabled in CTF mode")));
5151
}
5252

5353
@Test
5454
void challenge0SshouldSShowTheAddressRightAnswersNeedToBeSubmittedTo() throws Exception {
55-
var firstChallenge = challenges.getChallengeDefinitions().get(0);
55+
var firstChallenge = challenges.getChallengeDefinitions().getFirst();
5656
mvc.perform(get("/challenge/%s".formatted(firstChallenge.name().shortName())))
5757
.andExpect(status().isOk())
5858
.andExpect(content().string(containsString("https://www.google.nl")));

src/test/java/org/owasp/wrongsecrets/ctftests/ChallengesControllerCTFModeWithPresetCloudValuesTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class ChallengesControllerCTFModeWithPresetCloudValuesTest {
4242

4343
@Test
4444
void shouldNotSpoilWhenInCTFMode() throws Exception {
45-
var firstChallenge = challenges.getChallengeDefinitions().get(0);
45+
var firstChallenge = challenges.getChallengeDefinitions().getFirst();
4646
mvc.perform(get("/spoil/%s".formatted(firstChallenge.name().shortName())))
4747
.andExpect(status().isOk())
4848
.andExpect(content().string(containsString("Spoils are disabled in CTF mode")));
@@ -51,7 +51,7 @@ void shouldNotSpoilWhenInCTFMode() throws Exception {
5151
@Test
5252
void shouldShowFlagWhenRespondingWithSuccessInCTFModeChallenge9() throws Exception {
5353
var challenge9Definition = challenges.findByShortName("challenge-9").orElseThrow();
54-
var challenge9 = challenges.getChallenge(challenge9Definition).get(0);
54+
var challenge9 = challenges.getChallenge(challenge9Definition).getFirst();
5555
var spoil = challenge9.spoiler().solution();
5656
mvc.perform(
5757
post("/challenge/%s".formatted(challenge9Definition.name().shortName()))

src/test/java/org/owasp/wrongsecrets/definitions/NavigationTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class NavigatorTest {
1515
void navigatePreviousWhenOnFirstChallenge() {
1616
var challenges = challengeDefinitionsConfiguration.challenges();
1717
var navigation =
18-
new Navigator(challenges, challenges.get(0));
18+
new Navigator(challenges, challenges.getFirst());
1919

2020
assertThat(navigation.previous()).isEmpty();
2121
}
@@ -24,15 +24,15 @@ void navigatePreviousWhenOnFirstChallenge() {
2424
void navigateNextWhenOnLastChallenge() {
2525
var challenges = challengeDefinitionsConfiguration.challenges();
2626
var navigation =
27-
new Navigator(challenges, challenges.get(challenges.size() - 1));
27+
new Navigator(challenges, challenges.getLast());
2828

2929
assertThat(navigation.next()).isEmpty();
3030
}
3131

3232
@Test
3333
void navigatePreviousAndNextOnSecondChallenge() {
3434
var challenges = challengeDefinitionsConfiguration.challenges();
35-
var first = challenges.get(0);
35+
var first = challenges.getFirst();
3636
var second = challenges.get(1);
3737
var third = challenges.get(2);
3838

0 commit comments

Comments
 (0)