Search in sources :

Example 11 with PropertyResource

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"));
}
Also used : YamlFileResource(ch.jalu.configme.resource.YamlFileResource) PropertyResource(ch.jalu.configme.resource.PropertyResource) TestHelper.getJarFile(fr.xephi.authme.TestHelper.getJarFile) File(java.io.File) Test(org.junit.Test)

Example 12 with PropertyResource

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));
}
Also used : PropertyResource(ch.jalu.configme.resource.PropertyResource) File(java.io.File) Test(org.junit.Test)

Aggregations

PropertyResource (ch.jalu.configme.resource.PropertyResource)12 File (java.io.File)12 Test (org.junit.Test)11 YamlFileResource (ch.jalu.configme.resource.YamlFileResource)10 TestHelper.getJarFile (fr.xephi.authme.TestHelper.getJarFile)5 PlainMigrationService (ch.jalu.configme.migration.PlainMigrationService)2 Property (ch.jalu.configme.properties.Property)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 Map (java.util.Map)2 ConfigurationData (ch.jalu.configme.configurationdata.ConfigurationData)1 Settings (fr.xephi.authme.settings.Settings)1