mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-01-03 22:30:31 +03:00
[TEST] Тест на запуск лаунчсервера
This commit is contained in:
parent
ceff8a8684
commit
f0eeeaad10
3 changed files with 90 additions and 1 deletions
|
@ -40,6 +40,13 @@
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test {
|
||||||
|
useJUnitPlatform()
|
||||||
|
testLogging {
|
||||||
|
events "passed", "skipped", "failed"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
task sourcesJar(type: Jar) {
|
task sourcesJar(type: Jar) {
|
||||||
from sourceSets.main.allJava
|
from sourceSets.main.allJava
|
||||||
archiveClassifier = 'sources'
|
archiveClassifier = 'sources'
|
||||||
|
@ -107,6 +114,7 @@ pack project(':LauncherAPI')
|
||||||
compileOnlyA 'com.google.guava:guava:26.0-jre'
|
compileOnlyA 'com.google.guava:guava:26.0-jre'
|
||||||
compileOnlyA 'log4j:log4j:1.2.17' // Do not update (laggy dep).
|
compileOnlyA 'log4j:log4j:1.2.17' // Do not update (laggy dep).
|
||||||
compileOnlyA 'org.apache.logging.log4j:log4j-core:2.11.2'
|
compileOnlyA 'org.apache.logging.log4j:log4j-core:2.11.2'
|
||||||
|
testCompile 'org.junit.jupiter:junit-jupiter:5.4.1'
|
||||||
}
|
}
|
||||||
|
|
||||||
task hikari(type: Copy) {
|
task hikari(type: Copy) {
|
||||||
|
|
|
@ -312,7 +312,10 @@ public static LaunchServerConfig getDefault(LaunchServer.LaunchServerEnv env)
|
||||||
, "std")};
|
, "std")};
|
||||||
newConfig.auth[0].displayName = "Default";
|
newConfig.auth[0].displayName = "Default";
|
||||||
newConfig.protectHandler = new StdProtectHandler();
|
newConfig.protectHandler = new StdProtectHandler();
|
||||||
newConfig.permissionsHandler = new JsonFilePermissionsHandler();
|
if(env.equals(LaunchServer.LaunchServerEnv.TEST))
|
||||||
|
newConfig.permissionsHandler = new DefaultPermissionsHandler();
|
||||||
|
else
|
||||||
|
newConfig.permissionsHandler = new JsonFilePermissionsHandler();
|
||||||
newConfig.binaryName = "Launcher";
|
newConfig.binaryName = "Launcher";
|
||||||
newConfig.whitelistRejectString = "Вас нет в белом списке";
|
newConfig.whitelistRejectString = "Вас нет в белом списке";
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,78 @@
|
||||||
|
package pro.gravit.launchserver;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.io.TempDir;
|
||||||
|
import pro.gravit.launcher.Launcher;
|
||||||
|
import pro.gravit.launcher.managers.SimpleModulesConfigManager;
|
||||||
|
import pro.gravit.launchserver.config.LaunchServerConfig;
|
||||||
|
import pro.gravit.launchserver.config.LaunchServerRuntimeConfig;
|
||||||
|
import pro.gravit.launchserver.manangers.LaunchServerGsonManager;
|
||||||
|
import pro.gravit.launchserver.modules.impl.LaunchServerModulesManager;
|
||||||
|
import pro.gravit.utils.command.StdCommandHandler;
|
||||||
|
import pro.gravit.utils.helper.SecurityHelper;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.security.KeyPair;
|
||||||
|
import java.security.interfaces.RSAPrivateKey;
|
||||||
|
import java.security.interfaces.RSAPublicKey;
|
||||||
|
|
||||||
|
public class StartLaunchServerTest {
|
||||||
|
@TempDir
|
||||||
|
public static Path modulesDir;
|
||||||
|
@TempDir
|
||||||
|
public static Path configDir;
|
||||||
|
@TempDir
|
||||||
|
public static Path dir;
|
||||||
|
public static LaunchServer launchServer;
|
||||||
|
@BeforeAll
|
||||||
|
public static void prepare() throws Exception
|
||||||
|
{
|
||||||
|
LaunchServerModulesManager modulesManager = new LaunchServerModulesManager(modulesDir, configDir);
|
||||||
|
SimpleModulesConfigManager configManager = new SimpleModulesConfigManager(configDir);
|
||||||
|
LaunchServerConfig config = LaunchServerConfig.getDefault(LaunchServer.LaunchServerEnv.TEST);
|
||||||
|
Launcher.gsonManager = new LaunchServerGsonManager(modulesManager);
|
||||||
|
Launcher.gsonManager.initGson();
|
||||||
|
LaunchServerRuntimeConfig runtimeConfig = new LaunchServerRuntimeConfig();
|
||||||
|
LaunchServerBuilder builder = new LaunchServerBuilder();
|
||||||
|
KeyPair pair = SecurityHelper.genRSAKeyPair();
|
||||||
|
RSAPublicKey publicKey = (RSAPublicKey) pair.getPublic();
|
||||||
|
RSAPrivateKey privateKey = (RSAPrivateKey) pair.getPrivate();
|
||||||
|
builder.setDir(dir)
|
||||||
|
.setEnv(LaunchServer.LaunchServerEnv.TEST)
|
||||||
|
.setConfig(config)
|
||||||
|
.setRuntimeConfig(runtimeConfig)
|
||||||
|
.setPublicKey(publicKey)
|
||||||
|
.setPrivateKey(privateKey)
|
||||||
|
.setLaunchServerConfigManager(new LaunchServer.LaunchServerConfigManager() {
|
||||||
|
@Override
|
||||||
|
public LaunchServerConfig readConfig() throws IOException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LaunchServerRuntimeConfig readRuntimeConfig() throws IOException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeConfig(LaunchServerConfig config) throws IOException {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeRuntimeConfig(LaunchServerRuntimeConfig config) throws IOException {
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setModulesManager(modulesManager)
|
||||||
|
.setCommandHandler(new StdCommandHandler(false));
|
||||||
|
launchServer = builder.build();
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void start() throws Exception
|
||||||
|
{
|
||||||
|
launchServer.run();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue