Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ dependencies {
implementation("org.jfrog.buildinfo:build-info-extractor-gradle:5.2.5")
implementation("org.spongepowered:spongegradle-plugin-development:2.3.0")
implementation("fabric-loom:fabric-loom.gradle.plugin:1.15.3")
implementation("com.vanniktech:gradle-maven-publish-plugin:0.35.0")
}
8 changes: 4 additions & 4 deletions buildSrc/src/main/kotlin/CommonConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ fun Project.applyCommonConfiguration() {
}

dependencies {
"compileOnly"("org.projectlombok:lombok:1.18.36")
"annotationProcessor"("org.projectlombok:lombok:1.18.36")
"compileOnly"("org.projectlombok:lombok:1.18.38")
"annotationProcessor"("org.projectlombok:lombok:1.18.38")

"testCompileOnly"("org.projectlombok:lombok:1.18.36")
"testAnnotationProcessor"("org.projectlombok:lombok:1.18.36")
"testCompileOnly"("org.projectlombok:lombok:1.18.38")
"testAnnotationProcessor"("org.projectlombok:lombok:1.18.38")
}

configurations.all {
Expand Down
8 changes: 4 additions & 4 deletions buildSrc/src/main/kotlin/LibsConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ fun Project.applyLibrariesConfiguration() {
}

plugins.withId("java") {
the<JavaPluginExtension>().setSourceCompatibility("1.8")
the<JavaPluginExtension>().setTargetCompatibility("1.8")
the<JavaPluginExtension>().setSourceCompatibility("17")
the<JavaPluginExtension>().setTargetCompatibility("17")
}

group = "${rootProject.group}.BanManagerWebEnhancerLibs"
Expand Down Expand Up @@ -89,7 +89,7 @@ fun Project.applyLibrariesConfiguration() {
attribute(Category.CATEGORY_ATTRIBUTE, project.objects.named(Category.LIBRARY))
attribute(Bundling.BUNDLING_ATTRIBUTE, project.objects.named(Bundling.SHADOWED))
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, project.objects.named(LibraryElements.JAR))
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 8)
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 17)
}
outgoing.artifact(tasks.named("jar"))
}
Expand All @@ -104,7 +104,7 @@ fun Project.applyLibrariesConfiguration() {
attribute(Category.CATEGORY_ATTRIBUTE, project.objects.named(Category.LIBRARY))
attribute(Bundling.BUNDLING_ATTRIBUTE, project.objects.named(Bundling.SHADOWED))
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, project.objects.named(LibraryElements.JAR))
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 8)
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 17)
}
outgoing.artifact(tasks.named("jar"))
}
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/PlatformConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fun Project.applyPlatformAndCoreConfiguration() {

ext["internalVersion"] = "$version"

// Java 8 turns on doclint which we fail
// Suppress doclint to keep javadoc builds green; tags below document supported custom tags.
tasks.withType<Javadoc>().configureEach {
(options as StandardJavadocDocletOptions).apply {
addStringOption("Xdoclint:none", "-quiet")
Expand Down
2 changes: 1 addition & 1 deletion bukkit/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ dependencies {
exclude("junit", "junit")
}
compileOnly("org.apache.logging.log4j:log4j-core:2.17.0")
"shadeOnly"("org.bstats:bstats-bukkit:2.2.1")
"shadeOnly"("org.bstats:bstats-bukkit:3.2.1")
}

tasks.named<Copy>("processResources") {
Expand Down
2 changes: 1 addition & 1 deletion bungee/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ dependencies {
compileOnly("me.confuser.banmanager:BanManagerBungee:8.0.0-SNAPSHOT")

compileOnly("net.md-5:bungeecord-api:1.21-R0.4")
"shadeOnly"("org.bstats:bstats-bungeecord:2.2.1")
"shadeOnly"("org.bstats:bstats-bungeecord:3.2.1")
}

tasks.named<Copy>("processResources") {
Expand Down
22 changes: 12 additions & 10 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,26 @@ dependencies {
api("me.confuser.banmanager:BanManagerCommon:8.0.0-SNAPSHOT")
api("me.confuser.banmanager.BanManagerLibs:BanManagerLibs:8.0.0-SNAPSHOT")

// Test dependencies
testImplementation("junit:junit:4.13")
testImplementation("org.mockito:mockito-core:4.0.0")
testImplementation("org.powermock:powermock-module-junit4:2.0.2")
testImplementation("org.powermock:powermock-api-mockito2:2.0.2")
testImplementation("ch.vorburger.mariaDB4j:mariaDB4j:2.6.0")
testImplementation("org.awaitility:awaitility:4.0.1")
testImplementation(platform("org.junit:junit-bom:5.11.4"))
testImplementation("org.junit.jupiter:junit-jupiter")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
testImplementation("org.mockito:mockito-core:5.14.2")
testImplementation("org.mockito:mockito-junit-jupiter:5.14.2")
testImplementation("ch.vorburger.mariaDB4j:mariaDB4j:3.3.1")
testImplementation("org.awaitility:awaitility:4.3.0")
}

tasks.withType<Test>().configureEach {
useJUnit()
useJUnitPlatform()
maxHeapSize = "512m"
forkEvery = 1 // Fork a new JVM for each test class to prevent memory accumulation
// Fork a new JVM per test class - tests share JDBC/native fixtures that otherwise
// accumulate state across runs and hang the suite. See BanManager/common build.
forkEvery = 1
finalizedBy(tasks.jacocoTestReport)
}

jacoco {
toolVersion = "0.8.11"
toolVersion = "0.8.12"
}

tasks.jacocoTestReport {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package me.confuser.banmanager.webenhancer.common.data;

import me.confuser.banmanager.common.data.PlayerData;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.security.NoSuchAlgorithmException;
import java.util.UUID;

import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;

/**
Expand All @@ -23,8 +23,8 @@ public void shouldGenerateSixDigitPin() throws NoSuchAlgorithmException {
int pin = pinData.getGeneratedPin();

// 6 digit pin: 100000-999999
assertTrue("Pin should be at least 100000", pin >= 100000);
assertTrue("Pin should be at most 999999", pin <= 999999);
assertTrue(pin >= 100000, "Pin should be at least 100000");
assertTrue(pin <= 999999, "Pin should be at most 999999");
}

@Test
Expand All @@ -35,8 +35,8 @@ public void shouldHashPinWithArgon2() throws NoSuchAlgorithmException {
PlayerPinData pinData = new PlayerPinData(player);
String hashedPin = pinData.getPin();

assertNotNull("Hashed pin should not be null", hashedPin);
assertTrue("Pin should be hashed with Argon2i", hashedPin.startsWith("$argon2i$"));
assertNotNull(hashedPin, "Hashed pin should not be null");
assertTrue(hashedPin.startsWith("$argon2i$"), "Pin should be hashed with Argon2i");
}

@Test
Expand All @@ -52,8 +52,7 @@ public void shouldSetExpiryFiveMinutesFromNow() throws NoSuchAlgorithmException
long expires = pinData.getExpires();

// Allow 1 second tolerance for test execution
assertTrue("Expiry should be ~300 seconds from creation",
expires >= beforeCreate + 299 && expires <= afterCreate + 301);
assertTrue(expires >= beforeCreate + 299 && expires <= afterCreate + 301, "Expiry should be ~300 seconds from creation");
}

@Test
Expand All @@ -66,9 +65,8 @@ public void shouldStoreGeneratedPinForDisplay() throws NoSuchAlgorithmException
int generatedPin = pinData.getGeneratedPin();
String hashedPin = pinData.getPin();

assertNotEquals("Generated pin should not be 0", 0, generatedPin);
assertFalse("Hashed pin should not equal plaintext",
hashedPin.equals(String.valueOf(generatedPin)));
assertNotEquals(0, generatedPin, "Generated pin should not be 0");
assertFalse(hashedPin.equals(String.valueOf(generatedPin)), "Hashed pin should not equal plaintext");
}

@Test
Expand All @@ -78,7 +76,7 @@ public void shouldStorePlayerReference() throws NoSuchAlgorithmException {

PlayerPinData pinData = new PlayerPinData(player);

assertSame("Player reference should be stored", player, pinData.getPlayer());
assertSame(player, pinData.getPlayer(), "Player reference should be stored");
}

@Test
Expand All @@ -88,7 +86,7 @@ public void shouldHaveZeroIdBeforePersistence() throws NoSuchAlgorithmException

PlayerPinData pinData = new PlayerPinData(player);

assertEquals("ID should be 0 before persistence", 0, pinData.getId());
assertEquals(0, pinData.getId(), "ID should be 0 before persistence");
}

@Test
Expand All @@ -105,7 +103,7 @@ public void shouldGenerateRandomPins() throws NoSuchAlgorithmException {
pin1.getGeneratedPin() != pin3.getGeneratedPin() ||
pin2.getGeneratedPin() != pin3.getGeneratedPin();

assertTrue("At least two of three pins should differ", atLeastTwoDifferent);
assertTrue(atLeastTwoDifferent, "At least two of three pins should differ");
}

@Test
Expand All @@ -118,8 +116,7 @@ public void shouldGenerateUniqueHashesForSamePin() throws NoSuchAlgorithmExcepti

// Even if by chance the generated pins are the same, the hashes should differ
// due to unique random salts in Argon2
assertNotEquals("Hashes should differ due to random salts",
pin1.getPin(), pin2.getPin());
assertNotEquals(pin1.getPin(), pin2.getPin(), "Hashes should differ due to random salts");
}

@Test
Expand All @@ -130,6 +127,6 @@ public void generatedPinShouldBeSettable() throws NoSuchAlgorithmException {
PlayerPinData pinData = new PlayerPinData(player);
pinData.setGeneratedPin(999999);

assertEquals("Generated pin should be settable", 999999, pinData.getGeneratedPin());
assertEquals(999999, pinData.getGeneratedPin(), "Generated pin should be settable");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@
import me.confuser.banmanager.webenhancer.common.WebEnhancerPlugin;
import me.confuser.banmanager.webenhancer.common.data.PlayerPinData;
import me.confuser.banmanager.webenhancer.common.storage.PlayerPinStorage;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;

import static org.junit.Assert.*;
import static org.mockito.Mockito.*;

@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class CommonPlayerDeniedListenerTest {

@Mock
Expand All @@ -31,9 +30,9 @@ public class CommonPlayerDeniedListenerTest {

private CommonPlayerDeniedListener listener;

@Before
@BeforeEach
public void setUp() {
when(plugin.getPlayerPinStorage()).thenReturn(playerPinStorage);
lenient().when(plugin.getPlayerPinStorage()).thenReturn(playerPinStorage);
listener = new CommonPlayerDeniedListener(plugin);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package me.confuser.banmanager.webenhancer.common.security;

import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

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

/**
* Unit tests for Argon2PasswordEncoder.
Expand All @@ -12,7 +12,7 @@ public class Argon2PasswordEncoderTest {

private Argon2PasswordEncoder encoder;

@Before
@BeforeEach
public void setUp() {
encoder = new Argon2PasswordEncoder();
}
Expand All @@ -23,8 +23,8 @@ public void shouldEncodePassword() {

String encoded = encoder.encode(password);

assertNotNull("Encoded password should not be null", encoded);
assertNotEquals("Encoded password should differ from original", password, encoded);
assertNotNull(encoded, "Encoded password should not be null");
assertNotEquals(password, encoded, "Encoded password should differ from original");
}

@Test
Expand All @@ -34,7 +34,7 @@ public void shouldProduceArgon2iFormat() {
String encoded = encoder.encode(password);

// Argon2i format starts with $argon2i$
assertTrue("Hash should use Argon2i format", encoded.startsWith("$argon2i$"));
assertTrue(encoded.startsWith("$argon2i$"), "Hash should use Argon2i format");
}

@Test
Expand All @@ -44,7 +44,7 @@ public void shouldGenerateUniqueSaltsForSameInput() {
String encoded1 = encoder.encode(password);
String encoded2 = encoder.encode(password);

assertNotEquals("Hashes should differ due to unique salts", encoded1, encoded2);
assertNotEquals(encoded1, encoded2, "Hashes should differ due to unique salts");
}

@Test
Expand All @@ -53,7 +53,7 @@ public void shouldProduceCorrectHashLength() {

String encoded = encoder.encode(password);

assertTrue("Hash string should be substantial", encoded.length() > 50);
assertTrue(encoded.length() > 50, "Hash string should be substantial");
}

@Test
Expand All @@ -62,8 +62,8 @@ public void shouldHandleEmptyPassword() {

String encoded = encoder.encode(password);

assertNotNull("Should handle empty password", encoded);
assertTrue("Should still produce Argon2i format", encoded.startsWith("$argon2i$"));
assertNotNull(encoded, "Should handle empty password");
assertTrue(encoded.startsWith("$argon2i$"), "Should still produce Argon2i format");
}

@Test
Expand All @@ -75,8 +75,8 @@ public void shouldHandleLongPassword() {

String encoded = encoder.encode(longPassword.toString());

assertNotNull("Should handle long password", encoded);
assertTrue("Should still produce Argon2i format", encoded.startsWith("$argon2i$"));
assertNotNull(encoded, "Should handle long password");
assertTrue(encoded.startsWith("$argon2i$"), "Should still produce Argon2i format");
}

@Test
Expand All @@ -85,8 +85,8 @@ public void shouldHandleSpecialCharacters() {

String encoded = encoder.encode(password);

assertNotNull("Should handle special characters", encoded);
assertTrue("Should still produce Argon2i format", encoded.startsWith("$argon2i$"));
assertNotNull(encoded, "Should handle special characters");
assertTrue(encoded.startsWith("$argon2i$"), "Should still produce Argon2i format");
}

@Test
Expand All @@ -96,14 +96,14 @@ public void shouldHandleNumericPin() {

String encoded = encoder.encode(pin);

assertNotNull("Should handle numeric PIN", encoded);
assertTrue("Should produce Argon2i format", encoded.startsWith("$argon2i$"));
assertNotNull(encoded, "Should handle numeric PIN");
assertTrue(encoded.startsWith("$argon2i$"), "Should produce Argon2i format");

// Verify format contains expected parameters
assertTrue("Should contain version", encoded.contains("v="));
assertTrue("Should contain memory parameter", encoded.contains("m="));
assertTrue("Should contain time parameter", encoded.contains("t="));
assertTrue("Should contain parallelism parameter", encoded.contains("p="));
assertTrue(encoded.contains("v="), "Should contain version");
assertTrue(encoded.contains("m="), "Should contain memory parameter");
assertTrue(encoded.contains("t="), "Should contain time parameter");
assertTrue(encoded.contains("p="), "Should contain parallelism parameter");
}

@Test
Expand All @@ -117,6 +117,6 @@ public void shouldProduceConsistentFormatAcrossMultipleCalls() {

String format2 = encoded2.substring(0, encoded2.indexOf("$", 9));

assertEquals("Both instances should produce same format", format1, format2);
assertEquals(format1, format2, "Both instances should produce same format");
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ group=me.confuser.banmanager.webenhancer
version=8.0.0-SNAPSHOT
org.gradle.parallel=true

org.gradle.jvmargs=-Xmx2G -XX:+UseG1GC -XX:MaxGCPauseMillis=200
org.gradle.jvmargs=-Xmx2G -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -XX:+UseStringDeduplication
Loading
Loading