From d0b7d0ff069be63834b432c61e637ee42ab17dda Mon Sep 17 00:00:00 2001 From: ljacqu Date: Fri, 8 Jan 2016 23:20:42 +0100 Subject: [PATCH] #347 Create consistency and integration tests for NewSetting - Ensure that the project's config.yml contains all settings that NewSetting is aware of - Add extensive, more generic integration tests --- .../authme/settings/custom/HooksSettings.java | 2 +- .../authme/settings/custom/NewSetting.java | 34 +++- .../authme/settings/custom/PurgeSettings.java | 2 +- src/main/resources/config.yml | 2 + .../custom/ConfigFileConsistencyTest.java | 35 ++++ .../custom/NewSettingIntegrationTest.java | 113 ++++++++++++ .../settings/custom/NewSettingTest.java | 122 +++++-------- .../settings/custom/NewSettingsWriteTest.java | 41 ----- .../settings/custom/TestConfiguration.java | 46 +++++ src/test/resources/437-config-test.yml | 44 ----- src/test/resources/437-write-test.yml | 172 ------------------ .../resources/config-incomplete-sample.yml | 27 +++ src/test/resources/config-sample-values.yml | 27 +++ 13 files changed, 329 insertions(+), 338 deletions(-) create mode 100644 src/test/java/fr/xephi/authme/settings/custom/ConfigFileConsistencyTest.java create mode 100644 src/test/java/fr/xephi/authme/settings/custom/NewSettingIntegrationTest.java delete mode 100644 src/test/java/fr/xephi/authme/settings/custom/NewSettingsWriteTest.java create mode 100644 src/test/java/fr/xephi/authme/settings/custom/TestConfiguration.java delete mode 100644 src/test/resources/437-config-test.yml delete mode 100644 src/test/resources/437-write-test.yml create mode 100644 src/test/resources/config-incomplete-sample.yml create mode 100644 src/test/resources/config-sample-values.yml diff --git a/src/main/java/fr/xephi/authme/settings/custom/HooksSettings.java b/src/main/java/fr/xephi/authme/settings/custom/HooksSettings.java index 6e23c7398..707821e05 100644 --- a/src/main/java/fr/xephi/authme/settings/custom/HooksSettings.java +++ b/src/main/java/fr/xephi/authme/settings/custom/HooksSettings.java @@ -19,7 +19,7 @@ public class HooksSettings implements SettingsClass { @Comment("Send player to this BungeeCord server after register/login") public static final Property BUNGEECORD_SERVER = - newProperty(PropertyType.STRING, "bungeecord.server", ""); + newProperty(PropertyType.STRING, "Hooks.sendPlayerTo", ""); @Comment("Do we need to disable Essentials SocialSpy on join?") public static final Property DISABLE_SOCIAL_SPY = diff --git a/src/main/java/fr/xephi/authme/settings/custom/NewSetting.java b/src/main/java/fr/xephi/authme/settings/custom/NewSetting.java index 86a15b0d5..00aa9220e 100644 --- a/src/main/java/fr/xephi/authme/settings/custom/NewSetting.java +++ b/src/main/java/fr/xephi/authme/settings/custom/NewSetting.java @@ -24,6 +24,12 @@ public class NewSetting { private File file; private YamlConfiguration configuration; + /** + * Constructor. + * Loads the file as YAML and checks its integrity. + * + * @param file The configuration file + */ public NewSetting(File file) { this.configuration = YamlConfiguration.loadConfiguration(file); this.file = file; @@ -34,12 +40,33 @@ public class NewSetting { } } + /** + * Simple constructor for testing purposes. Does not check for all properties and + * never saves to the file. + * + * @param yamlConfiguration The YamlConfiguration object to use + * @param file The file to write to + * @param propertyMap The property map whose properties should be verified for presence, or null to skip this + */ @VisibleForTesting - NewSetting(YamlConfiguration yamlConfiguration, String file) { + NewSetting(YamlConfiguration yamlConfiguration, File file, PropertyMap propertyMap) { this.configuration = yamlConfiguration; - this.file = new File(file); + this.file = file; + + if (propertyMap != null) { + if (!containsAllSettings(propertyMap)) { + save(propertyMap); + } + } } + /** + * Get the given property from the configuration. + * + * @param property The property to retrieve + * @param The property's type + * @return The property's value + */ public T getOption(Property property) { return property.getFromFile(configuration); } @@ -105,7 +132,8 @@ public class NewSetting { } } - private boolean containsAllSettings(PropertyMap propertyMap) { + @VisibleForTesting + boolean containsAllSettings(PropertyMap propertyMap) { for (Property property : propertyMap.keySet()) { if (!property.isPresent(configuration)) { return false; diff --git a/src/main/java/fr/xephi/authme/settings/custom/PurgeSettings.java b/src/main/java/fr/xephi/authme/settings/custom/PurgeSettings.java index e2e1c0290..cff4a7c98 100644 --- a/src/main/java/fr/xephi/authme/settings/custom/PurgeSettings.java +++ b/src/main/java/fr/xephi/authme/settings/custom/PurgeSettings.java @@ -25,7 +25,7 @@ public class PurgeSettings implements SettingsClass { @Comment("Do we need to remove the Essentials/users/player.yml file during purge process?") public static final Property REMOVE_ESSENTIALS_FILES = - newProperty(BOOLEAN, "Purge.removeEssentialsFiles", false); + newProperty(BOOLEAN, "Purge.removeEssentialsFile", false); @Comment("World where are players.dat stores") public static final Property DEFAULT_WORLD = diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index a98d97393..1e0b6491a 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -355,6 +355,8 @@ Email: emailWhitelisted: [] # Do we need to send new password draw in an image? generateImage: false + # The email OAuth 2 token (leave empty if not used) + emailOauth2Token: '' Hooks: # Do we need to hook with multiverse for spawn checking? multiverse: true diff --git a/src/test/java/fr/xephi/authme/settings/custom/ConfigFileConsistencyTest.java b/src/test/java/fr/xephi/authme/settings/custom/ConfigFileConsistencyTest.java new file mode 100644 index 000000000..b5bdc4df9 --- /dev/null +++ b/src/test/java/fr/xephi/authme/settings/custom/ConfigFileConsistencyTest.java @@ -0,0 +1,35 @@ +package fr.xephi.authme.settings.custom; + +import org.junit.Test; + +import java.io.File; +import java.io.IOException; +import java.net.URL; + +import static org.hamcrest.Matchers.equalTo; +import static org.junit.Assert.assertThat; +import static org.junit.Assume.assumeThat; + +/** + * Test for {@link NewSetting} and the project's config.yml, + * verifying that no settings are missing from the file. + */ +public class ConfigFileConsistencyTest { + + @Test + public void shouldHaveAllConfigs() throws IOException { + URL url = this.getClass().getResource("/config.yml"); + File configFile = new File(url.getFile()); + + // given + assumeThat(configFile.exists(), equalTo(true)); + NewSetting settings = new NewSetting(configFile); + + // when + boolean result = settings.containsAllSettings(SettingsFieldRetriever.getAllPropertyFields()); + + // then + assertThat(result, equalTo(true)); + } + +} diff --git a/src/test/java/fr/xephi/authme/settings/custom/NewSettingIntegrationTest.java b/src/test/java/fr/xephi/authme/settings/custom/NewSettingIntegrationTest.java new file mode 100644 index 000000000..8e6801fe6 --- /dev/null +++ b/src/test/java/fr/xephi/authme/settings/custom/NewSettingIntegrationTest.java @@ -0,0 +1,113 @@ +package fr.xephi.authme.settings.custom; + +import com.google.common.collect.ImmutableMap; +import fr.xephi.authme.ReflectionTestUtils; +import fr.xephi.authme.settings.domain.Property; +import fr.xephi.authme.settings.propertymap.PropertyMap; +import org.bukkit.configuration.file.YamlConfiguration; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.io.File; +import java.lang.reflect.Field; +import java.net.URL; +import java.util.Arrays; +import java.util.Collections; +import java.util.Map; + +import static org.hamcrest.Matchers.equalTo; +import static org.junit.Assert.assertThat; +import static org.junit.Assume.assumeThat; + +/** + * Integration test for {@link NewSetting}. + */ +public class NewSettingIntegrationTest { + + /** File name of the sample config including all {@link TestConfiguration} values. */ + private static final String COMPLETE_FILE = "config-sample-values.yml"; + /** File name of the sample config missing certain {@link TestConfiguration} values. */ + private static final String INCOMPLETE_FILE = "config-incomplete-sample.yml"; + + private static PropertyMap propertyMap; + + @BeforeClass + public static void generatePropertyMap() { + propertyMap = new PropertyMap(); + for (Field field : TestConfiguration.class.getDeclaredFields()) { + Property property = + (Property) ReflectionTestUtils.getFieldValue(TestConfiguration.class, null, field.getName()); + String[] comments = new String[]{"Comment for '" + property.getPath() + "'"}; + propertyMap.put(property, comments); + } + } + + @Test + public void shouldLoadAndReadAllProperties() { + // given + YamlConfiguration configuration = YamlConfiguration.loadConfiguration(getConfigFile(COMPLETE_FILE)); + File file = new File("unused"); + assumeThat(file.exists(), equalTo(false)); + + // when / then + NewSetting settings = new NewSetting(configuration, file, propertyMap); + Map, Object> expectedValues = ImmutableMap., Object>builder() + .put(TestConfiguration.DURATION_IN_SECONDS, 22) + .put(TestConfiguration.SYSTEM_NAME, "Custom sys name") + .put(TestConfiguration.RATIO_LIMIT, -4.1) + .put(TestConfiguration.RATIO_FIELDS, Arrays.asList("Australia", "Burundi", "Colombia")) + .put(TestConfiguration.VERSION_NUMBER, 2492) + .put(TestConfiguration.SKIP_BORING_FEATURES, false) + .put(TestConfiguration.BORING_COLORS, Arrays.asList("beige", "gray")) + .put(TestConfiguration.DUST_LEVEL, 0.81) + .put(TestConfiguration.USE_COOL_FEATURES, true) + .put(TestConfiguration.COOL_OPTIONS, Arrays.asList("Dinosaurs", "Explosions", "Big trucks")) + .build(); + for (Map.Entry, Object> entry : expectedValues.entrySet()) { + assertThat("Property '" + entry.getKey().getPath() + "' has expected value", + settings.getOption(entry.getKey()), equalTo(entry.getValue())); + } + assertThat(file.exists(), equalTo(false)); + } + + @Test + public void shouldWriteMissingProperties() { + // given/when + File file = getConfigFile(INCOMPLETE_FILE); + YamlConfiguration configuration = YamlConfiguration.loadConfiguration(file); + assumeThat(configuration.contains(TestConfiguration.BORING_COLORS.getPath()), equalTo(false)); + // Expectation: File is rewritten to since it does not have all configurations + new NewSetting(configuration, file, propertyMap); + + // Load the settings again -> checks that what we wrote can be loaded again + configuration = YamlConfiguration.loadConfiguration(file); + + // then + NewSetting settings = new NewSetting(configuration, file, propertyMap); + Map, Object> expectedValues = ImmutableMap., Object>builder() + .put(TestConfiguration.DURATION_IN_SECONDS, 22) + .put(TestConfiguration.SYSTEM_NAME, "[TestDefaultValue]") + .put(TestConfiguration.RATIO_LIMIT, 3.0) + .put(TestConfiguration.RATIO_FIELDS, Arrays.asList("Australia", "Burundi", "Colombia")) + .put(TestConfiguration.VERSION_NUMBER, 32046) + .put(TestConfiguration.SKIP_BORING_FEATURES, false) + .put(TestConfiguration.BORING_COLORS, Collections.EMPTY_LIST) + .put(TestConfiguration.DUST_LEVEL, 0.2) + .put(TestConfiguration.USE_COOL_FEATURES, false) + .put(TestConfiguration.COOL_OPTIONS, Arrays.asList("Dinosaurs", "Explosions", "Big trucks")) + .build(); + for (Map.Entry, Object> entry : expectedValues.entrySet()) { + assertThat("Property '" + entry.getKey().getPath() + "' has expected value", + settings.getOption(entry.getKey()), equalTo(entry.getValue())); + } + } + + private File getConfigFile(String file) { + URL url = getClass().getClassLoader().getResource(file); + if (url == null) { + throw new IllegalStateException("File '" + file + "' could not be loaded"); + } + return new File(url.getFile()); + } + +} diff --git a/src/test/java/fr/xephi/authme/settings/custom/NewSettingTest.java b/src/test/java/fr/xephi/authme/settings/custom/NewSettingTest.java index 419d5917c..080e1d0d0 100644 --- a/src/test/java/fr/xephi/authme/settings/custom/NewSettingTest.java +++ b/src/test/java/fr/xephi/authme/settings/custom/NewSettingTest.java @@ -1,114 +1,84 @@ package fr.xephi.authme.settings.custom; -import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.settings.domain.Property; -import fr.xephi.authme.settings.domain.PropertyType; import org.bukkit.configuration.file.YamlConfiguration; import org.junit.Test; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import java.io.File; -import java.net.URL; -import java.util.List; -import static fr.xephi.authme.settings.domain.Property.newProperty; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.equalTo; import static org.mockito.BDDMockito.given; import static org.mockito.Matchers.anyBoolean; +import static org.mockito.Matchers.anyDouble; import static org.mockito.Matchers.anyInt; import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; +/** + * Test for {@link NewSetting}. + */ public class NewSettingTest { - private static final String CONFIG_FILE = "437-config-test.yml"; - - @Test - public void shouldReturnIntegerFromFile() { - // given - YamlConfiguration file = mock(YamlConfiguration.class); - Property config = TestConfiguration.DURATION_IN_SECONDS; - given(file.getInt("test.duration", 4)).willReturn(18); - NewSetting settings = new NewSetting(file, "conf.txt"); - - // when - int retrieve = settings.getOption(config); - - // then - assertThat(retrieve, equalTo(18)); - } - @Test public void shouldLoadAllConfigs() { // given YamlConfiguration file = mock(YamlConfiguration.class); + given(file.getString(anyString(), anyString())).willAnswer(withDefaultArgument()); + given(file.getBoolean(anyString(), anyBoolean())).willAnswer(withDefaultArgument()); + given(file.getDouble(anyString(), anyDouble())).willAnswer(withDefaultArgument()); + given(file.getInt(anyString(), anyInt())).willAnswer(withDefaultArgument()); - given(file.getString(anyString(), anyString())).willAnswer(new Answer() { - @Override - public String answer(InvocationOnMock invocation) throws Throwable { - // Return the second parameter -> the default - return (String) invocation.getArguments()[1]; - } - }); + setReturnValue(file, TestConfiguration.VERSION_NUMBER, 20); + setReturnValue(file, TestConfiguration.SKIP_BORING_FEATURES, true); + setReturnValue(file, TestConfiguration.RATIO_LIMIT, 4.25); + setReturnValue(file, TestConfiguration.SYSTEM_NAME, "myTestSys"); - given(file.getInt(eq(EmailSettings.RECOVERY_PASSWORD_LENGTH.getPath()), anyInt())) - .willReturn(20); - given(file.getBoolean(eq(SecuritySettings.REMOVE_PASSWORD_FROM_CONSOLE.getPath()), anyBoolean())) - .willReturn(false); + // when / then + NewSetting settings = new NewSetting(file, new File("conf.txt"), null); - // when - NewSetting settings = new NewSetting(file, "conf.txt"); + assertThat(settings.getOption(TestConfiguration.VERSION_NUMBER), equalTo(20)); + assertThat(settings.getOption(TestConfiguration.SKIP_BORING_FEATURES), equalTo(true)); + assertThat(settings.getOption(TestConfiguration.RATIO_LIMIT), equalTo(4.25)); + assertThat(settings.getOption(TestConfiguration.SYSTEM_NAME), equalTo("myTestSys")); - // then - // Expect the value we told the YAML mock to return: - assertThat(settings.getOption(EmailSettings.RECOVERY_PASSWORD_LENGTH), equalTo(20)); - // Expect the default: - assertThat(settings.getOption(EmailSettings.SMTP_HOST), equalTo(EmailSettings.SMTP_HOST.getDefaultValue())); - // Expect the value we told the YAML mock to return: - assertThat(settings.getOption(SecuritySettings.REMOVE_PASSWORD_FROM_CONSOLE), equalTo(false)); + assertDefaultValue(TestConfiguration.DURATION_IN_SECONDS, settings); + assertDefaultValue(TestConfiguration.DUST_LEVEL, settings); + assertDefaultValue(TestConfiguration.COOL_OPTIONS, settings); } - @Test - public void executeIntegrationTest() { - // given - YamlConfiguration yamlFile = YamlConfiguration.loadConfiguration(getConfigFile()); - NewSetting settings = new NewSetting(yamlFile, "conf.txt"); - - // when - int result = settings.getOption(TestConfiguration.DURATION_IN_SECONDS); - String systemName = settings.getOption(TestConfiguration.SYSTEM_NAME); - String helpHeader = settings.getOption(newProperty("settings.helpHeader", "")); - List unsafePasswords = settings.getOption( - newProperty(PropertyType.STRING_LIST, "Security.unsafePasswords")); - DataSource.DataSourceType dataSourceType = settings.getOption(DatabaseSettings.BACKEND); - - // then - assertThat(result, equalTo(22)); - assertThat(systemName, equalTo(TestConfiguration.SYSTEM_NAME.getDefaultValue())); - assertThat(helpHeader, equalTo("AuthMeReloaded")); - assertThat(unsafePasswords, contains("123456", "qwerty", "54321")); - assertThat(dataSourceType, equalTo(DataSource.DataSourceType.MYSQL)); - } - - private File getConfigFile() { - URL url = getClass().getClassLoader().getResource(CONFIG_FILE); - if (url == null) { - throw new RuntimeException("File '" + CONFIG_FILE + "' could not be loaded"); + private static void setReturnValue(YamlConfiguration config, Property property, T value) { + if (value instanceof String) { + when(config.getString(eq(property.getPath()), anyString())).thenReturn((String) value); + } else if (value instanceof Integer) { + when(config.getInt(eq(property.getPath()), anyInt())).thenReturn((Integer) value); + } else if (value instanceof Boolean) { + when(config.getBoolean(eq(property.getPath()), anyBoolean())).thenReturn((Boolean) value); + } else if (value instanceof Double) { + when(config.getDouble(eq(property.getPath()), anyDouble())).thenReturn((Double) value); + } else { + throw new UnsupportedOperationException("Value has unsupported type '" + + (value == null ? "null" : value.getClass().getSimpleName()) + "'"); } - return new File(url.getFile()); } - private static class TestConfiguration { + private static void assertDefaultValue(Property property, NewSetting setting) { + assertThat(property.getPath() + " has default value", + setting.getOption(property).equals(property.getDefaultValue()), equalTo(true)); + } - public static final Property DURATION_IN_SECONDS = - newProperty("test.duration", 4); - - public static final Property SYSTEM_NAME = - newProperty("test.systemName", "[TestDefaultValue]"); + private static Answer withDefaultArgument() { + return new Answer() { + @Override + public T answer(InvocationOnMock invocation) throws Throwable { + // Return the second parameter -> the default + return (T) invocation.getArguments()[1]; + } + }; } } diff --git a/src/test/java/fr/xephi/authme/settings/custom/NewSettingsWriteTest.java b/src/test/java/fr/xephi/authme/settings/custom/NewSettingsWriteTest.java deleted file mode 100644 index ab7e763db..000000000 --- a/src/test/java/fr/xephi/authme/settings/custom/NewSettingsWriteTest.java +++ /dev/null @@ -1,41 +0,0 @@ -package fr.xephi.authme.settings.custom; - -import org.junit.Test; - -import java.io.File; -import java.net.URL; - -import static org.junit.Assert.assertThat; -import static org.hamcrest.Matchers.equalTo; - -/** - * Test for the save() function of new settings - */ -public class NewSettingsWriteTest { - - private static final String CONFIG_FILE = "437-write-test.yml"; - - @Test - public void shouldWriteProperties() { - File file = getConfigFile(); - NewSetting setting = new NewSetting(file); - setting.save(); - - // assert that we can load the file again -- i.e. that it's valid YAML! - NewSetting newSetting = new NewSetting(file); - assertThat(newSetting.getOption(SecuritySettings.CAPTCHA_LENGTH), - equalTo(SecuritySettings.CAPTCHA_LENGTH.getDefaultValue())); - assertThat(newSetting.getOption(ProtectionSettings.COUNTRIES_BLACKLIST), - equalTo(ProtectionSettings.COUNTRIES_BLACKLIST.getDefaultValue())); - } - - - private File getConfigFile() { - URL url = getClass().getClassLoader().getResource(CONFIG_FILE); - if (url == null) { - throw new RuntimeException("File '" + CONFIG_FILE + "' could not be loaded"); - } - return new File(url.getFile()); - } - -} diff --git a/src/test/java/fr/xephi/authme/settings/custom/TestConfiguration.java b/src/test/java/fr/xephi/authme/settings/custom/TestConfiguration.java new file mode 100644 index 000000000..5f43262c7 --- /dev/null +++ b/src/test/java/fr/xephi/authme/settings/custom/TestConfiguration.java @@ -0,0 +1,46 @@ +package fr.xephi.authme.settings.custom; + +import fr.xephi.authme.settings.domain.Property; +import fr.xephi.authme.settings.domain.PropertyType; +import fr.xephi.authme.settings.domain.SettingsClass; + +import java.util.List; + +import static fr.xephi.authme.settings.domain.Property.newProperty; + +/** + * Sample properties for testing purposes. + */ +class TestConfiguration implements SettingsClass { + + public static final Property DURATION_IN_SECONDS = + newProperty("test.duration", 4); + + public static final Property SYSTEM_NAME = + newProperty("test.systemName", "[TestDefaultValue]"); + + public static final Property RATIO_LIMIT = + newProperty(PropertyType.DOUBLE, "sample.ratio.limit", 3.0); + + public static final Property> RATIO_FIELDS = + newProperty(PropertyType.STRING_LIST, "sample.ratio.fields", "a", "b", "c"); + + public static final Property VERSION_NUMBER = + newProperty("version", 32046); + + public static final Property SKIP_BORING_FEATURES = + newProperty("features.boring.skip", false); + + public static final Property> BORING_COLORS = + newProperty(PropertyType.STRING_LIST, "features.boring.colors"); + + public static final Property DUST_LEVEL = + newProperty(PropertyType.DOUBLE, "features.boring.dustLevel", 0.2); + + public static final Property USE_COOL_FEATURES = + newProperty("features.cool.enabled", false); + + public static final Property> COOL_OPTIONS = + newProperty(PropertyType.STRING_LIST, "features.cool.options", "Sparks", "Sprinkles"); + +} diff --git a/src/test/resources/437-config-test.yml b/src/test/resources/437-config-test.yml deleted file mode 100644 index 5057bea92..000000000 --- a/src/test/resources/437-config-test.yml +++ /dev/null @@ -1,44 +0,0 @@ -test: - duration: 22 -DataSource: - # What type of database do you want to use? - # Valid values: sqlite, mysql - backend: mysql - # Enable database caching, should improve database performance - caching: true -settings: - # The name shown in the help messages. - helpHeader: AuthMeReloaded - GameMode: - # ForceSurvivalMode to player when join ? - ForceSurvivalMode: false -Security: - SQLProblem: - # Stop the server if we can't contact the sql database - # Take care with this, if you set that to false, - # AuthMe automatically disable and the server is not protected! - stopServer: true - ReloadCommand: - # /reload support - useReloadCommandSupport: true - console: - # Remove spam console - noConsoleSpam: false - # Replace passwords in the console when player type a command like /login - removePassword: true - captcha: - # Player need to put a captcha when he fails too lot the password - useCaptcha: false - # Max allowed tries before request a captcha - maxLoginTry: 5 - # Captcha length - captchaLength: 5 - unsafePasswords: - - '123456' - - 'qwerty' - - '54321' -Email: - # Email SMTP server host - mailSMTP: smtp.gmail.com - # Email SMTP server port - mailPort: 465 diff --git a/src/test/resources/437-write-test.yml b/src/test/resources/437-write-test.yml deleted file mode 100644 index de2b762f8..000000000 --- a/src/test/resources/437-write-test.yml +++ /dev/null @@ -1,172 +0,0 @@ - - -Converter: - Rakamak: - # Rakamak file name - fileName: 'users.rak' - # Rakamak use IP? - useIP: false - # Rakamak IP file name - ipFileName: 'UsersIp.rak' - CrazyLogin: - # CrazyLogin database file name - fileName: 'accounts.db' - -DataSource: - # What type of database do you want to use? - # Valid values: sqlite, mysql - backend: 'sqlite' - # Enable database caching, should improve database performance - caching: true - # Database host address - mySQLHost: '127.0.0.1' - # Database port - mySQLPort: '3306' - # Username about Database Connection Infos - mySQLUsername: 'authme' - # Password about Database Connection Infos - mySQLPassword: '123456' - # Database Name, use with converters or as SQLITE database name - mySQLDatabase: 'authme' - # Table of the database - mySQLTablename: 'authme' - # Column of IDs to sort data - mySQLColumnId: 'id' - # Column for storing or checking players nickname - mySQLColumnName: 'username' - # Column for storing or checking players RealName - mySQLRealName: 'realname' - # Column for storing players passwords - mySQLColumnPassword: 'password' - # Column for storing players emails - mySQLColumnEmail: 'email' - # Column for storing if a player is logged in or not - mySQLColumnLogged: 'email' - # Column for storing players ips - mySQLColumnIp: 'ip' - # Column for storing players lastlogins - mySQLColumnLastLogin: 'lastlogin' - # Column for storing player LastLocation - X - mySQLlastlocX: 'x' - # Column for storing player LastLocation - Y - mySQLlastlocY: 'y' - # Column for storing player LastLocation - Z - mySQLlastlocZ: 'z' - # Column for storing player LastLocation - World Name - mySQLlastlocWorld: 'world' - # Enable this when you allow registration through a website - mySQLWebsite: false - -ExternalBoardOptions: - # Column for storing players passwords salts - mySQLColumnSalt: '' - # Column for storing players groups - mySQLColumnGroup: '' - -Email: - # Email SMTP server host - mailSMTP: 'smtp.gmail.com' - # Email SMTP server port - mailPort: 465 - # Email account which sends the mails - mailAccount: '' - # Email account password - mailPassword: '' - # Recovery password length - RecoveryPasswordLength: 8 - # Mail Subject - mailSubject: 'Your new AuthMe password' - # Like maxRegPerIP but with email - maxRegPerEmail: 1 - # Recall players to add an email? - recallPlayers: false - # Delay in minute for the recall scheduler - delayRecall: 5 - # Blacklist these domains for emails - emailBlacklisted: - - '10minutemail.com' - # Whitelist ONLY these domains for emails - emailWhitelisted: [] - # Send the new password drawn in an image? - generateImage: false - # The OAuth2 token - emailOauth2Token: '' - -Hooks: - # Do we need to hook with multiverse for spawn checking? - multiverse: true - # Do we need to hook with BungeeCord? - bungeecord: false - # Do we need to disable Essentials SocialSpy on join? - disableSocialSpy: false - # Do we need to force /motd Essentials command on join? - useEssentialsMotd: false - # Do we need to cache custom Attributes? - customAttributes: false - -bungeecord: - # Send player to this BungeeCord server after register/login - server: '' - -Protection: - # Enable some servers protection (country based login, antibot) - enableProtection: false - # 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! - countries: - - 'US' - - 'GB' - - 'A1' - # Countries not allowed to join the server and register - # PLEASE USE QUOTES! - countriesBlacklist: [] - # Do we need to enable automatic antibot system? - enableAntiBot: false - # Max number of player allowed to login in 5 secs before enable AntiBot system automatically - antiBotSensibility: 5 - # Duration in minutes of the antibot automatic system - antiBotDuration: 10 - -Purge: - # If enabled, AuthMe automatically purges old, unused accounts - useAutoPurge: false - # Number of Days an account become Unused - daysBeforeRemovePlayer: 60 - # Do we need to remove the player.dat file during purge process? - removePlayerDat: false - # Do we need to remove the Essentials/users/player.yml file during purge process? - removeEssentialsFiles: false - # World where are players.dat stores - defaultWorld: 'world' - # Do we need to remove LimitedCreative/inventories/player.yml, player_creative.yml files during purge process ? - removeLimitedCreativesInventories: false - # Do we need to remove the AntiXRayData/PlayerData/player file during purge process? - removeAntiXRayFile: false - # Do we need to remove permissions? - removePermissions: false - -Security: - SQLProblem: - # Stop the server if we can't contact the sql database - # Take care with this, if you set this to false, - # AuthMe will automatically disable and the server won't be protected! - stopServer: true - ReloadCommand: - # /reload support - useReloadCommandSupport: true - console: - # Remove spam from console? - noConsoleSpam: false - # Remove passwords from console? - removePassword: true - captcha: - # Player need to put a captcha when he fails too lot the password - useCaptcha: false - # Max allowed tries before request a captcha - maxLoginTry: 5 - # Captcha length - captchaLength: 5 - stop: - # Kick players before stopping the server, that allow us to save position of players - # and all needed information correctly without any corruption. - kickPlayersBeforeStopping: true diff --git a/src/test/resources/config-incomplete-sample.yml b/src/test/resources/config-incomplete-sample.yml new file mode 100644 index 000000000..a29879720 --- /dev/null +++ b/src/test/resources/config-incomplete-sample.yml @@ -0,0 +1,27 @@ +# Test config file with missing options from TestConfiguration +# Notice the commented out lines! + +test: + duration: 22 +# systemName: 'Custom sys name' +sample: + ratio: +# limit: 3.0 + fields: + - 'Australia' + - 'Burundi' + - 'Colombia' +#version: 2492 +features: +# boring: +# skip: false +# colors: +# - 'beige' +# - 'gray' +# dustLevel: 0.81 + cool: +# enabled: true + options: + - 'Dinosaurs' + - 'Explosions' + - 'Big trucks' diff --git a/src/test/resources/config-sample-values.yml b/src/test/resources/config-sample-values.yml new file mode 100644 index 000000000..1bd99d771 --- /dev/null +++ b/src/test/resources/config-sample-values.yml @@ -0,0 +1,27 @@ +# Test config file with all options +# defined in the TestConfiguration class + +test: + duration: 22 + systemName: 'Custom sys name' +sample: + ratio: + limit: -4.1 + fields: + - 'Australia' + - 'Burundi' + - 'Colombia' +version: 2492 +features: + boring: + skip: false + colors: + - 'beige' + - 'gray' + dustLevel: 0.81 + cool: + enabled: true + options: + - 'Dinosaurs' + - 'Explosions' + - 'Big trucks'