#2661 Remove mocks of InetAddress (which is a sealed class in JDK 19)

- Remove mocks of InetAddress in favor of using real InetAddress instances. This fixes test issues under JDK 19, where InetAddress has been changed to a sealed class
This commit is contained in:
ljacqu
2022-12-30 08:27:51 +01:00
parent a14df80a87
commit 779e62674e
15 changed files with 63 additions and 45 deletions
@@ -1,6 +1,7 @@
package fr.xephi.authme.service;
import ch.jalu.configme.properties.Property;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import fr.xephi.authme.ConsoleLogger;
@@ -23,6 +24,7 @@ import org.bukkit.entity.Player;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import java.net.InetSocketAddress;
import java.util.Collection;
import java.util.List;
import java.util.Locale;
@@ -156,7 +158,7 @@ public class ValidationService implements Reloadable {
}
String ip = PlayerUtils.getPlayerIp(player);
String domain = player.getAddress().getHostName();
String domain = getHostName(player.getAddress());
for (String restriction : restrictions) {
if (restriction.startsWith("regex:")) {
restriction = restriction.replace("regex:", "");
@@ -173,6 +175,11 @@ public class ValidationService implements Reloadable {
return false;
}
@VisibleForTesting
protected String getHostName(InetSocketAddress inetSocketAddr) {
return inetSocketAddr.getHostName();
}
/**
* Verifies whether the given value is allowed according to the given whitelist and blacklist settings.
* Whitelist has precedence over blacklist: if a whitelist is set, the value is rejected if not present