use of fr.xephi.authme.settings.Settings in project AuthMeReloaded by AuthMe.
the class SettingsProvider method get.
/**
* Loads the plugin's settings.
*
* @return the settings instance, or null if it could not be constructed
*/
@Override
public Settings get() {
File configFile = new File(dataFolder, "config.yml");
if (!configFile.exists()) {
FileUtils.create(configFile);
}
PropertyResource resource = new YamlFileResource(configFile);
ConfigurationData configurationData = AuthMeSettingsRetriever.buildConfigurationData();
return new Settings(dataFolder, resource, migrationService, configurationData);
}
use of fr.xephi.authme.settings.Settings in project AuthMeReloaded by AuthMe.
the class HashAlgorithmIntegrationTest method setUpConfigAndInjector.
@BeforeClass
public static void setUpConfigAndInjector() {
Settings settings = mock(Settings.class);
given(settings.getProperty(HooksSettings.BCRYPT_LOG2_ROUND)).willReturn(8);
given(settings.getProperty(SecuritySettings.DOUBLE_MD5_SALT_LENGTH)).willReturn(16);
given(settings.getProperty(SecuritySettings.PBKDF2_NUMBER_OF_ROUNDS)).willReturn(10_000);
injector = new InjectorBuilder().addDefaultHandlers("fr.xephi.authme").create();
injector.register(Settings.class, settings);
}
use of fr.xephi.authme.settings.Settings in project AuthMeReloaded by AuthMe.
the class MessageFileHandlerProviderTest method shouldCreateHandler.
@Test
public void shouldCreateHandler() {
// given
String language = "fr";
given(settings.getProperty(PluginSettings.MESSAGES_LANGUAGE)).willReturn(language);
MessageFileHandlerProvider provider = Mockito.spy(handlerProvider);
Function<String, String> fileFunction = lang -> "file_" + lang + ".txt";
File file = new File(dataFolder, "some_file.txt");
doReturn(file).when(provider).initializeFile(language, fileFunction);
// when
MessageFileHandler handler = provider.initializeHandler(fileFunction);
// then
assertThat(handler, not(nullValue()));
verify(settings).getProperty(PluginSettings.MESSAGES_LANGUAGE);
verify(provider).initializeFile(language, fileFunction);
}
use of fr.xephi.authme.settings.Settings in project AuthMeReloaded by AuthMe.
the class AbstractResourceClosingTest method initializeSettings.
/** Initialize the settings mock and makes it return the default of any given property by default. */
@SuppressWarnings({ "unchecked", "rawtypes" })
@BeforeClass
public static void initializeSettings() throws IOException, ClassNotFoundException {
settings = mock(Settings.class);
given(settings.getProperty(any(Property.class))).willAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) {
return ((Property<?>) invocation.getArguments()[0]).getDefaultValue();
}
});
TestHelper.setupLogger();
}
use of fr.xephi.authme.settings.Settings in project AuthMeReloaded by AuthMe.
the class SQLiteIntegrationTest method initializeSettings.
/**
* Set up the settings mock to return specific values for database settings and load {@link #sqlInitialize}.
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
@BeforeClass
public static void initializeSettings() throws IOException, ClassNotFoundException {
// Check that we have an implementation for SQLite
Class.forName("org.sqlite.JDBC");
settings = mock(Settings.class);
when(settings.getProperty(any(Property.class))).thenAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
return ((Property) invocation.getArguments()[0]).getDefaultValue();
}
});
set(DatabaseSettings.MYSQL_DATABASE, "sqlite-test");
set(DatabaseSettings.MYSQL_TABLE, "authme");
TestHelper.setRealLogger();
Path sqlInitFile = TestHelper.getJarPath(TestHelper.PROJECT_ROOT + "datasource/sql-initialize.sql");
// Note ljacqu 20160221: It appears that we can only run one statement per Statement.execute() so we split
// the SQL file by ";\n" as to get the individual statements
sqlInitialize = new String(Files.readAllBytes(sqlInitFile)).split(";(\\r?)\\n");
}
Aggregations