From f8c2f76971f5a7f26d18e5e669d5e0ce9c560f3f Mon Sep 17 00:00:00 2001 From: Fup Duck Date: Thu, 7 Dec 2017 12:52:29 +0100 Subject: Rename constants * renamed last constants * remove unnecessary updates/ConstantUnification --- .../java/se/leap/bitmaskclient/test/TestEIP.java | 4 ++-- .../java/se/leap/bitmaskclient/ProviderAPI.java | 8 ++++---- .../se/leap/bitmaskclient/ProviderDetailFragment.java | 5 ++--- app/src/main/java/de/blinkt/openvpn/VpnProfile.java | 2 +- .../se/leap/bitmaskclient/BaseConfigurationWizard.java | 4 ++-- app/src/main/java/se/leap/bitmaskclient/Constants.java | 14 ++++++-------- app/src/main/java/se/leap/bitmaskclient/Dashboard.java | 4 ++-- .../java/se/leap/bitmaskclient/FeatureVersionCode.java | 5 +++++ .../java/se/leap/bitmaskclient/ProviderApiBase.java | 6 +++--- .../main/java/se/leap/bitmaskclient/StartActivity.java | 14 +++++--------- .../java/se/leap/bitmaskclient/VersionMilestone.java | 6 ------ .../main/java/se/leap/bitmaskclient/VpnFragment.java | 6 +++--- app/src/main/java/se/leap/bitmaskclient/eip/EIP.java | 4 ++-- .../se/leap/bitmaskclient/eip/GatewaysManager.java | 5 +++-- .../se/leap/bitmaskclient/eip/VpnConfigGenerator.java | 4 ++-- .../bitmaskclient/updates/ConstantUnification.java | 18 ------------------ .../se/leap/bitmaskclient/eip/GatewaysManagerTest.java | 4 ++-- .../leap/bitmaskclient/eip/VpnConfigGeneratorTest.java | 8 ++++---- 18 files changed, 48 insertions(+), 73 deletions(-) create mode 100644 app/src/main/java/se/leap/bitmaskclient/FeatureVersionCode.java delete mode 100644 app/src/main/java/se/leap/bitmaskclient/VersionMilestone.java delete mode 100644 app/src/main/java/se/leap/bitmaskclient/updates/ConstantUnification.java diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/TestEIP.java b/app/src/androidTest/java/se/leap/bitmaskclient/test/TestEIP.java index f06846a9..c5a6e809 100644 --- a/app/src/androidTest/java/se/leap/bitmaskclient/test/TestEIP.java +++ b/app/src/androidTest/java/se/leap/bitmaskclient/test/TestEIP.java @@ -59,13 +59,13 @@ public class TestEIP extends ServiceTestCase { } private void testEmptyCertificate() { - preferences.edit().putString(Constants.VPN_CERTIFICATE, "").apply(); + preferences.edit().putString(Constants.PROVIDER_VPN_CERTIFICATE, "").apply(); startService(Constants.EIP_ACTION_CHECK_CERT_VALIDITY); } private void testExpiredCertificate() { String expired_certificate = "expired certificate"; - preferences.edit().putString(Constants.VPN_CERTIFICATE, expired_certificate).apply(); + preferences.edit().putString(Constants.PROVIDER_VPN_CERTIFICATE, expired_certificate).apply(); startService(Constants.EIP_ACTION_CHECK_CERT_VALIDITY); } diff --git a/app/src/insecure/java/se/leap/bitmaskclient/ProviderAPI.java b/app/src/insecure/java/se/leap/bitmaskclient/ProviderAPI.java index c6826a53..7689c343 100644 --- a/app/src/insecure/java/se/leap/bitmaskclient/ProviderAPI.java +++ b/app/src/insecure/java/se/leap/bitmaskclient/ProviderAPI.java @@ -137,8 +137,8 @@ public class ProviderAPI extends ProviderApiBase { //TODO setProviderName(name); preferences.edit().putString(Provider.KEY, provider_json.toString()).commit(); - preferences.edit().putBoolean(Constants.ALLOWED_ANON, provider_json.getJSONObject(Provider.SERVICE).getBoolean(Constants.ALLOWED_ANON)).commit(); - preferences.edit().putBoolean(Constants.ALLOWED_REGISTERED, provider_json.getJSONObject(Provider.SERVICE).getBoolean(Constants.ALLOWED_REGISTERED)).commit(); + preferences.edit().putBoolean(Constants.PROVIDER_ALLOW_ANONYMOUS, provider_json.getJSONObject(Provider.SERVICE).getBoolean(Constants.PROVIDER_ALLOW_ANONYMOUS)).commit(); + preferences.edit().putBoolean(Constants.PROVIDER_ALLOWED_REGISTERED, provider_json.getJSONObject(Provider.SERVICE).getBoolean(Constants.PROVIDER_ALLOWED_REGISTERED)).commit(); result.putBoolean(RESULT_KEY, true); } catch (JSONException e) { @@ -167,7 +167,7 @@ public class ProviderAPI extends ProviderApiBase { JSONObject eip_service_json = new JSONObject(eip_service_json_string); eip_service_json.getInt(Provider.API_RETURN_SERIAL); - preferences.edit().putString(Constants.KEY, eip_service_json.toString()).commit(); + preferences.edit().putString(Constants.PROVIDER_KEY, eip_service_json.toString()).commit(); result.putBoolean(RESULT_KEY, true); } catch (NullPointerException | JSONException e) { @@ -190,7 +190,7 @@ public class ProviderAPI extends ProviderApiBase { JSONObject provider_json = new JSONObject(preferences.getString(Provider.KEY, "")); String provider_main_url = provider_json.getString(Provider.API_URL); - URL new_cert_string_url = new URL(provider_main_url + "/" + provider_json.getString(Provider.API_VERSION) + "/" + Constants.VPN_CERTIFICATE); + URL new_cert_string_url = new URL(provider_main_url + "/" + provider_json.getString(Provider.API_VERSION) + "/" + Constants.PROVIDER_VPN_CERTIFICATE); String cert_string = downloadWithProviderCA(new_cert_string_url.toString(), last_danger_on); diff --git a/app/src/insecure/java/se/leap/bitmaskclient/ProviderDetailFragment.java b/app/src/insecure/java/se/leap/bitmaskclient/ProviderDetailFragment.java index f6ebfc4b..390d4aeb 100644 --- a/app/src/insecure/java/se/leap/bitmaskclient/ProviderDetailFragment.java +++ b/app/src/insecure/java/se/leap/bitmaskclient/ProviderDetailFragment.java @@ -2,7 +2,6 @@ package se.leap.bitmaskclient; import org.json.*; -import se.leap.bitmaskclient.eip.*; import se.leap.bitmaskclient.ProviderListContent.ProviderItem; import android.app.*; @@ -60,7 +59,7 @@ public class ProviderDetailFragment extends DialogFragment { private boolean anon_allowed(JSONObject provider_json) { try { JSONObject service_description = provider_json.getJSONObject(Provider.SERVICE); - return service_description.has(Constants.ALLOWED_ANON) && service_description.getBoolean(Constants.ALLOWED_ANON); + return service_description.has(Constants.PROVIDER_ALLOW_ANONYMOUS) && service_description.getBoolean(Constants.PROVIDER_ALLOW_ANONYMOUS); } catch (JSONException e) { return false; } @@ -79,7 +78,7 @@ public class ProviderDetailFragment extends DialogFragment { public void onCancel(DialogInterface dialog) { super.onCancel(dialog); SharedPreferences.Editor editor = getActivity().getSharedPreferences(Constants.SHARED_PREFERENCES, Activity.MODE_PRIVATE).edit(); - editor.remove(Provider.KEY).remove(ProviderItem.DANGER_ON).remove(Constants.ALLOWED_ANON).remove(Constants.KEY).commit(); + editor.remove(Provider.KEY).remove(ProviderItem.DANGER_ON).remove(Constants.PROVIDER_ALLOW_ANONYMOUS).remove(Constants.PROVIDER_KEY).commit(); interface_with_configuration_wizard.cancelAndShowAllProviders(); } diff --git a/app/src/main/java/de/blinkt/openvpn/VpnProfile.java b/app/src/main/java/de/blinkt/openvpn/VpnProfile.java index aa25da48..cc8d987c 100644 --- a/app/src/main/java/de/blinkt/openvpn/VpnProfile.java +++ b/app/src/main/java/de/blinkt/openvpn/VpnProfile.java @@ -1017,7 +1017,7 @@ public class VpnProfile implements Serializable, Cloneable { if (data.contains("Proc-Type: 4,ENCRYPTED")) return true; - else if (data.contains("-----BEGIN ENCRYPTED PRIVATE KEY-----")) + else if (data.contains("-----BEGIN ENCRYPTED PRIVATE PROVIDER_KEY-----")) return true; else return false; diff --git a/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java b/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java index 2ff8a088..21520dc4 100644 --- a/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java +++ b/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java @@ -219,7 +219,7 @@ public abstract class BaseConfigurationWizard extends Activity e.printStackTrace(); } - if (preferences.getBoolean(Constants.ALLOWED_ANON, false)) { + if (preferences.getBoolean(Constants.PROVIDER_ALLOW_ANONYMOUS, false)) { mConfigState.putExtra(SERVICES_RETRIEVED, true); downloadVpnCertificate(); @@ -296,7 +296,7 @@ public abstract class BaseConfigurationWizard extends Activity public void cancelSettingUpProvider() { mConfigState.setAction(PROVIDER_NOT_SET); adapter.showAllProviders(); - preferences.edit().remove(Provider.KEY).remove(Constants.ALLOWED_ANON).remove(Constants.KEY).apply(); + preferences.edit().remove(Provider.KEY).remove(Constants.PROVIDER_ALLOW_ANONYMOUS).remove(Constants.PROVIDER_KEY).apply(); } private void askDashboardToQuitApp() { diff --git a/app/src/main/java/se/leap/bitmaskclient/Constants.java b/app/src/main/java/se/leap/bitmaskclient/Constants.java index f330ef68..8723191c 100644 --- a/app/src/main/java/se/leap/bitmaskclient/Constants.java +++ b/app/src/main/java/se/leap/bitmaskclient/Constants.java @@ -27,14 +27,12 @@ public interface Constants { ////////////////////////////////////////////// - // ? CONSTANTS + // PROVIDER CONSTANTS ///////////////////////////////////////////// - - // TODO FIND BETTER NAMES AND DO NOT USE AS PREFERENCES KEY - String ALLOWED_ANON = "allow_anonymous"; - String ALLOWED_REGISTERED = "allow_registration"; - String VPN_CERTIFICATE = "cert"; - String PRIVATE_KEY = "Constants.PRIVATE_KEY"; - String KEY = "Constants.KEY"; + String PROVIDER_ALLOW_ANONYMOUS = "allow_anonymous"; + String PROVIDER_ALLOWED_REGISTERED = "allow_registration"; + String PROVIDER_VPN_CERTIFICATE = "cert"; + String PROVIDER_PRIVATE_KEY = "Constants.PROVIDER_PRIVATE_KEY"; + String PROVIDER_KEY = "Constants.PROVIDER_KEY"; String PROVIDER_CONFIGURED = "Constants.PROVIDER_CONFIGURED"; } diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java index df558e08..1f0477c9 100644 --- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java +++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java @@ -159,7 +159,7 @@ public class Dashboard extends Activity implements ProviderAPIResultReceiver.Rec switch (versionCode) { case 91: // 0.6.0 without Bug #5999 case 101: // 0.8.0 - if (!preferences.getString(Constants.KEY, "").isEmpty()) + if (!preferences.getString(Constants.PROVIDER_KEY, "").isEmpty()) eip_fragment.updateEipService(); break; } @@ -315,7 +315,7 @@ public class Dashboard extends Activity implements ProviderAPIResultReceiver.Rec public void downloadVpnCertificate() { boolean is_authenticated = User.loggedIn(); - boolean allowed_anon = preferences.getBoolean(Constants.ALLOWED_ANON, false); + boolean allowed_anon = preferences.getBoolean(Constants.PROVIDER_ALLOW_ANONYMOUS, false); if (allowed_anon || is_authenticated) ProviderAPICommand.execute(Bundle.EMPTY, ProviderAPI.DOWNLOAD_CERTIFICATE, providerAPI_result_receiver); else diff --git a/app/src/main/java/se/leap/bitmaskclient/FeatureVersionCode.java b/app/src/main/java/se/leap/bitmaskclient/FeatureVersionCode.java new file mode 100644 index 00000000..b2a39c1a --- /dev/null +++ b/app/src/main/java/se/leap/bitmaskclient/FeatureVersionCode.java @@ -0,0 +1,5 @@ +package se.leap.bitmaskclient; + +public interface FeatureVersionCode { + int MULTIPLE_PROFILES = 132; +} diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderApiBase.java b/app/src/main/java/se/leap/bitmaskclient/ProviderApiBase.java index b9063f18..38981289 100644 --- a/app/src/main/java/se/leap/bitmaskclient/ProviderApiBase.java +++ b/app/src/main/java/se/leap/bitmaskclient/ProviderApiBase.java @@ -807,7 +807,7 @@ public abstract class ProviderApiBase extends IntentService { String certificateString = null, keyString = null; String[] certAndKey = cert_string.split("(?<=-\n)"); for (int i = 0; i < certAndKey.length - 1; i++) { - if (certAndKey[i].contains("KEY")) { + if (certAndKey[i].contains("PROVIDER_KEY")) { keyString = certAndKey[i++] + certAndKey[i]; } else if (certAndKey[i].contains("CERTIFICATE")) { certificateString = certAndKey[i++] + certAndKey[i]; @@ -816,11 +816,11 @@ public abstract class ProviderApiBase extends IntentService { RSAPrivateKey key = ConfigHelper.parseRsaKeyFromString(keyString); keyString = Base64.encodeToString(key.getEncoded(), Base64.DEFAULT); - preferences.edit().putString(Constants.PRIVATE_KEY, "-----BEGIN RSA PRIVATE KEY-----\n" + keyString + "-----END RSA PRIVATE KEY-----").commit(); + preferences.edit().putString(Constants.PROVIDER_PRIVATE_KEY, "-----BEGIN RSA PRIVATE PROVIDER_KEY-----\n" + keyString + "-----END RSA PRIVATE PROVIDER_KEY-----").commit(); X509Certificate certificate = ConfigHelper.parseX509CertificateFromString(certificateString); certificateString = Base64.encodeToString(certificate.getEncoded(), Base64.DEFAULT); - preferences.edit().putString(Constants.VPN_CERTIFICATE, "-----BEGIN CERTIFICATE-----\n" + certificateString + "-----END CERTIFICATE-----").commit(); + preferences.edit().putString(Constants.PROVIDER_VPN_CERTIFICATE, "-----BEGIN CERTIFICATE-----\n" + certificateString + "-----END CERTIFICATE-----").commit(); return true; } catch (CertificateException e) { // TODO Auto-generated catch block diff --git a/app/src/main/java/se/leap/bitmaskclient/StartActivity.java b/app/src/main/java/se/leap/bitmaskclient/StartActivity.java index ade43701..dd2be212 100644 --- a/app/src/main/java/se/leap/bitmaskclient/StartActivity.java +++ b/app/src/main/java/se/leap/bitmaskclient/StartActivity.java @@ -13,7 +13,6 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import de.blinkt.openvpn.core.VpnStatus; -import se.leap.bitmaskclient.updates.ConstantUnification; import se.leap.bitmaskclient.userstatus.User; /** @@ -113,15 +112,12 @@ public class StartActivity extends Activity { } /** - * execute necessary updates for version change + * execute necessary upgrades for version change */ private void executeUpgrade() { - if (passedMilestone(VersionMilestone.MULTIPLE_PROFILES)) { + if (hasNewFeature(FeatureVersionCode.MULTIPLE_PROFILES)) { // TODO prepare usage of multiple profiles } - if (passedMilestone(VersionMilestone.CONSTANT_UNIFICATION)) { - ConstantUnification.upgrade(preferences); - } // ensure all upgrades have passed before storing new information preferences.edit().putInt(Constants.PREFERENCES_APP_VERSION, versionCode).apply(); @@ -129,11 +125,11 @@ public class StartActivity extends Activity { /** * check if an upgrade passed or moved to given milestone - * @param milestone Version code of the Milestone VersionMilestone.MILE_STONE + * @param featureVersionCode Version code of the Milestone FeatureVersionCode.MILE_STONE * @return true if milestone is reached - false otherwise */ - private boolean passedMilestone(int milestone) { - return previousVersionCode < milestone && versionCode >= milestone; + private boolean hasNewFeature(int featureVersionCode) { + return previousVersionCode < featureVersionCode && versionCode >= featureVersionCode; } } diff --git a/app/src/main/java/se/leap/bitmaskclient/VersionMilestone.java b/app/src/main/java/se/leap/bitmaskclient/VersionMilestone.java deleted file mode 100644 index eac57d72..00000000 --- a/app/src/main/java/se/leap/bitmaskclient/VersionMilestone.java +++ /dev/null @@ -1,6 +0,0 @@ -package se.leap.bitmaskclient; - -public interface VersionMilestone { - int MULTIPLE_PROFILES = 132; - int CONSTANT_UNIFICATION = 132; -} diff --git a/app/src/main/java/se/leap/bitmaskclient/VpnFragment.java b/app/src/main/java/se/leap/bitmaskclient/VpnFragment.java index 7b01714f..f787a955 100644 --- a/app/src/main/java/se/leap/bitmaskclient/VpnFragment.java +++ b/app/src/main/java/se/leap/bitmaskclient/VpnFragment.java @@ -163,13 +163,13 @@ public class VpnFragment extends Fragment implements Observer { } private boolean canStartEIP() { - boolean certificateExists = !Dashboard.preferences.getString(Constants.VPN_CERTIFICATE, "").isEmpty(); - boolean isAllowedAnon = Dashboard.preferences.getBoolean(Constants.ALLOWED_ANON, false); + boolean certificateExists = !Dashboard.preferences.getString(Constants.PROVIDER_VPN_CERTIFICATE, "").isEmpty(); + boolean isAllowedAnon = Dashboard.preferences.getBoolean(Constants.PROVIDER_ALLOW_ANONYMOUS, false); return (isAllowedAnon || certificateExists) && !eip_status.isConnected() && !eip_status.isConnecting(); } private boolean canLogInToStartEIP() { - boolean isAllowedRegistered = Dashboard.preferences.getBoolean(Constants.ALLOWED_REGISTERED, false); + boolean isAllowedRegistered = Dashboard.preferences.getBoolean(Constants.PROVIDER_ALLOWED_REGISTERED, false); boolean isLoggedIn = !LeapSRPSession.getToken().isEmpty(); return isAllowedRegistered && !isLoggedIn && !eip_status.isConnecting() && !eip_status.isConnected(); } diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java index 929a0c70..0b35dc3d 100644 --- a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java +++ b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java @@ -154,7 +154,7 @@ public final class EIP extends IntentService { private JSONObject eipDefinitionFromPreferences() { JSONObject result = new JSONObject(); try { - String eip_definition_string = preferences.getString(Constants.KEY, ""); + String eip_definition_string = preferences.getString(Constants.PROVIDER_KEY, ""); if (!eip_definition_string.isEmpty()) { result = new JSONObject(eip_definition_string); } @@ -184,7 +184,7 @@ public final class EIP extends IntentService { } private void checkCertValidity() { - VpnCertificateValidator validator = new VpnCertificateValidator(preferences.getString(Constants.VPN_CERTIFICATE, "")); + VpnCertificateValidator validator = new VpnCertificateValidator(preferences.getString(Constants.PROVIDER_VPN_CERTIFICATE, "")); int resultCode = validator.isValid() ? Activity.RESULT_OK : Activity.RESULT_CANCELED; diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java b/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java index 177f553e..43c16d00 100644 --- a/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java +++ b/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java @@ -36,6 +36,7 @@ import java.util.List; import de.blinkt.openvpn.VpnProfile; import de.blinkt.openvpn.core.Connection; import de.blinkt.openvpn.core.ProfileManager; +import se.leap.bitmaskclient.Constants; import se.leap.bitmaskclient.Provider; /** @@ -123,8 +124,8 @@ public class GatewaysManager { JSONObject result = new JSONObject(); try { result.put(Provider.CA_CERT, preferences.getString(Provider.CA_CERT, "")); - result.put(Constants.PRIVATE_KEY, preferences.getString(Constants.PRIVATE_KEY, "")); - result.put(Constants.VPN_CERTIFICATE, preferences.getString(Constants.VPN_CERTIFICATE, "")); + result.put(Constants.PROVIDER_PRIVATE_KEY, preferences.getString(Constants.PROVIDER_PRIVATE_KEY, "")); + result.put(Constants.PROVIDER_VPN_CERTIFICATE, preferences.getString(Constants.PROVIDER_VPN_CERTIFICATE, "")); } catch (JSONException e) { e.printStackTrace(); } diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java b/app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java index f428099e..54563ec4 100644 --- a/app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java +++ b/app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java @@ -118,14 +118,14 @@ public class VpnConfigGenerator { String key = "" + new_line - + secrets.getString(Constants.PRIVATE_KEY) + + secrets.getString(Constants.PROVIDER_PRIVATE_KEY) + new_line + ""; String openvpn_cert = "" + new_line - + secrets.getString(Constants.VPN_CERTIFICATE) + + secrets.getString(Constants.PROVIDER_VPN_CERTIFICATE) + new_line + ""; diff --git a/app/src/main/java/se/leap/bitmaskclient/updates/ConstantUnification.java b/app/src/main/java/se/leap/bitmaskclient/updates/ConstantUnification.java deleted file mode 100644 index ba78fa00..00000000 --- a/app/src/main/java/se/leap/bitmaskclient/updates/ConstantUnification.java +++ /dev/null @@ -1,18 +0,0 @@ -package se.leap.bitmaskclient.updates; - -import android.content.SharedPreferences; - -public class ConstantUnification { - - private String OLD_ALLOWED_ANON = "allow_anonymous"; - private String OLD_ALLOWED_REGISTERED = "allow_registration"; - private String OLD_VPN_CERTIFICATE = "cert"; - private String OLD_PRIVATE_KEY = "Constants.PRIVATE_KEY"; - private String OLD_KEY = "Constants.KEY"; - private String OLD_PROVIDER_CONFIGURED = "Constants.PROVIDER_CONFIGURED"; - - public static void upgrade(SharedPreferences preferences) { - // TODO MOVE SAVED DATA - } - -} diff --git a/app/src/test/java/se/leap/bitmaskclient/eip/GatewaysManagerTest.java b/app/src/test/java/se/leap/bitmaskclient/eip/GatewaysManagerTest.java index 01cd50dc..ea212480 100644 --- a/app/src/test/java/se/leap/bitmaskclient/eip/GatewaysManagerTest.java +++ b/app/src/test/java/se/leap/bitmaskclient/eip/GatewaysManagerTest.java @@ -43,9 +43,9 @@ public class GatewaysManagerTest { JSONObject secrets = new JSONObject(getJsonStringFor("secrets.json")); - when(sharedPreferences.getString(eq(Constants.PRIVATE_KEY), anyString())).thenReturn(secrets.getString(Constants.PRIVATE_KEY)); + when(sharedPreferences.getString(eq(Constants.PROVIDER_PRIVATE_KEY), anyString())).thenReturn(secrets.getString(Constants.PROVIDER_PRIVATE_KEY)); when(sharedPreferences.getString(eq(Provider.CA_CERT), anyString())).thenReturn(secrets.getString(Provider.CA_CERT)); - when(sharedPreferences.getString(eq(Constants.VPN_CERTIFICATE), anyString())).thenReturn(secrets.getString(Constants.VPN_CERTIFICATE)); + when(sharedPreferences.getString(eq(Constants.PROVIDER_VPN_CERTIFICATE), anyString())).thenReturn(secrets.getString(Constants.PROVIDER_VPN_CERTIFICATE)); when(mockContext.getSharedPreferences(anyString(), anyInt())).thenReturn(sharedPreferences); diff --git a/app/src/test/java/se/leap/bitmaskclient/eip/VpnConfigGeneratorTest.java b/app/src/test/java/se/leap/bitmaskclient/eip/VpnConfigGeneratorTest.java index 7e60edb9..25aba956 100644 --- a/app/src/test/java/se/leap/bitmaskclient/eip/VpnConfigGeneratorTest.java +++ b/app/src/test/java/se/leap/bitmaskclient/eip/VpnConfigGeneratorTest.java @@ -62,7 +62,7 @@ public class VpnConfigGeneratorTest { "\n" + "\n" + "\n" + - "-----BEGIN RSA PRIVATE KEY-----\n" + + "-----BEGIN RSA PRIVATE PROVIDER_KEY-----\n" + "MIIEwAIBADANBgkqhkiG9w0BAQEFAASCBKowggSmAgEAAoIBAQDUTYWeGgsHS+fjijmziniNqw6h\n" + "MBpyK4S/cM6PxV28C33VuOWPTMcIYesctjZANWFCggfFTQSjV5Qaxq9UK4i27tayLbCdlVS6hpbl\n" + "Vf4DuI3Gj1Pv1rtITBShtvCf3T7yBnjW4wVpOpsUAAOViKUSvUU3kPPMFWhiGQw8yHYr82ts6XMo\n" + @@ -85,7 +85,7 @@ public class VpnConfigGeneratorTest { "ispy6Y0CgYEAgl1o2lo+ACyk+oVQPaaPqK3d7WOBFp4eR2nXFor/vsx9igQOlZUgzRDQsR8jo1o9\n" + "efOSBf87igrZGgssys89pWa2dnXnz5PMmzkKr6bw4D9Ez6u6Puc9UZhGw/8wDYg6fSosdB9utspm\n" + "M698ycef7jBNMDgmhpSvfw5GctoNQ4s=\n" + - "-----END RSA PRIVATE KEY-----\n" + + "-----END RSA PRIVATE PROVIDER_KEY-----\n" + "\n" + "\n" + "-----BEGIN CERTIFICATE-----\n" + @@ -160,7 +160,7 @@ public class VpnConfigGeneratorTest { "\n" + "\n" + "\n" + - "-----BEGIN RSA PRIVATE KEY-----\n" + + "-----BEGIN RSA PRIVATE PROVIDER_KEY-----\n" + "MIIEwAIBADANBgkqhkiG9w0BAQEFAASCBKowggSmAgEAAoIBAQDUTYWeGgsHS+fjijmziniNqw6h\n" + "MBpyK4S/cM6PxV28C33VuOWPTMcIYesctjZANWFCggfFTQSjV5Qaxq9UK4i27tayLbCdlVS6hpbl\n" + "Vf4DuI3Gj1Pv1rtITBShtvCf3T7yBnjW4wVpOpsUAAOViKUSvUU3kPPMFWhiGQw8yHYr82ts6XMo\n" + @@ -183,7 +183,7 @@ public class VpnConfigGeneratorTest { "ispy6Y0CgYEAgl1o2lo+ACyk+oVQPaaPqK3d7WOBFp4eR2nXFor/vsx9igQOlZUgzRDQsR8jo1o9\n" + "efOSBf87igrZGgssys89pWa2dnXnz5PMmzkKr6bw4D9Ez6u6Puc9UZhGw/8wDYg6fSosdB9utspm\n" + "M698ycef7jBNMDgmhpSvfw5GctoNQ4s=\n" + - "-----END RSA PRIVATE KEY-----\n" + + "-----END RSA PRIVATE PROVIDER_KEY-----\n" + "\n" + "\n" + "-----BEGIN CERTIFICATE-----\n" + -- cgit v1.2.3