use of ch.jalu.configme.resource.PropertyResource in project AuthMeReloaded by AuthMe.
the class SettingsMigrationServiceTest method shouldPerformMigrations.
@Test
public void shouldPerformMigrations() throws IOException {
// given
File dataFolder = temporaryFolder.newFolder();
File configFile = new File(dataFolder, "config.yml");
Files.copy(getJarFile(OLD_CONFIG_FILE), configFile);
PropertyResource resource = new YamlFileResource(configFile);
SettingsMigrationService migrationService = new SettingsMigrationService(dataFolder);
// when
Settings settings = new Settings(dataFolder, resource, migrationService, AuthMeSettingsRetriever.buildConfigurationData());
// then
assertThat(settings.getProperty(ALLOWED_NICKNAME_CHARACTERS), equalTo(ALLOWED_NICKNAME_CHARACTERS.getDefaultValue()));
assertThat(settings.getProperty(DELAY_JOIN_MESSAGE), equalTo(true));
assertThat(settings.getProperty(FORCE_SPAWN_LOCATION_AFTER_LOGIN), equalTo(true));
assertThat(settings.getProperty(FORCE_SPAWN_ON_WORLDS), contains("survival", "survival_nether", "creative"));
assertThat(settings.getProperty(LOG_LEVEL), equalTo(LogLevel.INFO));
assertThat(settings.getProperty(REGISTRATION_TYPE), equalTo(RegistrationType.EMAIL));
assertThat(settings.getProperty(REGISTER_SECOND_ARGUMENT), equalTo(RegisterSecondaryArgument.CONFIRMATION));
assertThat(settings.getProperty(ENABLE_PERMISSION_CHECK), equalTo(true));
assertThat(settings.getProperty(REGISTERED_GROUP), equalTo("unLoggedinGroup"));
assertThat(settings.getProperty(UNREGISTERED_GROUP), equalTo(""));
// Check migration of old setting to email.html
assertThat(Files.readLines(new File(dataFolder, "email.html"), StandardCharsets.UTF_8), contains("Dear <playername />, <br /><br /> This is your new AuthMe password for the server " + "<br /><br /> <servername /> : <br /><br /> <generatedpass /><br /><image /><br />Do not forget to " + "change password after login! <br /> /changepassword <generatedpass /> newPassword"));
}
use of ch.jalu.configme.resource.PropertyResource in project AuthMeReloaded by AuthMe.
the class SettingsTest method shouldLoadEmailMessage.
@Test
public void shouldLoadEmailMessage() throws IOException {
// given
String emailMessage = "Sample email message\nThat's all!";
File emailFile = new File(testPluginFolder, "email.html");
createFile(emailFile);
Files.write(emailFile.toPath(), emailMessage.getBytes());
PropertyResource resource = mock(PropertyResource.class);
Settings settings = new Settings(testPluginFolder, resource, null, CONFIG_DATA);
// when
String result = settings.getPasswordEmailMessage();
// then
assertThat(result, equalTo(emailMessage));
}
Aggregations