|
From: <pe...@us...> - 2003-10-28 23:56:29
|
Update of /cvsroot/neuclear/neuclear-id/src/test/org/neuclear/signers
In directory sc8-pr-cvs1:/tmp/cvs-serv10750/src/test/org/neuclear/signers
Modified Files:
SimpleSignerStoreTest.java
Log Message:
Fixed the SimpleSignerStore unit test to verify the next functionality of the SignerStore interface.
Index: SimpleSignerStoreTest.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-id/src/test/org/neuclear/signers/SimpleSignerStoreTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** SimpleSignerStoreTest.java 21 Oct 2003 22:31:15 -0000 1.3
--- SimpleSignerStoreTest.java 28 Oct 2003 23:56:04 -0000 1.4
***************
*** 1,4 ****
--- 1,7 ----
/* $Id$
* $Log$
+ * Revision 1.4 2003/10/28 23:56:04 pelle
+ * Fixed the SimpleSignerStore unit test to verify the next functionality of the SignerStore interface.
+ *
* Revision 1.3 2003/10/21 22:31:15 pelle
* Renamed NeudistException to NeuClearException and moved it to org.neuclear.commons where it makes more sense.
***************
*** 59,68 ****
import junit.framework.TestCase;
- import org.neudist.crypto.signerstores.SimpleSignerStore;
import org.neuclear.commons.NeuClearException;
import java.io.File;
import java.io.IOException;
! import java.security.*;
--- 62,76 ----
import junit.framework.TestCase;
import org.neuclear.commons.NeuClearException;
+ import org.neudist.crypto.CryptoException;
+ import org.neudist.crypto.CryptoTools;
+ import org.neudist.crypto.signerstores.SimpleSignerStore;
import java.io.File;
import java.io.IOException;
! import java.security.GeneralSecurityException;
! import java.security.KeyPair;
! import java.security.KeyPairGenerator;
! import java.security.SecureRandom;
***************
*** 70,78 ****
* @author pelleb
* @version $Revision$
! **/
public class SimpleSignerStoreTest extends TestCase {
public SimpleSignerStoreTest(String name) throws GeneralSecurityException, NeuClearException {
super(name);
! setUp();
}
--- 78,87 ----
* @author pelleb
* @version $Revision$
! */
public class SimpleSignerStoreTest extends TestCase {
public SimpleSignerStoreTest(String name) throws GeneralSecurityException, NeuClearException {
super(name);
! store = getSignerStoreInstance();
! generateKeys();
}
***************
*** 84,91 ****
}
- protected void setUp() throws NeuClearException, GeneralSecurityException {
- store = getSignerStoreInstance();
- generateKeys();
- }
protected static synchronized void generateKeys() throws GeneralSecurityException {
--- 93,96 ----
***************
*** 101,107 ****
}
- protected void tearDown() {
- store = null;
- }
public void testAddKey() throws NeuClearException, GeneralSecurityException, IOException {
--- 106,109 ----
***************
*** 118,127 ****
}
! public void testGetKey() throws NeuClearException, GeneralSecurityException, IOException {
boolean success = false;
! PrivateKey key = null;
try {
store.addKey("bob", "bob".toCharArray(), bob.getPrivate());
! key = store.getKey("bob", "bob".toCharArray());
success = true;
} catch (GeneralSecurityException e) {
--- 120,130 ----
}
! public void testSignData() throws NeuClearException, GeneralSecurityException, IOException, CryptoException {
boolean success = false;
! byte data[] = null;
try {
store.addKey("bob", "bob".toCharArray(), bob.getPrivate());
! data = store.sign("bob", "test".getBytes());
! assertTrue(CryptoTools.verify(bob.getPublic(), "test".getBytes(), data));
success = true;
} catch (GeneralSecurityException e) {
***************
*** 130,153 ****
e.printStackTrace();
}
! assertTrue("Managed to add and Fetch a key", success);
! assertNotNull("Key wasn't null", key);
! assertEquals("Gotten Key was the same as Stored Key", bob.getPrivate(), key);
}
- public static void main(String[] args) {
- try {
- SimpleSignerStoreTest test = new SimpleSignerStoreTest("SimpleSignerStoreTest");
- test.setUp();
- test.testGetKey();
- } catch (Exception e) {
- // if (e instanceof NeuClearException) {
- // ((NeuClearException)e).getParcel().printStackTrace();
- // } else
- e.printStackTrace();
-
- }
-
- // junit.textui.TestRunner.run (suite());
- }
private SimpleSignerStore store;
--- 133,141 ----
e.printStackTrace();
}
! assertTrue("Managed to add and sign some data", success);
! assertNotNull("Key wasn't null", data);
! //assertEquals("Gotten Key was the same as Stored Key", bob.getPrivate(), key);
}
private SimpleSignerStore store;
|