This commit is contained in:
parent
fa236cb1ad
commit
66e7338fa5
5 changed files with 235 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
offsets.txt
|
||||
environment.txt
|
84
src/test/java/integration/Environment.java
Normal file
84
src/test/java/integration/Environment.java
Normal file
|
@ -0,0 +1,84 @@
|
|||
/* Copyright WTFPL */
|
||||
package integration;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Environment {
|
||||
public final String CONTAINER = "environment.txt";
|
||||
|
||||
private String atmosphere;
|
||||
private String prodkeys;
|
||||
private String firmwares;
|
||||
private String saveTo;
|
||||
|
||||
public Environment() throws Exception{
|
||||
if (Files.notExists(Path.of(CONTAINER))) {
|
||||
boolean createdTemplate = createTemplate();
|
||||
throw new Exception("'environment.txt' not found\n" +
|
||||
"Please "+(createdTemplate?"":"create and ") +
|
||||
"set values in file");
|
||||
}
|
||||
|
||||
read();
|
||||
|
||||
if (isNotValid())
|
||||
throw new Exception("'environment.txt' doesn't contain valid data\n");
|
||||
}
|
||||
private void read() throws Exception{
|
||||
HashMap<String, String> rawKeySet = new HashMap<>();
|
||||
try (BufferedReader br = new BufferedReader(new FileReader(CONTAINER))) {
|
||||
String fileLine;
|
||||
String[] keyValue;
|
||||
while ((fileLine = br.readLine()) != null) {
|
||||
keyValue = fileLine.trim().split("\\s+?=\\s+?", 2);
|
||||
if (keyValue.length == 2)
|
||||
rawKeySet.put(keyValue[0], keyValue[1]);
|
||||
}
|
||||
}
|
||||
|
||||
atmosphere = rawKeySet.get("ATMOSPHERE");
|
||||
prodkeys = rawKeySet.get("PRODKEYS");
|
||||
firmwares = rawKeySet.get("NS_GLOBAL_FIRMWARES");
|
||||
saveTo = rawKeySet.get("SAVE_TO");
|
||||
}
|
||||
private boolean isNotValid(){
|
||||
return atmosphere == null || atmosphere.isBlank() ||
|
||||
prodkeys == null || prodkeys.isBlank() ||
|
||||
firmwares == null || firmwares.isBlank();
|
||||
}
|
||||
private boolean createTemplate(){
|
||||
try(FileWriter writer = new FileWriter(CONTAINER)){
|
||||
writer.write(
|
||||
"ATMOSPHERE = \n" +
|
||||
"PRODKEYS = \n" +
|
||||
"NS_GLOBAL_FIRMWARES = \n" +
|
||||
"SAVE_TO = /tmp");
|
||||
}
|
||||
catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getAtmosphereLocation() {
|
||||
return atmosphere;
|
||||
}
|
||||
|
||||
public String getProdkeysLocation() {
|
||||
return prodkeys;
|
||||
}
|
||||
|
||||
public String getFirmwaresLocation() {
|
||||
return firmwares;
|
||||
}
|
||||
|
||||
public String getSaveToLocation() {
|
||||
return saveTo;
|
||||
}
|
||||
}
|
54
src/test/java/integration/EsIntegrationTest.java
Normal file
54
src/test/java/integration/EsIntegrationTest.java
Normal file
|
@ -0,0 +1,54 @@
|
|||
/* Copyright WTFPL */
|
||||
package integration;
|
||||
|
||||
import nsusbloader.NSLMain;
|
||||
import nsusbloader.Utilities.patches.es.EsPatchMaker;
|
||||
import org.junit.jupiter.api.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class EsIntegrationTest {
|
||||
static String pathToFirmware;
|
||||
static String pathToFirmwares;
|
||||
static String pathToKeysFile;
|
||||
static String saveTo;
|
||||
|
||||
@BeforeAll
|
||||
static void init() throws Exception{
|
||||
NSLMain.isCli = true;
|
||||
Environment environment = new Environment();
|
||||
pathToKeysFile = environment.getProdkeysLocation();
|
||||
saveTo = environment.getSaveToLocation() + File.separator + "ES_LPR";
|
||||
pathToFirmwares = environment.getFirmwaresLocation();
|
||||
pathToFirmware = pathToFirmware + File.separator + "Firmware 14.1.0";
|
||||
}
|
||||
|
||||
@Disabled
|
||||
@DisplayName("ES Integration validation - everything")
|
||||
@Test
|
||||
void makeEss() throws Exception{
|
||||
File[] fwDirs = new File(pathToFirmwares).listFiles((file, s) -> {
|
||||
return s.matches("^Firmware (9\\.|[0-9][0-9]\\.).*");
|
||||
//return s.matches("^Firmware 10.0.1.*");
|
||||
});
|
||||
assert fwDirs != null;
|
||||
Arrays.sort(fwDirs);
|
||||
for (File dir : fwDirs){
|
||||
EsPatchMaker esPatchMaker = new EsPatchMaker(dir.getAbsolutePath(), pathToKeysFile, saveTo);
|
||||
Thread workThread = new Thread(esPatchMaker);
|
||||
workThread.start();
|
||||
workThread.join();
|
||||
}
|
||||
}
|
||||
|
||||
@Disabled
|
||||
@DisplayName("ES Integration validation - one particular firmware")
|
||||
@Test
|
||||
void makeEs() throws Exception{
|
||||
EsPatchMaker esPatchMaker = new EsPatchMaker(pathToFirmware, pathToKeysFile, saveTo);
|
||||
Thread workThread = new Thread(esPatchMaker);
|
||||
workThread.start();
|
||||
workThread.join();
|
||||
}
|
||||
}
|
60
src/test/java/integration/FsIntegrationTest.java
Normal file
60
src/test/java/integration/FsIntegrationTest.java
Normal file
|
@ -0,0 +1,60 @@
|
|||
/* Copyright WTFPL */
|
||||
package integration;
|
||||
|
||||
import nsusbloader.NSLMain;
|
||||
import nsusbloader.Utilities.patches.fs.FsPatchMaker;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class FsIntegrationTest {
|
||||
static String pathToFirmware;
|
||||
static String pathToFirmwares;
|
||||
static String pathToKeysFile;
|
||||
static String saveTo;
|
||||
|
||||
@BeforeAll
|
||||
static void init() throws Exception{
|
||||
NSLMain.isCli = true;
|
||||
Environment environment = new Environment();
|
||||
pathToKeysFile = environment.getProdkeysLocation();
|
||||
saveTo = environment.getSaveToLocation() + File.separator + "FS_LPR";
|
||||
pathToFirmwares = environment.getFirmwaresLocation();
|
||||
pathToFirmware = pathToFirmware + File.separator + "Firmware 13.0.0";
|
||||
}
|
||||
|
||||
@Disabled
|
||||
@DisplayName("FS Integration validation - everything")
|
||||
@Test
|
||||
void makeFss() throws Exception{
|
||||
File[] fwDirs = new File(pathToFirmwares).listFiles((file, s) -> {
|
||||
return (s.matches("^Firmware (9\\.|[0-9][0-9]\\.).*") && ! s.endsWith(".zip"));
|
||||
//return s.matches("^Firmware 10.0.1.*");
|
||||
});
|
||||
assert fwDirs != null;
|
||||
Arrays.sort(fwDirs);
|
||||
|
||||
for (File dir : fwDirs){
|
||||
System.out.println("\n\t\t\t"+dir.getName());
|
||||
FsPatchMaker fsPatchMaker = new FsPatchMaker(dir.getAbsolutePath(), pathToKeysFile, saveTo);
|
||||
Thread workThread = new Thread(fsPatchMaker);
|
||||
workThread.start();
|
||||
workThread.join();
|
||||
}
|
||||
}
|
||||
|
||||
@Disabled
|
||||
@DisplayName("FS Integration validation - one particular firmware")
|
||||
@Test
|
||||
void makeFs() throws Exception{
|
||||
System.out.println(pathToFirmware);
|
||||
FsPatchMaker fsPatchMaker = new FsPatchMaker(pathToFirmware, pathToKeysFile, saveTo);
|
||||
Thread workThread = new Thread(fsPatchMaker);
|
||||
workThread.start();
|
||||
workThread.join();
|
||||
}
|
||||
}
|
35
src/test/java/integration/LoaderIntegrationTest.java
Normal file
35
src/test/java/integration/LoaderIntegrationTest.java
Normal file
|
@ -0,0 +1,35 @@
|
|||
/* Copyright WTFPL */
|
||||
package integration;
|
||||
|
||||
import nsusbloader.NSLMain;
|
||||
import nsusbloader.Utilities.patches.loader.LoaderPatchMaker;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class LoaderIntegrationTest {
|
||||
static String pathToAtmo;
|
||||
static String saveTo;
|
||||
|
||||
@BeforeAll
|
||||
static void init() throws Exception{
|
||||
NSLMain.isCli = true;
|
||||
Environment environment = new Environment();
|
||||
saveTo = environment.getSaveToLocation() + File.separator + "Loader_LPR";
|
||||
pathToAtmo = environment.getAtmosphereLocation();
|
||||
}
|
||||
|
||||
@Disabled
|
||||
@DisplayName("Loader Integration validation")
|
||||
@Test
|
||||
void makeLoader() throws Exception{
|
||||
System.out.println(pathToAtmo);
|
||||
LoaderPatchMaker patchMaker = new LoaderPatchMaker(pathToAtmo, saveTo);
|
||||
Thread workThread = new Thread(patchMaker);
|
||||
workThread.start();
|
||||
workThread.join();
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue