Compare commits

9 Commits

Author SHA1 Message Date
Dave
6e84c0e76e formatting 2015-12-05 18:01:07 +02:00
Dave
86a5d724e3 added null check to nested user hash 2015-12-05 14:21:23 +02:00
Dave
ee92afd7da changed hashing method to use toString, bytearray may have proved
inconsistent
2015-12-05 14:05:09 +02:00
Dave
d0e2b2d69a Changed from static system var to explicit constructor
(consider changing to a generic NoCore/NoSession type in future)
2015-11-29 15:50:26 +02:00
Dave
d230b610da added exception to ClassNotFound error in setupNoUserClass 2015-11-29 15:27:56 +02:00
Dave
495a227da1 clean up this. 2015-11-29 11:53:53 +02:00
Dave
9108b2720a stopped ignoring actions on Hash (they are lifetime incremetors) 2015-11-29 11:36:30 +02:00
Dave
24c44e08d6 NoUser is now abstract 2015-11-29 11:24:47 +02:00
Dave
44d2ee3cc5 added @NoHash annotation to the correct fields in TestNoUser 2015-11-29 11:09:55 +02:00
9 changed files with 110 additions and 118 deletions

View File

@@ -43,6 +43,7 @@ import nodash.models.NoSession.NoState;
*/
public final class NoCore {
private NoAdapter adapter;
private Class<? extends NoUser> userClass;
/**
* Instantiates an instance of the NoCore, using the given adapter to interact with saved hashes,
@@ -50,8 +51,9 @@ public final class NoCore {
*
* @param adapter an object implementing the NoAdapter interface.
*/
public NoCore(NoAdapter adapter) {
public NoCore(NoAdapter adapter, Class<? extends NoUser> userClass) {
this.adapter = adapter;
this.userClass = userClass;
}
/**
@@ -92,7 +94,7 @@ public final class NoCore {
*/
public byte[] login(byte[] data, char[] password) throws NoUserNotValidException,
NoUserAlreadyOnlineException {
NoSession session = new NoSession(data, password);
NoSession session = new NoSession(data, password, userClass);
/* 1. Check that user is a valid user of the system based on their hash. */
try {
@@ -286,7 +288,7 @@ public final class NoCore {
byte[] newHash = session.getNoUserSafe().createHash();
try {
session.confirmSave(adapter, data, password);
session.confirmSave(adapter, data, password, userClass);
try {
adapter.insertHash(newHash);

View File

@@ -38,7 +38,6 @@ import javax.crypto.spec.SecretKeySpec;
import org.apache.commons.codec.binary.Base64;
import nodash.exceptions.NoDashFatalException;
import nodash.models.NoUser;
public final class NoUtil {
public static final SecretKey SECRET_KEY = setupSecretKey();
@@ -53,18 +52,6 @@ public final class NoUtil {
public static final int RSA_STRENGTH = setupRsaStrength();
public static final int AES_STRENGTH = 256;
public static final byte BLANK_BYTE = 'A';
public static final Class<? extends NoUser> NO_USER_CLASS = setupNoUserClass();
private static Class<? extends NoUser> setupNoUserClass() {
String secretEnv = System.getenv("NODASH_USER_CLASS");
try {
@SuppressWarnings("unchecked")
Class<? extends NoUser> clazz = (Class<? extends NoUser>) Class.forName(secretEnv);
return clazz;
} catch (ClassNotFoundException e) {
throw new RuntimeException("Can't find NODASH_USER_CLASS");
}
}
private static SecretKey setupSecretKey() {
String secretEnv = System.getenv("NODASH_SECRET");

View File

@@ -50,14 +50,15 @@ public final class NoSession implements Serializable {
this.current = newUser;
}
public NoSession(byte[] data, char[] password) throws NoUserNotValidException {
public NoSession(byte[] data, char[] password, Class<? extends NoUser> userClass)
throws NoUserNotValidException {
this();
this.state = NoState.IDLE;
byte[] originalData = Arrays.copyOf(data, data.length);
char[] originalPassword = Arrays.copyOf(password, password.length);
this.original =
NoUser.createUserFromFile(originalData, originalPassword, NoUtil.NO_USER_CLASS);
this.current = NoUser.createUserFromFile(data, password, NoUtil.NO_USER_CLASS);
NoUser.createUserFromFile(originalData, originalPassword, userClass);
this.current = NoUser.createUserFromFile(data, password, userClass);
NoUtil.wipeBytes(data);
NoUtil.wipeChars(password);
this.uuid = UUID.randomUUID().toString();
@@ -78,32 +79,32 @@ public final class NoSession implements Serializable {
public NoState touchState() throws NoSessionConfirmedException, NoSessionExpiredException {
check();
if (this.original == null) {
if (this.state != NoState.AWAITING_CONFIRMATION) {
this.state = NoState.MODIFIED;
if (original == null) {
if (state != NoState.AWAITING_CONFIRMATION) {
state = NoState.MODIFIED;
}
} else {
String originalHash = this.original.createHashString();
String currentHash = this.current.createHashString();
if (originalHash.equals(currentHash)) {
this.state = NoState.IDLE;
state = NoState.IDLE;
} else if (this.state != NoState.AWAITING_CONFIRMATION) {
this.state = NoState.MODIFIED;
state = NoState.MODIFIED;
}
}
return this.state;
return state;
}
public byte[] initiateSaveAttempt(char[] password)
throws NoSessionConfirmedException, NoSessionExpiredException {
touchState();
this.state = NoState.AWAITING_CONFIRMATION;
byte[] file = this.current.createFile(password);
byte[] file = current.createFile(password);
NoUtil.wipeChars(password);
return file;
}
public void confirmSave(NoAdapter adapter, byte[] confirmData, char[] password)
public void confirmSave(NoAdapter adapter, byte[] confirmData, char[] password, Class<? extends NoUser> userClass)
throws NoSessionConfirmedException, NoSessionExpiredException,
NoSessionNotAwaitingConfirmationException, NoUserNotValidException {
check();
@@ -111,7 +112,7 @@ public final class NoSession implements Serializable {
throw new NoSessionNotAwaitingConfirmationException();
}
NoUser confirmed = NoUser.createUserFromFile(confirmData, password, NoUtil.NO_USER_CLASS);
NoUser confirmed = NoUser.createUserFromFile(confirmData, password, userClass);
NoUtil.wipeBytes(confirmData);
NoUtil.wipeChars(password);

View File

@@ -18,9 +18,6 @@
package nodash.models;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.math.BigInteger;
@@ -41,8 +38,6 @@ import javax.crypto.IllegalBlockSizeException;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
import org.apache.commons.codec.binary.Base64;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
@@ -53,7 +48,7 @@ import nodash.exceptions.NoByteSetBadDecryptionException;
import nodash.exceptions.NoDashFatalException;
import nodash.exceptions.NoUserNotValidException;
public class NoUser implements Serializable {
public abstract class NoUser implements Serializable {
private static final long serialVersionUID = 7132405837081692211L;
@NoHash
private RSAPublicKeyImpl publicKey;
@@ -88,10 +83,10 @@ public class NoUser implements Serializable {
}
KeyPair keyPair = kpg.generateKeyPair();
this.publicKey = (RSAPublicKeyImpl) keyPair.getPublic();
this.privateKey = (RSAPrivateCrtKeyImpl) keyPair.getPrivate();
this.influences = 0;
this.actions = 0;
publicKey = (RSAPublicKeyImpl) keyPair.getPublic();
privateKey = (RSAPrivateCrtKeyImpl) keyPair.getPrivate();
influences = 0;
actions = 0;
touchRandomizer();
}
@@ -107,7 +102,6 @@ public class NoUser implements Serializable {
public final byte[] createFile(char[] password) {
List<NoAction> tempActions = outgoing;
int tempActionCount = actions;
touchRandomizer();
outgoing = new ArrayList<NoAction>();
@@ -117,7 +111,6 @@ public class NoUser implements Serializable {
byte[] json = NoUtil.toBytes(gson.toJson(this));
byte[] encrypted = NoUtil.encrypt(json, password);
actions = tempActionCount;
outgoing = tempActions;
return encrypted;
}
@@ -125,7 +118,6 @@ public class NoUser implements Serializable {
@SuppressWarnings("unchecked")
public final byte[] createHash() {
try {
List<Object> items = new ArrayList<Object>();
Comparator<Field> fieldComp = new Comparator<Field>() {
@Override
public int compare(Field o1, Field o2) {
@@ -134,6 +126,7 @@ public class NoUser implements Serializable {
};
Class<? extends NoUser> userClass = getClass();
StringBuilder toString = new StringBuilder();
while (userClass != null) {
Field[] noHashFields = userClass.getDeclaredFields();
@@ -143,7 +136,11 @@ public class NoUser implements Serializable {
for (Field field : noHashFields) {
if (field.isAnnotationPresent(NoHash.class)) {
field.setAccessible(true);
items.add(field.get(this));
toString.append("|");
Object item = field.get(this);
if (item != null) {
toString.append(field.get(this).toString());
}
}
}
@@ -154,19 +151,15 @@ public class NoUser implements Serializable {
}
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(items);
byte[] itemBytes = baos.toByteArray();
byte[] itemBytes = toString.toString().getBytes();
return NoUtil.getHashFromByteArray(itemBytes);
} catch (IOException e) {
throw new NoDashFatalException("IO Exception encountered while generating user hash.", e);
} catch (IllegalArgumentException e) {
throw new NoDashFatalException("IllegalArgument Exception encountered while generating user hash.", e);
throw new NoDashFatalException(
"IllegalArgument Exception encountered while generating user hash.", e);
} catch (IllegalAccessException e) {
throw new NoDashFatalException("IllegalAccess Exception encountered while generating user hash.", e);
throw new NoDashFatalException(
"IllegalAccess Exception encountered while generating user hash.", e);
}
}
@@ -192,12 +185,12 @@ public class NoUser implements Serializable {
}
public final void addAction(NoAction action) {
this.outgoing.add(action);
outgoing.add(action);
actions++;
}
public final List<NoAction> getNoActions() {
return this.outgoing;
return outgoing;
}
public final BigInteger getPublicExponent() {
@@ -222,11 +215,11 @@ public class NoUser implements Serializable {
private final byte[] decryptRsa(byte[] data)
throws InvalidKeyException, IllegalBlockSizeException, BadPaddingException {
return NoUtil.decryptRsa(data, this.privateKey);
return NoUtil.decryptRsa(data, privateKey);
}
public static NoUser createUserFromFile(byte[] data, char[] password, Class<? extends NoUser> clazz)
throws NoUserNotValidException {
public static NoUser createUserFromFile(byte[] data, char[] password,
Class<? extends NoUser> clazz) throws NoUserNotValidException {
byte[] decrypted;
try {
decrypted = NoUtil.decrypt(data, password);
@@ -244,8 +237,8 @@ public class NoUser implements Serializable {
}
}
public String createHashString() {
return Base64.encodeBase64URLSafeString(createHash());
public final String createHashString() {
return NoUtil.fromBytes(createHash());
}
@Override
@@ -258,8 +251,7 @@ public class NoUser implements Serializable {
return false;
}
return this.privateKey.getModulus().equals(((NoUser) otherUser).privateKey.getModulus());
return privateKey.getModulus().equals(((NoUser) otherUser).privateKey.getModulus());
}
}

View File

@@ -38,6 +38,7 @@ import nodash.exceptions.NoUserAlreadyOnlineException;
import nodash.exceptions.NoUserNotValidException;
import nodash.models.NoRegister;
import nodash.models.NoUser;
import nodash.test.functional.implementations.TestNoUser;
import nodash.models.NoSession.NoState;
import org.junit.Test;
@@ -46,20 +47,20 @@ public class NoCoreTest {
@Test
public void testRegister() {
NoCore core = new NoCore(new NoDefaultAdapter());
NoCore core = new NoCore(new NoDefaultAdapter(), TestNoUser.class);
NoUser user1 = new NoUser();
NoUser user1 = new TestNoUser("Test");
NoRegister registration1 = core.register(user1, "password".toCharArray());
assertNotNull(registration1.cookie);
assertNotNull(registration1.data);
NoUser user2 = new NoUser();
NoUser user2 = new TestNoUser("Test");
NoRegister registration2 = core.register(user2, "password".toCharArray());
assertFalse(Arrays.equals(registration1.cookie, registration2.cookie));
assertFalse(Arrays.equals(registration1.data, registration2.data));
NoUser user3 = new NoUser();
NoUser user3 = new TestNoUser("Test");
try {
core.register(null, "password".toCharArray());
fail("Did not throw NullPointerException.");
@@ -89,16 +90,16 @@ public class NoCoreTest {
NoSessionAlreadyAwaitingConfirmationException, NoAdapterException, NoSuchMethodException,
SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
NoAdapter adapter = new NoDefaultAdapter();
NoCore core = new NoCore(adapter);
NoCore core = new NoCore(adapter, TestNoUser.class);
NoUser newUser = new NoUser();
NoUser newUser = new TestNoUser("Test");
NoRegister registration = core.register(newUser, "password".toCharArray());
byte[] newUserFile = Arrays.copyOf(registration.data, registration.data.length);
core.confirm(registration.cookie, "password".toCharArray(), newUserFile);
byte[] newUserHash = newUser.createHash();
adapter.checkHash(newUserHash);
NoUser newUserBadPass = new NoUser();
NoUser newUserBadPass = new TestNoUser("Test");
registration = core.register(newUserBadPass, "password".toCharArray());
byte[] newUserBadPassFile = Arrays.copyOf(registration.data, registration.data.length);
try {
@@ -125,7 +126,7 @@ public class NoCoreTest {
// Do nothing, true
}
NoUser oldUser = new NoUser();
NoUser oldUser = new TestNoUser("Test");
registration = core.register(oldUser, "password".toCharArray());
byte[] oldUserFile = Arrays.copyOf(registration.data, registration.data.length);
core.confirm(registration.cookie, "password".toCharArray(), oldUserFile);
@@ -161,8 +162,8 @@ public class NoCoreTest {
public void testGetUser() throws NoSessionExpiredException, NoSessionConfirmedException,
NoSessionNotAwaitingConfirmationException, NoUserNotValidException,
NoUserAlreadyOnlineException {
NoCore core = new NoCore(new NoDefaultAdapter());
NoUser user = new NoUser();
NoCore core = new NoCore(new NoDefaultAdapter(), TestNoUser.class);
NoUser user = new TestNoUser("Test");
NoRegister registration = core.register(user, "password".toCharArray());
byte[] file = Arrays.copyOf(registration.data, registration.data.length);
core.confirm(registration.cookie, "password".toCharArray(), file);
@@ -187,8 +188,8 @@ public class NoCoreTest {
public void testGetSessionState() throws NoSessionExpiredException, NoSessionConfirmedException,
NoSessionNotAwaitingConfirmationException, NoUserNotValidException,
NoUserAlreadyOnlineException, NoSessionNotChangedException, NoSessionAlreadyAwaitingConfirmationException {
NoCore core = new NoCore(new NoDefaultAdapter());
NoUser user = new NoUser();
NoCore core = new NoCore(new NoDefaultAdapter(), TestNoUser.class);
NoUser user = new TestNoUser("Test");
NoRegister registration = core.register(user, "password".toCharArray());
assertEquals(core.getSessionState(registration.cookie), NoState.AWAITING_CONFIRMATION);
byte[] file = Arrays.copyOf(registration.data, registration.data.length);
@@ -216,8 +217,8 @@ public class NoCoreTest {
@Test
public void testShred() throws NoAdapterException, NoSessionConfirmedException, NoSessionExpiredException {
NoAdapter adapter = new NoDefaultAdapter();
NoCore core = new NoCore(adapter);
NoUser user = new NoUser();
NoCore core = new NoCore(adapter, TestNoUser.class);
NoUser user = new TestNoUser("Test");
NoRegister registration = core.register(user, "password".toCharArray());
assertTrue(adapter.isOnline(user.createHash()));
assertEquals(core.getSessionState(registration.cookie), NoState.AWAITING_CONFIRMATION);

View File

@@ -27,6 +27,7 @@ import nodash.exceptions.NoUserNotValidException;
import nodash.models.NoSession;
import nodash.models.NoSession.NoState;
import nodash.models.NoUser;
import nodash.test.functional.implementations.TestNoUser;
import org.junit.Test;
@@ -34,7 +35,7 @@ public class NoSessionTest {
@Test
public void testNoSessionNoUser() throws NoSessionConfirmedException, NoSessionExpiredException {
NoUser user = new NoUser();
NoUser user = new TestNoUser("Test");
NoSession session = new NoSession(user);
assertNotNull(session.getNoUser());
assertNotNull(session.getUuid());
@@ -51,14 +52,15 @@ public class NoSessionTest {
// Do nothing, correct
}
}
@Test
public void testNoSessionByteArrayCharArray() throws NoUserNotValidException,
NoSessionExpiredException, NoSessionConfirmedException {
NoUser user = new NoUser();
public void testNoSessionByteArrayCharArray()
throws NoUserNotValidException, NoSessionExpiredException, NoSessionConfirmedException {
NoUser user = new TestNoUser("Test");
final byte[] userFile1 = user.createFile("password".toCharArray());
byte[] userFile2 = Arrays.copyOf(userFile1, userFile1.length);
char[] userPassword = "password".toCharArray();
NoSession session = new NoSession(userFile2, userPassword);
NoSession session = new NoSession(userFile2, userPassword, TestNoUser.class);
assertFalse(Arrays.equals(userFile1, userFile2));
assertFalse(Arrays.equals("password".toCharArray(), userPassword));
assertNotNull(session.getNoUser());
@@ -71,14 +73,15 @@ public class NoSessionTest {
byte[] badUserFile = Arrays.copyOf(userFile1, userFile1.length);
badUserFile[0] = (byte) (badUserFile[0] == 'A' ? 'B' : 'A');
try {
new NoSession(badUserFile, "password".toCharArray());
new NoSession(badUserFile, "password".toCharArray(), TestNoUser.class);
fail("Did not throw NoUserNotValidException when given bad file.");
} catch (NoUserNotValidException e) {
// Do nothing, correct
}
try {
new NoSession(Arrays.copyOf(userFile2, userFile2.length), "badpassword".toCharArray());
new NoSession(Arrays.copyOf(userFile2, userFile2.length), "badpassword".toCharArray(),
TestNoUser.class);
fail("Did not throw NoUserNotValidException when given bad password.");
} catch (NoUserNotValidException e) {
// Do nothing, correct

View File

@@ -28,15 +28,15 @@ import javax.crypto.IllegalBlockSizeException;
import nodash.core.NoUtil;
import nodash.exceptions.NoUserNotValidException;
import nodash.models.NoUser;
import nodash.test.functional.implementations.TestNoUser;
import org.apache.commons.codec.binary.Base64;
import org.junit.Test;
public class NoUserTest {
@Test
public void testNoUser() {
NoUser user = new NoUser();
NoUser user = new TestNoUser("Test");
assertNotNull(user.getNoActions());
assertEquals(user.getNoActions().size(), 0);
@@ -48,7 +48,7 @@ public class NoUserTest {
@Test
public void testCreateFile() {
NoUser user = new NoUser();
NoUser user = new TestNoUser("Test");
byte[] file = user.createFile("password".toCharArray());
assertNotNull(file);
@@ -61,7 +61,7 @@ public class NoUserTest {
@Test
public void testCreateHash() {
NoUser user = new NoUser();
NoUser user = new TestNoUser("Test");
byte[] hash = user.createHash();
assertNotNull(hash);
@@ -74,18 +74,18 @@ public class NoUserTest {
@Test
public void testCreateHashString() {
NoUser user = new NoUser();
NoUser user = new TestNoUser("Test");
byte[] hash = user.createHash();
String hashString = user.createHashString();
assertEquals(Base64.encodeBase64URLSafeString(hash), hashString);
assertEquals(NoUtil.fromBytes(hash), hashString);
}
@Test
public void testCreateUserFromFile()
throws IllegalBlockSizeException, BadPaddingException,
ClassNotFoundException, IOException, NoUserNotValidException {
NoUser user = new NoUser();
NoUser user = new TestNoUser("Test");
final byte[] originalFile = user.createFile("password".toCharArray());
byte[] file = Arrays.copyOf(originalFile, originalFile.length);
byte[] hash = user.createHash();
@@ -93,34 +93,34 @@ public class NoUserTest {
user = null;
try {
user = NoUser.createUserFromFile(file, "wrongpassword".toCharArray(), NoUtil.NO_USER_CLASS);
user = NoUser.createUserFromFile(file, "wrongpassword".toCharArray(), TestNoUser.class);
fail("Should have thrown an error when given wrong password.");
} catch (NoUserNotValidException e) {
// Do nothing, correct
}
file = Arrays.copyOf(originalFile, originalFile.length);
user = NoUser.createUserFromFile(file, "password".toCharArray(), NoUtil.NO_USER_CLASS);
user = NoUser.createUserFromFile(file, "password".toCharArray(), TestNoUser.class);
assertTrue(Arrays.equals(hash, user.createHash()));
assertEquals(hashString, user.createHashString());
file = Arrays.copyOf(originalFile, originalFile.length);
try {
NoUser.createUserFromFile(file, null, NoUtil.NO_USER_CLASS);
NoUser.createUserFromFile(file, null, TestNoUser.class);
fail("Should have thrown a NullPointerException.");
} catch (NullPointerException e) {
// Do nothing, correct
}
try {
NoUser.createUserFromFile(null, "password".toCharArray(), NoUtil.NO_USER_CLASS);
NoUser.createUserFromFile(null, "password".toCharArray(), TestNoUser.class);
fail("Should have thrown a IllegalArgumentException.");
} catch (IllegalArgumentException e) {
// Do nothing, correct
}
try {
NoUser.createUserFromFile(null, null, NoUtil.NO_USER_CLASS);
NoUser.createUserFromFile(null, null, TestNoUser.class);
fail("Should have thrown a IllegalArgumentException.");
} catch (NullPointerException e) {
// Do nothing, correct

View File

@@ -36,7 +36,7 @@ public class NoRoutineTest {
private byte[] registerAndConfirm(TestNoUser user, String password)
throws NoSessionExpiredException, NoSessionConfirmedException,
NoSessionNotAwaitingConfirmationException, NoUserNotValidException {
NoCore core = new NoCore(new NoDefaultAdapter());
NoCore core = new NoCore(new NoDefaultAdapter(), TestNoUser.class);
NoRegister registration = core.register(user, password.toCharArray());
core.confirm(getCopy(registration.cookie), password.toCharArray(), getCopy(registration.data));
return getCopy(registration.data);
@@ -50,7 +50,7 @@ public class NoRoutineTest {
final byte[] userFile = registerAndConfirm(new TestNoUser("username"), "password");
NoAdapter adapter = new NoDefaultAdapter();
NoCore core = new NoCore(adapter);
NoCore core = new NoCore(adapter, TestNoUser.class);
byte[] cookie = core.login(getCopy(userFile), "password".toCharArray());
TestNoUser userRegistered = (TestNoUser) core.getNoUser(Arrays.copyOf(cookie, cookie.length));
@@ -84,7 +84,7 @@ public class NoRoutineTest {
NoUserAlreadyOnlineException, NoSessionNotChangedException,
NoSessionAlreadyAwaitingConfirmationException { // testing TestJustTouchStaticField
byte[] userFile = registerAndConfirm(new TestNoUser("username"), "password");
NoCore core = new NoCore(new NoDefaultAdapter());
NoCore core = new NoCore(new NoDefaultAdapter(), TestNoUser.class);
int touchCount = TestJustTouchStaticField.touchMe;
@@ -118,7 +118,7 @@ public class NoRoutineTest {
NoUserNotValidException, NoUserAlreadyOnlineException, NoSessionNotChangedException,
NoSessionAlreadyAwaitingConfirmationException { // testing TestRequestFunds
byte[] requesterFile = registerAndConfirm(new TestNoUser("requester"), "password");
NoCore core = new NoCore(new NoDefaultAdapter());
NoCore core = new NoCore(new NoDefaultAdapter(), TestNoUser.class);
byte[] requesterCookie = core.login(getCopy(requesterFile), "password".toCharArray());
TestNoUser requester = (TestNoUser) core.getNoUser(getCopy(requesterCookie));
@@ -137,7 +137,7 @@ public class NoRoutineTest {
NoUserNotValidException, NoUserAlreadyOnlineException, NoSessionNotChangedException,
NoSessionAlreadyAwaitingConfirmationException { // testing TestRequestFunds
byte[] requesterFile = registerAndConfirm(new TestNoUser("requester"), "password");
NoCore core = new NoCore(new NoDefaultAdapter());
NoCore core = new NoCore(new NoDefaultAdapter(), TestNoUser.class);
byte[] requesterCookie = core.login(getCopy(requesterFile), "password".toCharArray());
TestNoUser requester = (TestNoUser) core.getNoUser(getCopy(requesterCookie));
@@ -161,7 +161,7 @@ public class NoRoutineTest {
NoSessionAlreadyAwaitingConfirmationException { // testing TestSendFunds
byte[] fundSenderFile = registerAndConfirm(new TestNoUser("fund-sender"), "password1");
byte[] fundGetterFile = registerAndConfirm(new TestNoUser("fund-getter"), "password2");
NoCore core = new NoCore(new NoDefaultAdapter());
NoCore core = new NoCore(new NoDefaultAdapter(), TestNoUser.class);
byte[] senderCookie = core.login(getCopy(fundSenderFile), "password1".toCharArray());
TestNoUser sender = (TestNoUser) core.getNoUser(senderCookie);
@@ -211,7 +211,7 @@ public class NoRoutineTest {
NoSessionAlreadyAwaitingConfirmationException { // testing TestSendFundsReceipted
byte[] fundSenderFile = registerAndConfirm(new TestNoUser("fund-sender"), "password1");
byte[] fundGetterFile = registerAndConfirm(new TestNoUser("fund-getter"), "password2");
NoCore core = new NoCore(new NoDefaultAdapter());
NoCore core = new NoCore(new NoDefaultAdapter(), TestNoUser.class);
byte[] senderCookie = core.login(getCopy(fundSenderFile), "password1".toCharArray());
TestNoUser sender = (TestNoUser) core.getNoUser(senderCookie);
@@ -268,7 +268,7 @@ public class NoRoutineTest {
NoUserNotValidException, NoUserAlreadyOnlineException { // testing TestSendFundsSourced
byte[] fundSenderFile = registerAndConfirm(new TestNoUser("fund-sender"), "password1");
byte[] fundGetterFile = registerAndConfirm(new TestNoUser("fund-getter"), "password2");
NoCore core = new NoCore(new NoDefaultAdapter());
NoCore core = new NoCore(new NoDefaultAdapter(), TestNoUser.class);
byte[] senderCookie = core.login(getCopy(fundSenderFile), "password1".toCharArray());
TestNoUser sender = (TestNoUser) core.getNoUser(senderCookie);

View File

@@ -3,6 +3,7 @@ package nodash.test.functional.implementations;
import java.util.ArrayList;
import java.util.List;
import nodash.models.NoHash;
import nodash.models.NoUser;
public class TestNoUser extends NoUser {
@@ -11,8 +12,13 @@ public class TestNoUser extends NoUser {
*/
private static final long serialVersionUID = 1L;
@NoHash
private String username;
@NoHash
private int money;
@NoHash
private List<String> receipts;
public TestNoUser(String username) {