Add missing tests for API package

This commit is contained in:
ljacqu
2017-10-28 23:15:53 +02:00
parent b687c68d46
commit 2c6181d150
4 changed files with 297 additions and 18 deletions
@@ -62,12 +62,7 @@ public class AuthMeApi {
* @return The AuthMeApi object, or null if the AuthMe plugin is not enabled or not fully initialized yet
*/
public static AuthMeApi getInstance() {
if (singleton != null) {
return singleton;
}
// AuthMeApi is initialized in AuthMe#onEnable -> if singleton is null,
// it means AuthMe isn't initialized (yet)
return null;
return singleton;
}
/**
@@ -144,7 +139,7 @@ public class AuthMeApi {
*/
public String getLastIp(String playerName) {
PlayerAuth auth = playerCache.getAuth(playerName);
if(auth == null) {
if (auth == null) {
auth = dataSource.getAuth(playerName);
}
if (auth != null) {
@@ -212,10 +207,10 @@ public class AuthMeApi {
*/
public boolean registerPlayer(String playerName, String password) {
String name = playerName.toLowerCase();
HashedPassword result = passwordSecurity.computeHash(password, name);
if (isRegistered(name)) {
return false;
}
HashedPassword result = passwordSecurity.computeHash(password, name);
PlayerAuth auth = PlayerAuth.builder()
.name(name)
.password(result)