#1146 List available converter, reference converters Wiki page in config.yml

This commit is contained in:
ljacqu 2017-05-21 12:28:35 +02:00
parent 5afe6bb35b
commit 1c46c92b4e
5 changed files with 58 additions and 22 deletions

View File

@ -1,5 +1,5 @@
<!-- AUTO-GENERATED FILE! Do not edit this directly -->
<!-- File auto-generated on Sat Apr 29 18:27:38 CEST 2017. See docs/config/config.tpl.md -->
<!-- File auto-generated on Sun May 21 12:23:19 CEST 2017. See docs/config/config.tpl.md -->
## AuthMe Configuration
The first time you run AuthMe it will create a config.yml file in the plugins/AuthMe folder,
@ -219,14 +219,14 @@ settings:
# PBKDF2DJANGO, WORDPRESS, ROYALAUTH, CUSTOM (for developers only). See full list at
# https://github.com/AuthMe/AuthMeReloaded/blob/master/docs/hash_algorithms.md
passwordHash: 'SHA256'
# Salt length for the SALTED2MD5 MD5(MD5(password)+salt)
doubleMD5SaltLength: 8
# If a password check fails, AuthMe will also try to check with the following hash methods.
# Use this setting when you change from one hash method to another.
# AuthMe will update the password to the new hash. Example:
# legacyHashes:
# - 'SHA1'
legacyHashes: []
# Salt length for the SALTED2MD5 MD5(MD5(password)+salt)
doubleMD5SaltLength: 8
# Number of rounds to use if passwordHash is set to PBKDF2. Default is 10000
pbkdf2Rounds: 10000
# Prevent unsafe passwords from being used; put them in lowercase!
@ -493,6 +493,7 @@ BackupSystem:
OnServerStop: true
# Windows only: MySQL installation path
MysqlWindowsPath: 'C:\Program Files\MySQL\MySQL Server 5.1\'
# Converter settings: see https://github.com/AuthMe/AuthMeReloaded/wiki/Converters
Converter:
Rakamak:
# Rakamak file name
@ -504,6 +505,18 @@ Converter:
CrazyLogin:
# CrazyLogin database file name
fileName: 'accounts.db'
loginSecurity:
# LoginSecurity: convert from SQLite; if false we use MySQL
useSqlite: true
mySql:
# LoginSecurity MySQL: database host
host: ''
# LoginSecurity MySQL: database name
database: ''
# LoginSecurity MySQL: database user
user: ''
# LoginSecurity MySQL: password for database user
password: ''
```
To change settings on a running server, save your changes to config.yml and use
@ -511,4 +524,4 @@ To change settings on a running server, save your changes to config.yml and use
---
This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Sat Apr 29 18:27:38 CEST 2017
This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Sun May 21 12:23:19 CEST 2017

View File

@ -316,7 +316,7 @@ public class CommandInitializer {
.description("Converter command")
.detailedDescription("Converter command for AuthMeReloaded.")
.withArgument("job", "Conversion job: xauth / crazylogin / rakamak / "
+ "royalauth / vauth / sqliteToSql / mysqlToSqlite / loginsecurity", false)
+ "royalauth / vauth / sqliteToSql / mysqlToSqlite / loginsecurity", true)
.permission(AdminPermission.CONVERTER)
.executableCommand(ConverterCommand.class)
.register();

View File

@ -1,7 +1,7 @@
package fr.xephi.authme.command.executable.authme;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSortedMap;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.command.ExecutableCommand;
import fr.xephi.authme.datasource.converter.Converter;
@ -41,14 +41,10 @@ public class ConverterCommand implements ExecutableCommand {
private Factory<Converter> converterFactory;
@Override
public void executeCommand(final CommandSender sender, List<String> arguments) {
// Get the conversion job
String job = arguments.get(0);
// Determine the job type
Class<? extends Converter> converterClass = CONVERTERS.get(job.toLowerCase());
public void executeCommand(CommandSender sender, List<String> arguments) {
Class<? extends Converter> converterClass = getConverterClassFromArgs(arguments);
if (converterClass == null) {
sender.sendMessage("[AuthMe] Converter does not exist!");
sender.sendMessage("Converters: " + String.join(", ", CONVERTERS.keySet()));
return;
}
@ -69,7 +65,13 @@ public class ConverterCommand implements ExecutableCommand {
});
// Show a status message
sender.sendMessage("[AuthMe] Successfully started " + job);
sender.sendMessage("[AuthMe] Successfully started " + arguments.get(0));
}
private static Class<? extends Converter> getConverterClassFromArgs(List<String> arguments) {
return arguments.isEmpty()
? null
: CONVERTERS.get(arguments.get(0).toLowerCase());
}
/**
@ -78,7 +80,7 @@ public class ConverterCommand implements ExecutableCommand {
* @return map with all available converters
*/
private static Map<String, Class<? extends Converter>> getConverters() {
return ImmutableMap.<String, Class<? extends Converter>>builder()
return ImmutableSortedMap.<String, Class<? extends Converter>>naturalOrder()
.put("xauth", XAuthConverter.class)
.put("crazylogin", CrazyLoginConverter.class)
.put("rakamak", RakamakConverter.class)
@ -89,5 +91,4 @@ public class ConverterCommand implements ExecutableCommand {
.put("loginsecurity", LoginSecurityConverter.class)
.build();
}
}

View File

@ -1,8 +1,12 @@
package fr.xephi.authme.settings.properties;
import ch.jalu.configme.Comment;
import ch.jalu.configme.SectionComments;
import ch.jalu.configme.SettingsHolder;
import ch.jalu.configme.properties.Property;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import static ch.jalu.configme.properties.PropertyInitializer.newProperty;
@ -47,4 +51,9 @@ public final class ConverterSettings implements SettingsHolder {
private ConverterSettings() {
}
@SectionComments
public static Map<String, String[]> buildSectionComments() {
return ImmutableMap.of("Converter",
new String[]{"Converter settings: see https://github.com/AuthMe/AuthMeReloaded/wiki/Converters"});
}
}

View File

@ -42,7 +42,7 @@ public class ConverterCommandTest {
private ConverterCommand command;
@Mock
private CommonService commandService;
private CommonService commonService;
@Mock
private BukkitService bukkitService;
@ -64,10 +64,23 @@ public class ConverterCommandTest {
command.executeCommand(sender, Collections.singletonList("invalid"));
// then
verify(sender).sendMessage(argThat(containsString("Converter does not exist")));
verifyNoMoreInteractions(commandService);
verifyZeroInteractions(converterFactory);
verifyZeroInteractions(bukkitService);
String converters = String.join(", ", ConverterCommand.CONVERTERS.keySet());
verify(sender).sendMessage(argThat(containsString(converters)));
verifyZeroInteractions(commonService, converterFactory, bukkitService);
}
@Test
public void shouldHandleCommandWithNoArgs() {
// given
CommandSender sender = mock(CommandSender.class);
// when
command.executeCommand(sender, Collections.emptyList());
// then
String converters = String.join(", ", ConverterCommand.CONVERTERS.keySet());
verify(sender).sendMessage(argThat(containsString(converters)));
verifyZeroInteractions(commonService, converterFactory, bukkitService);
}
@Test
@ -122,7 +135,7 @@ public class ConverterCommandTest {
verifyNoMoreInteractions(converter);
verify(converterFactory).newInstance(converterClass);
verifyNoMoreInteractions(converterFactory);
verify(commandService).send(sender, MessageKey.ERROR);
verify(commonService).send(sender, MessageKey.ERROR);
}
private <T extends Converter> T createMockReturnedByInjector(Class<T> clazz) {