#699 Unit test that config.yml values correspond to property defaults
- Create unit test - Correct offending values
This commit is contained in:
parent
3673e15ff7
commit
223f56425b
@ -32,7 +32,7 @@ public class DatabaseSettings implements SettingsClass {
|
|||||||
|
|
||||||
@Comment("Password about Database Connection Infos")
|
@Comment("Password about Database Connection Infos")
|
||||||
public static final Property<String> MYSQL_PASSWORD =
|
public static final Property<String> MYSQL_PASSWORD =
|
||||||
newProperty("DataSource.mySQLPassword", "123456");
|
newProperty("DataSource.mySQLPassword", "12345");
|
||||||
|
|
||||||
@Comment("Database Name, use with converters or as SQLITE database name")
|
@Comment("Database Name, use with converters or as SQLITE database name")
|
||||||
public static final Property<String> MYSQL_DATABASE =
|
public static final Property<String> MYSQL_DATABASE =
|
||||||
|
|||||||
@ -25,7 +25,7 @@ public class HooksSettings implements SettingsClass {
|
|||||||
|
|
||||||
@Comment("Do we need to disable Essentials SocialSpy on join?")
|
@Comment("Do we need to disable Essentials SocialSpy on join?")
|
||||||
public static final Property<Boolean> DISABLE_SOCIAL_SPY =
|
public static final Property<Boolean> DISABLE_SOCIAL_SPY =
|
||||||
newProperty("Hooks.disableSocialSpy", false);
|
newProperty("Hooks.disableSocialSpy", true);
|
||||||
|
|
||||||
@Comment("Do we need to force /motd Essentials command on join?")
|
@Comment("Do we need to force /motd Essentials command on join?")
|
||||||
public static final Property<Boolean> USE_ESSENTIALS_MOTD =
|
public static final Property<Boolean> USE_ESSENTIALS_MOTD =
|
||||||
|
|||||||
@ -19,12 +19,12 @@ public class ProtectionSettings implements SettingsClass {
|
|||||||
@Comment({"Countries allowed to join the server and register, see http://dev.bukkit.org/bukkit-plugins/authme-reloaded/pages/countries-codes/ for countries' codes",
|
@Comment({"Countries allowed to join the server and register, see http://dev.bukkit.org/bukkit-plugins/authme-reloaded/pages/countries-codes/ for countries' codes",
|
||||||
"PLEASE USE QUOTES!"})
|
"PLEASE USE QUOTES!"})
|
||||||
public static final Property<List<String>> COUNTRIES_WHITELIST =
|
public static final Property<List<String>> COUNTRIES_WHITELIST =
|
||||||
newListProperty("Protection.countries", "US", "GB", "A1");
|
newListProperty("Protection.countries", "US", "GB");
|
||||||
|
|
||||||
@Comment({"Countries not allowed to join the server and register",
|
@Comment({"Countries not allowed to join the server and register",
|
||||||
"PLEASE USE QUOTES!"})
|
"PLEASE USE QUOTES!"})
|
||||||
public static final Property<List<String>> COUNTRIES_BLACKLIST =
|
public static final Property<List<String>> COUNTRIES_BLACKLIST =
|
||||||
newListProperty("Protection.countriesBlacklist");
|
newListProperty("Protection.countriesBlacklist", "A1");
|
||||||
|
|
||||||
@Comment("Do we need to enable automatic antibot system?")
|
@Comment("Do we need to enable automatic antibot system?")
|
||||||
public static final Property<Boolean> ENABLE_ANTIBOT =
|
public static final Property<Boolean> ENABLE_ANTIBOT =
|
||||||
|
|||||||
@ -31,7 +31,7 @@ public class RestrictionSettings implements SettingsClass {
|
|||||||
@Comment("Allowed commands for unauthenticated players")
|
@Comment("Allowed commands for unauthenticated players")
|
||||||
public static final Property<List<String>> ALLOW_COMMANDS =
|
public static final Property<List<String>> ALLOW_COMMANDS =
|
||||||
newListProperty("settings.restrictions.allowCommands",
|
newListProperty("settings.restrictions.allowCommands",
|
||||||
"login", "register", "l", "reg", "email", "captcha");
|
"/login", "/register", "/l", "/reg", "/email", "/captcha");
|
||||||
|
|
||||||
@Comment({
|
@Comment({
|
||||||
"Max number of allowed registrations per IP",
|
"Max number of allowed registrations per IP",
|
||||||
|
|||||||
@ -108,12 +108,11 @@ settings:
|
|||||||
# AllowedRestrctedUser field.
|
# AllowedRestrctedUser field.
|
||||||
AllowRestrictedUser: false
|
AllowRestrictedUser: false
|
||||||
# The restricted user feature will kick players listed below
|
# The restricted user feature will kick players listed below
|
||||||
# if they dont match of the defined ip address.
|
# if they don't match of the defined ip address.
|
||||||
# Example:
|
# Example:
|
||||||
# AllowedRestrictedUser:
|
# AllowedRestrictedUser:
|
||||||
# - playername;127.0.0.1
|
# - playername;127.0.0.1
|
||||||
AllowedRestrictedUser:
|
AllowedRestrictedUser: []
|
||||||
- playername;127.0.0.1
|
|
||||||
# Should unregistered players be kicked immediately?
|
# Should unregistered players be kicked immediately?
|
||||||
kickNonRegistered: false
|
kickNonRegistered: false
|
||||||
# Should players be kicked on wrong password?
|
# Should players be kicked on wrong password?
|
||||||
@ -263,11 +262,11 @@ settings:
|
|||||||
# Do we need to broadcast the welcome message to all server or only to the player? set true for server or false for player
|
# Do we need to broadcast the welcome message to all server or only to the player? set true for server or false for player
|
||||||
broadcastWelcomeMessage: false
|
broadcastWelcomeMessage: false
|
||||||
# Should we delay the join message and display it once the player has logged in?
|
# Should we delay the join message and display it once the player has logged in?
|
||||||
delayJoinMessage: true
|
delayJoinMessage: false
|
||||||
# Should we remove join messages altogether?
|
# Should we remove join messages altogether?
|
||||||
removeJoinMessage: true
|
removeJoinMessage: false
|
||||||
# Should we remove leave messages?
|
# Should we remove leave messages?
|
||||||
removeLeaveMessage: true
|
removeLeaveMessage: false
|
||||||
# Do we need to add potion effect Blinding before login/register?
|
# Do we need to add potion effect Blinding before login/register?
|
||||||
applyBlindEffect: false
|
applyBlindEffect: false
|
||||||
# Do we need to prevent people to login with another case?
|
# Do we need to prevent people to login with another case?
|
||||||
@ -307,7 +306,7 @@ BackupSystem:
|
|||||||
# set Backup at every stop of Server
|
# set Backup at every stop of Server
|
||||||
OnServerStop: true
|
OnServerStop: true
|
||||||
# Windows only mysql installation Path
|
# Windows only mysql installation Path
|
||||||
MysqlWindowsPath: 'C:\\Program Files\\MySQL\\MySQL Server 5.1\\'
|
MysqlWindowsPath: 'C:\Program Files\MySQL\MySQL Server 5.1\'
|
||||||
Security:
|
Security:
|
||||||
SQLProblem:
|
SQLProblem:
|
||||||
# Stop the server if we can't contact the sql database
|
# Stop the server if we can't contact the sql database
|
||||||
@ -360,7 +359,7 @@ Email:
|
|||||||
# Random password length
|
# Random password length
|
||||||
RecoveryPasswordLength: 8
|
RecoveryPasswordLength: 8
|
||||||
# Email subject of password get
|
# Email subject of password get
|
||||||
mailSubject: 'Your new AuthMe Password'
|
mailSubject: 'Your new AuthMe password'
|
||||||
# Like maxRegPerIp but with email
|
# Like maxRegPerIp but with email
|
||||||
maxRegPerEmail: 1
|
maxRegPerEmail: 1
|
||||||
# Recall players to add an email?
|
# Recall players to add an email?
|
||||||
|
|||||||
@ -12,13 +12,14 @@ import org.junit.Test;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
import static org.junit.Assert.assertThat;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -56,9 +57,8 @@ public class ConfigFileConsistencyTest {
|
|||||||
@Test
|
@Test
|
||||||
public void shouldNotHaveUnknownConfigs() {
|
public void shouldNotHaveUnknownConfigs() {
|
||||||
// given
|
// given
|
||||||
URL url = this.getClass().getResource(CONFIG_FILE);
|
File configFile = TestHelper.getJarFile(CONFIG_FILE);
|
||||||
File configFile = new File(url.getFile());
|
FileConfiguration configuration = YamlConfiguration.loadConfiguration(configFile);
|
||||||
YamlConfiguration configuration = YamlConfiguration.loadConfiguration(configFile);
|
|
||||||
Map<String, Object> allReadProperties = configuration.getValues(true);
|
Map<String, Object> allReadProperties = configuration.getValues(true);
|
||||||
Set<String> knownKeys = getAllKnownPropertyPaths();
|
Set<String> knownKeys = getAllKnownPropertyPaths();
|
||||||
|
|
||||||
@ -78,6 +78,20 @@ public class ConfigFileConsistencyTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldHaveValueCorrespondingToPropertyDefault() {
|
||||||
|
// given
|
||||||
|
File configFile = TestHelper.getJarFile(CONFIG_FILE);
|
||||||
|
FileConfiguration configuration = YamlConfiguration.loadConfiguration(configFile);
|
||||||
|
PropertyMap propertyMap = SettingsFieldRetriever.getAllPropertyFields();
|
||||||
|
|
||||||
|
// when / then
|
||||||
|
for (Property<?> property : propertyMap.keySet()) {
|
||||||
|
assertThat("Default value of '" + property.getPath() + "' in config.yml should be the same as in Property",
|
||||||
|
property.getFromFile(configuration), equalTo(property.getDefaultValue()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Set<String> getAllKnownPropertyPaths() {
|
private static Set<String> getAllKnownPropertyPaths() {
|
||||||
PropertyMap propertyMap = SettingsFieldRetriever.getAllPropertyFields();
|
PropertyMap propertyMap = SettingsFieldRetriever.getAllPropertyFields();
|
||||||
Set<String> paths = new HashSet<>(propertyMap.size());
|
Set<String> paths = new HashSet<>(propertyMap.size());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user