Skip to content

Commit

Permalink
Android: Added tests that validate ECIES encryptor creation
Browse files Browse the repository at this point in the history
  • Loading branch information
hvge committed Oct 3, 2024
1 parent 5908ed2 commit 5b6b965
Showing 1 changed file with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import androidx.test.ext.junit.runners.AndroidJUnit4;

import com.google.gson.reflect.TypeToken;
import io.getlime.security.powerauth.core.EciesEncryptor;
import io.getlime.security.powerauth.networking.client.JsonSerialization;
import io.getlime.security.powerauth.networking.response.*;
import org.junit.After;
Expand Down Expand Up @@ -506,4 +507,46 @@ public void onJwtSignatureFailed(@NonNull Throwable t) {
boolean result = testHelper.getServerApi().verifyEcdsaSignature(activationHelper.getActivation().getActivationId(), jwtSignedDatasBase64, jwtSignatureBase64, "JOSE");
assertTrue(result);
}

@Test
public void testEciesEncryptors() throws Exception {
EciesEncryptor encryptor = AsyncHelper.await(resultCatcher -> {
powerAuthSDK.getEciesEncryptorForApplicationScope(new IGetEciesEncryptorListener() {
@Override
public void onGetEciesEncryptorSuccess(@NonNull EciesEncryptor encryptor) {
resultCatcher.completeWithResult(encryptor);
}

@Override
public void onGetEciesEncryptorFailed(@NonNull Throwable t) {
resultCatcher.completeWithError(t);
}
});
});
assertNotNull(encryptor);

// Now create activation
activationHelper.createStandardActivation(true, null);
final ActivationHelper.HelperState activationHelperState = activationHelper.getHelperState();

// Now re-instantiate PowerAuthSDK (e.g. with no-EEK in configuration)
testHelper = new PowerAuthTestHelper.Builder().build(true);
powerAuthSDK = testHelper.getSharedSdk();
activationHelper = new ActivationHelper(testHelper, activationHelperState);

encryptor = AsyncHelper.await(resultCatcher -> {
powerAuthSDK.getEciesEncryptorForApplicationScope(new IGetEciesEncryptorListener() {
@Override
public void onGetEciesEncryptorSuccess(@NonNull EciesEncryptor encryptor) {
resultCatcher.completeWithResult(encryptor);
}

@Override
public void onGetEciesEncryptorFailed(@NonNull Throwable t) {
resultCatcher.completeWithError(t);
}
});
});
assertNotNull(encryptor);
}
}

0 comments on commit 5b6b965

Please sign in to comment.