use of com.github.dedis.popstellar.model.objects.security.PoPToken in project popstellar by dedis.
the class KeyManagerTest method popTokenRetrievingFailsWhenWalletFails.
@Test
public void popTokenRetrievingFailsWhenWalletFails() throws KeyException {
PoPToken token = Base64DataUtils.generatePoPToken();
// create LAO and RollCall
Lao lao = new Lao("lao", Base64DataUtils.generatePublicKey(), 54213424);
RollCall rollCall = new RollCall(lao.getId(), 5421364, "rollcall");
lao.updateRollCall(rollCall.getId(), rollCall);
KeyManager manager = new KeyManager(androidKeysetManager, wallet);
// Test with every possible errors
when(wallet.recoverKey(any(), any(), any())).thenThrow(new KeyGenerationException(new GeneralSecurityException()));
assertThrows(KeyGenerationException.class, () -> manager.getValidPoPToken(lao));
verify(wallet, times(1)).recoverKey(eq(lao.getId()), eq(rollCall.getId()), any());
reset(wallet);
when(wallet.recoverKey(any(), any(), any())).thenThrow(new UninitializedWalletException());
assertThrows(UninitializedWalletException.class, () -> manager.getValidPoPToken(lao));
verify(wallet, times(1)).recoverKey(eq(lao.getId()), eq(rollCall.getId()), any());
reset(wallet);
when(wallet.recoverKey(any(), any(), any())).thenThrow(new InvalidPoPTokenException(token));
assertThrows(InvalidPoPTokenException.class, () -> manager.getValidPoPToken(lao));
verify(wallet, times(1)).recoverKey(eq(lao.getId()), eq(rollCall.getId()), any());
}
use of com.github.dedis.popstellar.model.objects.security.PoPToken in project popstellar by dedis.
the class WalletTest method crossValidationWithFe1Web.
@Test
public void crossValidationWithFe1Web() throws GeneralSecurityException, KeyException {
String Lao_ID = "T8grJq7LR9KGjE7741gXMqPny8xsLvsyBiwIFwoF7rg=";
String Roll_Call_ID = "T8grJq7LR9KGjE7741gXMqPny8xsLvsyBiwIFwoF7rg=";
Wallet hdw = new Wallet(TestKeysetModule.provideWalletKeysetManager());
hdw.importSeed("garbage effort river orphan negative kind outside quit hat camera approve first");
PoPToken res = hdw.generatePoPToken(Lao_ID, Roll_Call_ID);
assertEquals("9e8ca414e088b2276d140bb69302269ccede242197e1f1751c45ec40b01678a0", Utils.bytesToHex(res.getPrivateKey().getData()));
assertEquals("7147759d146897111bcf74f60a1948b1d3a22c9199a6b88c236eb7326adc2efc", Utils.bytesToHex(res.getPublicKey().getData()));
}
Aggregations