tmpTest
This commit is contained in:
parent
eac490f040
commit
5f7573f0cd
3 changed files with 58 additions and 3 deletions
|
@ -3,8 +3,6 @@ package be.jeffcheasey88.peeratcode.model;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
|
55
test/be/jeffcheasey88/peeratcode/routes/TmpRoutesTests.java
Normal file
55
test/be/jeffcheasey88/peeratcode/routes/TmpRoutesTests.java
Normal file
|
@ -0,0 +1,55 @@
|
|||
package be.jeffcheasey88.peeratcode.routes;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
import org.junit.jupiter.api.TestInstance.Lifecycle;
|
||||
|
||||
import be.jeffcheasey88.peeratcode.Main;
|
||||
import be.jeffcheasey88.peeratcode.webclient.WebClient;
|
||||
|
||||
@TestInstance(Lifecycle.PER_CLASS)
|
||||
public class TmpRoutesTests {
|
||||
|
||||
private Thread server;
|
||||
private WebClient client;
|
||||
|
||||
@BeforeAll
|
||||
void init(){
|
||||
server = new Thread(new Runnable(){
|
||||
@Override
|
||||
public void run(){
|
||||
try {
|
||||
Main.main(null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
};
|
||||
}
|
||||
});
|
||||
server.start();
|
||||
client = new WebClient("localhost", 80);
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
void close(){
|
||||
server.interrupt();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testOnDeployed(){
|
||||
try {
|
||||
WebClient deploy = new WebClient("api.peerat.dev", 80);
|
||||
|
||||
deploy.auth("JeffCheasey88", "TheoPueDesPieds");
|
||||
deploy.route("/player/","GET");
|
||||
|
||||
deploy.assertResponseCode(200);
|
||||
}catch(Exception e){
|
||||
fail(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -50,14 +50,16 @@ public class WebClient {
|
|||
login.put("pseudo", user);
|
||||
login.put("passwd", password);
|
||||
route("/login", "POST", login.toJSONString());
|
||||
System.out.println("["+host+"] /login "+login);
|
||||
|
||||
for(String line : this.headers){
|
||||
Matcher matcher = AUTORIZATION.matcher(line);
|
||||
if(matcher.matches()){
|
||||
this.token = matcher.group(1);
|
||||
System.out.println(token);
|
||||
System.out.println(host+": "+token);
|
||||
break;
|
||||
}
|
||||
System.out.println("["+host+"] "+line);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue