tests: only delete keystore when it's actually available

This commit is contained in:
Bruno Bierbaumer 2015-11-24 14:28:45 +01:00
parent 3f6d97da43
commit 58a0bbae24

View file

@ -2,6 +2,7 @@ package net.bierbaumer.otp_authenticator;
import android.app.Application; import android.app.Application;
import android.content.Context; import android.content.Context;
import android.os.Build;
import android.test.ApplicationTestCase; import android.test.ApplicationTestCase;
import org.apache.commons.codec.DecoderException; import org.apache.commons.codec.DecoderException;
@ -95,10 +96,13 @@ public class ApplicationTest extends ApplicationTestCase<Application> {
public void testSettingsHelper() throws KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException { public void testSettingsHelper() throws KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException {
Context context = getContext(); Context context = getContext();
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
final KeyStore keyStore = KeyStore.getInstance("AndroidKeyStore"); final KeyStore keyStore = KeyStore.getInstance("AndroidKeyStore");
keyStore.load(null); keyStore.load(null);
keyStore.deleteEntry("settings"); keyStore.deleteEntry("settings");
}
new File(context.getFilesDir() + "/" + SettingsHelper.SETTINGS_FILE).delete(); new File(context.getFilesDir() + "/" + SettingsHelper.SETTINGS_FILE).delete();
new File(context.getFilesDir() + "/" + SettingsHelper.KEY_FILE).delete(); new File(context.getFilesDir() + "/" + SettingsHelper.KEY_FILE).delete();