set up NoUtil to use a env secret key

This commit is contained in:
Dave
2015-07-03 23:24:57 +02:00
parent c0b2c1c82d
commit 788e2a8dc4
9 changed files with 33 additions and 34 deletions

View File

@@ -8,6 +8,7 @@ import nodash.core.NoAdapter;
import nodash.core.NoCore;
import nodash.core.NoDefaultAdapter;
import nodash.core.NoRegister;
import nodash.exceptions.NoAdapterException;
import nodash.exceptions.NoDashSessionBadUuidException;
import nodash.exceptions.NoSessionAlreadyAwaitingConfirmationException;
import nodash.exceptions.NoSessionConfirmedException;
@@ -23,12 +24,6 @@ import org.junit.Test;
public class NoCoreTest {
@Test
public void testLogin() {
NoCore core = new NoCore(new NoDefaultAdapter());
fail("Not yet implemented");
}
@Test
public void testRegister() {
NoCore core = new NoCore(new NoDefaultAdapter());
@@ -70,7 +65,7 @@ public class NoCoreTest {
@Test
public void testSaveAndConfirm() throws NoSessionExpiredException, NoSessionConfirmedException,
NoSessionNotAwaitingConfirmationException, NoUserNotValidException,
NoDashSessionBadUuidException, NoUserAlreadyOnlineException, NoSessionNotChangedException, NoSessionAlreadyAwaitingConfirmationException {
NoDashSessionBadUuidException, NoUserAlreadyOnlineException, NoSessionNotChangedException, NoSessionAlreadyAwaitingConfirmationException, NoAdapterException {
NoAdapter adapter = new NoDefaultAdapter();
NoCore core = new NoCore(adapter);
@@ -79,7 +74,7 @@ public class NoCoreTest {
byte[] newUserFile = Arrays.copyOf(registration.data, registration.data.length);
core.confirm(registration.cookie, "password".toCharArray(), newUserFile);
byte[] newUserHash = newUser.createHash();
assertTrue(adapter.checkHash(newUserHash));
adapter.checkHash(newUserHash);
NoUser newUserBadPass = new NoUser();
registration = core.register(newUserBadPass, "password".toCharArray());
@@ -109,15 +104,20 @@ public class NoCoreTest {
assertNotNull(adapter.getNoSession(oldUserCookie));
oldUser.createFile("password".toCharArray()); // Touch the randomizer
NoUser oldUserRevisited = core.getUser(oldUserCookie);
NoUser oldUserRevisited = core.getNoUser(oldUserCookie);
byte[] currentHash = oldUserRevisited.createHash();
oldUserRevisited.createFile("password".toCharArray());
byte[] oldCreatedFile = core.save(oldUserCookie, "new-password".toCharArray());
byte[] oldUserHash = oldUserRevisited.createHash();
core.confirm(oldUserCookie, "new-password".toCharArray(), oldCreatedFile);
assertFalse(adapter.containsNoSession(oldUserCookie));
assertTrue(adapter.checkHash(oldUserHash));
assertFalse(adapter.checkHash(currentHash));
adapter.checkHash(oldUserHash);
try {
adapter.checkHash(currentHash);
fail("Did not fail on checkhash.");
} catch (NoUserNotValidException e) {
// Correct, do nothing
}
}

View File

@@ -10,11 +10,6 @@ import org.junit.Before;
import org.junit.Test;
public class NoSessionTest {
@Before
public void setup() {
NoCore.setup();
}
@Test
public void testNoSession() throws NoSessionConfirmedException, NoSessionExpiredException {

View File

@@ -17,11 +17,6 @@ import org.junit.Test;
public class NoUserTest {
@Before
public void setup() {
NoCore.setup();
}
@Test
public void testNoUser() {
NoUser user = new NoUser();

View File

@@ -23,11 +23,6 @@ import org.junit.Test;
public class NoUtilTest {
@Before
public void setup() throws NoSuchAlgorithmException, NoSuchPaddingException, NoSuchProviderException {
NoCore.setup();
}
@Test
public void testAllowedKeySize() throws NoSuchAlgorithmException {
if (Cipher.getMaxAllowedKeyLength(NoUtil.CIPHER_KEY_SPEC) < NoUtil.AES_STRENGTH) {