diff options
Diffstat (limited to 'app/src/androidTest')
-rw-r--r-- | app/src/androidTest/assets/riseup.net.json | 37 | ||||
-rw-r--r-- | app/src/androidTest/assets/riseup.net.pem | 32 | ||||
-rw-r--r-- | app/src/androidTest/java/se/leap/bitmaskclient/test/StartActivityDrawerTest.java | 127 | ||||
-rw-r--r-- | app/src/androidTest/java/se/leap/bitmaskclient/test/TestEIP.java | 81 | ||||
-rw-r--r-- | app/src/androidTest/legacy/BaseTestDashboardFragment.java (renamed from app/src/androidTest/java/se/leap/bitmaskclient/test/BaseTestDashboardFragment.java) | 0 | ||||
-rw-r--r-- | app/src/androidTest/legacy/ConnectionManager.java (renamed from app/src/androidTest/java/se/leap/bitmaskclient/test/ConnectionManager.java) | 0 | ||||
-rw-r--r-- | app/src/androidTest/legacy/FromAssets.java (renamed from app/src/androidTest/java/se/leap/bitmaskclient/test/FromAssets.java) | 0 | ||||
-rw-r--r-- | app/src/androidTest/legacy/Screenshot.java (renamed from app/src/androidTest/java/se/leap/bitmaskclient/test/Screenshot.java) | 0 | ||||
-rw-r--r-- | app/src/androidTest/legacy/TestCalendarProvider.java (renamed from app/src/androidTest/java/se/leap/bitmaskclient/test/TestCalendarProvider.java) | 0 | ||||
-rw-r--r-- | app/src/androidTest/legacy/TestConstants.java (renamed from app/src/androidTest/java/se/leap/bitmaskclient/test/TestConstants.java) | 0 | ||||
-rw-r--r-- | app/src/androidTest/legacy/TestDashboardIntegration.java (renamed from app/src/androidTest/java/se/leap/bitmaskclient/test/TestDashboardIntegration.java) | 0 | ||||
-rw-r--r-- | app/src/androidTest/legacy/TestEipFragment.java (renamed from app/src/androidTest/java/se/leap/bitmaskclient/test/TestEipFragment.java) | 0 | ||||
-rw-r--r-- | app/src/androidTest/legacy/TestGatewaysManager.java (renamed from app/src/androidTest/java/se/leap/bitmaskclient/test/TestGatewaysManager.java) | 0 | ||||
-rw-r--r-- | app/src/androidTest/legacy/TestLeapSRPSession.java (renamed from app/src/androidTest/java/se/leap/bitmaskclient/test/TestLeapSRPSession.java) | 0 | ||||
-rw-r--r-- | app/src/androidTest/legacy/TestProviderListActivity.java (renamed from app/src/androidTest/java/se/leap/bitmaskclient/test/TestProviderListActivity.java) | 0 | ||||
-rw-r--r-- | app/src/androidTest/legacy/TestUserStatusFragment.java (renamed from app/src/androidTest/java/se/leap/bitmaskclient/test/TestUserStatusFragment.java) | 0 | ||||
-rw-r--r-- | app/src/androidTest/legacy/TestVpnCertificateValidator.java (renamed from app/src/androidTest/java/se/leap/bitmaskclient/test/TestVpnCertificateValidator.java) | 0 | ||||
-rw-r--r-- | app/src/androidTest/legacy/UserStatusTestController.java (renamed from app/src/androidTest/java/se/leap/bitmaskclient/test/UserStatusTestController.java) | 0 | ||||
-rw-r--r-- | app/src/androidTest/legacy/VpnTestController.java (renamed from app/src/androidTest/java/se/leap/bitmaskclient/test/VpnTestController.java) | 1 |
19 files changed, 197 insertions, 81 deletions
diff --git a/app/src/androidTest/assets/riseup.net.json b/app/src/androidTest/assets/riseup.net.json new file mode 100644 index 00000000..9a5ec79e --- /dev/null +++ b/app/src/androidTest/assets/riseup.net.json @@ -0,0 +1,37 @@ +{ + "api_uri": "https://api.black.riseup.net:443", + "api_version": "1", + "ca_cert_fingerprint": "SHA256: a5244308a1374709a9afce95e3ae47c1b44bc2398c0a70ccbf8b3a8a97f29494", + "ca_cert_uri": "https://black.riseup.net/ca.crt", + "default_language": "en", + "description": { + "en": "Riseup is a non-profit collective in Seattle that provides online communication tools for people and groups working toward liberatory social change." + }, + "domain": "riseup.net", + "enrollment_policy": "open", + "languages": [ + "en" + ], + "name": { + "en": "Riseup Networks" + }, + "service": { + "allow_anonymous": false, + "allow_free": true, + "allow_limited_bandwidth": false, + "allow_paid": false, + "allow_registration": true, + "allow_unlimited_bandwidth": true, + "bandwidth_limit": 102400, + "default_service_level": 1, + "levels": { + "1": { + "description": "Please donate.", + "name": "free" + } + } + }, + "services": [ + "openvpn" + ] +}
\ No newline at end of file diff --git a/app/src/androidTest/assets/riseup.net.pem b/app/src/androidTest/assets/riseup.net.pem new file mode 100644 index 00000000..c890aff4 --- /dev/null +++ b/app/src/androidTest/assets/riseup.net.pem @@ -0,0 +1,32 @@ +-----BEGIN CERTIFICATE----- +MIIFjTCCA3WgAwIBAgIBATANBgkqhkiG9w0BAQ0FADBZMRgwFgYDVQQKDA9SaXNl +dXAgTmV0d29ya3MxGzAZBgNVBAsMEmh0dHBzOi8vcmlzZXVwLm5ldDEgMB4GA1UE +AwwXUmlzZXVwIE5ldHdvcmtzIFJvb3QgQ0EwHhcNMTQwNDI4MDAwMDAwWhcNMjQw +NDI4MDAwMDAwWjBZMRgwFgYDVQQKDA9SaXNldXAgTmV0d29ya3MxGzAZBgNVBAsM +Emh0dHBzOi8vcmlzZXVwLm5ldDEgMB4GA1UEAwwXUmlzZXVwIE5ldHdvcmtzIFJv +b3QgQ0EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC76J4ciMJ8Sg0m +TP7DF2DT9zNe0Csk4myoMFC57rfJeqsAlJCv1XMzBmXrw8wq/9z7XHv6n/0sWU7a +7cF2hLR33ktjwODlx7vorU39/lXLndo492ZBhXQtG1INMShyv+nlmzO6GT7ESfNE +LliFitEzwIegpMqxCIHXFuobGSCWF4N0qLHkq/SYUMoOJ96O3hmPSl1kFDRMtWXY +iw1SEKjUvpyDJpVs3NGxeLCaA7bAWhDY5s5Yb2fA1o8ICAqhowurowJpW7n5ZuLK +5VNTlNy6nZpkjt1QycYvNycffyPOFm/Q/RKDlvnorJIrihPkyniV3YY5cGgP+Qkx +HUOT0uLA6LHtzfiyaOqkXwc4b0ZcQD5Vbf6Prd20Ppt6ei0zazkUPwxld3hgyw58 +m/4UIjG3PInWTNf293GngK2Bnz8Qx9e/6TueMSAn/3JBLem56E0WtmbLVjvko+LF +PM5xA+m0BmuSJtrD1MUCXMhqYTtiOvgLBlUm5zkNxALzG+cXB28k6XikXt6MRG7q +hzIPG38zwkooM55yy5i1YfcIi5NjMH6A+t4IJxxwb67MSb6UFOwg5kFokdONZcwj +shczHdG9gLKSBIvrKa03Nd3W2dF9hMbRu//STcQxOailDBQCnXXfAATj9pYzdY4k +ha8VCAREGAKTDAex9oXf1yRuktES4QIDAQABo2AwXjAdBgNVHQ4EFgQUC4tdmLVu +f9hwfK4AGliaet5KkcgwDgYDVR0PAQH/BAQDAgIEMAwGA1UdEwQFMAMBAf8wHwYD +VR0jBBgwFoAUC4tdmLVuf9hwfK4AGliaet5KkcgwDQYJKoZIhvcNAQENBQADggIB +AGzL+GRnYu99zFoy0bXJKOGCF5XUXP/3gIXPRDqQf5g7Cu/jYMID9dB3No4Zmf7v +qHjiSXiS8jx1j/6/Luk6PpFbT7QYm4QLs1f4BlfZOti2KE8r7KRDPIecUsUXW6P/ +3GJAVYH/+7OjA39za9AieM7+H5BELGccGrM5wfl7JeEz8in+V2ZWDzHQO4hMkiTQ +4ZckuaL201F68YpiItBNnJ9N5nHr1MRiGyApHmLXY/wvlrOpclh95qn+lG6/2jk7 +3AmihLOKYMlPwPakJg4PYczm3icFLgTpjV5sq2md9bRyAg3oPGfAuWHmKj2Ikqch +Td5CHKGxEEWbGUWEMP0s1A/JHWiCbDigc4Cfxhy56CWG4q0tYtnc2GMw8OAUO6Wf +Xu5pYKNkzKSEtT/MrNJt44tTZWbKV/Pi/N2Fx36my7TgTUj7g3xcE9eF4JV2H/sg +tsK3pwE0FEqGnT4qMFbixQmc8bGyuakr23wjMvfO7eZUxBuWYR2SkcP26sozF9PF +tGhbZHQVGZUTVPyvwahMUEhbPGVerOW0IYpxkm0x/eaWdTc4vPpf/rIlgbAjarnJ +UN9SaWRlWKSdP4haujnzCoJbM7dU9bjvlGZNyXEekgeT0W2qFeGGp+yyUWw8tNsp +0BuC1b7uW/bBn/xKm319wXVDvBgZgcktMolak39V7DVO +-----END CERTIFICATE-----
\ No newline at end of file diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/StartActivityDrawerTest.java b/app/src/androidTest/java/se/leap/bitmaskclient/test/StartActivityDrawerTest.java new file mode 100644 index 00000000..c7c6a86f --- /dev/null +++ b/app/src/androidTest/java/se/leap/bitmaskclient/test/StartActivityDrawerTest.java @@ -0,0 +1,127 @@ +package se.leap.bitmaskclient.test; + +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.support.test.InstrumentationRegistry; +import android.support.test.espresso.contrib.DrawerActions; +import android.support.test.rule.ActivityTestRule; +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.io.IOException; + +import se.leap.bitmaskclient.MainActivity; +import se.leap.bitmaskclient.Provider; +import se.leap.bitmaskclient.testutils.TestSetupHelper; + +import static android.support.test.InstrumentationRegistry.getInstrumentation; +import static android.support.test.espresso.Espresso.onData; +import static android.support.test.espresso.Espresso.onView; +import static android.support.test.espresso.action.ViewActions.click; +import static android.support.test.espresso.assertion.ViewAssertions.matches; +import static android.support.test.espresso.contrib.DrawerMatchers.isClosed; +import static android.support.test.espresso.contrib.DrawerMatchers.isOpen; +import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; +import static android.support.test.espresso.matcher.ViewMatchers.withId; +import static org.hamcrest.Matchers.anything; +import static se.leap.bitmaskclient.Constants.SHARED_PREFERENCES; +import static se.leap.bitmaskclient.MainActivity.ACTION_SHOW_VPN_FRAGMENT; +import static se.leap.bitmaskclient.R.id.aboutLayout; +import static se.leap.bitmaskclient.R.id.accountList; +import static se.leap.bitmaskclient.R.id.configuration_wizard_layout; +import static se.leap.bitmaskclient.R.id.drawer_layout; +import static se.leap.bitmaskclient.R.id.eipServiceFragment; +import static se.leap.bitmaskclient.R.id.log_layout; +import static se.leap.bitmaskclient.R.id.settingsList; + +/** + * Created by cyberta on 19.01.18. + */ + +@RunWith(AndroidJUnit4.class) +public class StartActivityDrawerTest { + + Intent intent; + SharedPreferences preferences; + SharedPreferences.Editor preferencesEditor; + + @Rule + public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>( + MainActivity.class, + true, + false); // Activity is not launched immediately + + @Before + public void setUp() throws IOException { + intent = new Intent(ACTION_SHOW_VPN_FRAGMENT); + Context context = getInstrumentation().getTargetContext(); + + preferences = context.getSharedPreferences(SHARED_PREFERENCES, Context.MODE_PRIVATE); + preferencesEditor = preferences.edit(); + preferencesEditor.putString(Provider.KEY, TestSetupHelper.getInputAsString(InstrumentationRegistry.getContext().getAssets().open("riseup.net.json"))) + .putString(Provider.CA_CERT, TestSetupHelper.getInputAsString(InstrumentationRegistry.getContext().getAssets().open("riseup.net.pem"))) + .commit(); + + } + + + @Test + public void testDisplayDrawer_isOpenUntilUserManuallyOpendDrawerOnce() { + preferencesEditor.putBoolean("navigation_drawer_learned", false).commit(); + mActivityRule.launchActivity(intent); + onView(withId(drawer_layout)).check(matches(isOpen())); + onView(withId(drawer_layout)).perform(DrawerActions.close()); + mActivityRule.finishActivity(); + + mActivityRule.launchActivity(intent); + onView(withId(drawer_layout)).check(matches(isOpen())); + onView(withId(drawer_layout)).perform(DrawerActions.close()); + onView(withId(drawer_layout)).perform(DrawerActions.open()); + mActivityRule.finishActivity(); + + mActivityRule.launchActivity(intent); + onView(withId(drawer_layout)).check(matches(isClosed())); + } + + @Test + public void testClickProviderName_closeDrawerAndShowEipFragment() { + preferencesEditor.putBoolean("navigation_drawer_learned", false).commit(); + mActivityRule.launchActivity(intent); + + onData(anything()).inAdapterView(withId(accountList)).atPosition(0).perform(click()); + onView(withId(drawer_layout)).check(matches(isClosed())); + onView(withId(eipServiceFragment)).check(matches(isDisplayed())); + } + + @Test + public void testClickSwitchProvider_closeDrawerAndShowProviderListView() { + preferencesEditor.putBoolean("navigation_drawer_learned", false).commit(); + mActivityRule.launchActivity(intent); + + onData(anything()).inAdapterView(withId(settingsList)).atPosition(0).perform(click()); + onView(withId(configuration_wizard_layout)).check(matches(isDisplayed())); + } + + @Test + public void testClickLog_closeDrawerAndShowLogFragment() { + preferencesEditor.putBoolean("navigation_drawer_learned", false).commit(); + mActivityRule.launchActivity(intent); + + onData(anything()).inAdapterView(withId(settingsList)).atPosition(1).perform(click()); + onView(withId(log_layout)).check(matches(isDisplayed())); + } + + @Test + public void testClickAbout_closeDrawerAndShowAboutFragment() { + preferencesEditor.putBoolean("navigation_drawer_learned", false).commit(); + mActivityRule.launchActivity(intent); + + onData(anything()).inAdapterView(withId(settingsList)).atPosition(2).perform(click()); + onView(withId(aboutLayout)).check(matches(isDisplayed())); + } +} diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/TestEIP.java b/app/src/androidTest/java/se/leap/bitmaskclient/test/TestEIP.java deleted file mode 100644 index 4c215360..00000000 --- a/app/src/androidTest/java/se/leap/bitmaskclient/test/TestEIP.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * Copyright (c) 2013, 2014, 2015 LEAP Encryption Access Project and contributers - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ -package se.leap.bitmaskclient.test; - - -import android.content.Context; -import android.content.Intent; -import android.content.SharedPreferences; -import android.test.ServiceTestCase; -import android.test.suitebuilder.annotation.MediumTest; - -import se.leap.bitmaskclient.eip.EIP; - -import static se.leap.bitmaskclient.Constants.EIP_ACTION_CHECK_CERT_VALIDITY; -import static se.leap.bitmaskclient.Constants.PROVIDER_VPN_CERTIFICATE; -import static se.leap.bitmaskclient.Constants.SHARED_PREFERENCES; - -/** - * @author parmegv - */ -public class TestEIP extends ServiceTestCase<EIP> { - - private Context context; - private Intent intent; - private SharedPreferences preferences; - - public TestEIP(Class<EIP> activityClass) { - super(activityClass); - context = getSystemContext(); - intent = new Intent(context, EIP.class); - preferences = context.getSharedPreferences(SHARED_PREFERENCES, Context.MODE_PRIVATE); - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - } - - @MediumTest - private void testCheckCertValidity() { - testEmptyCertificate(); - testExpiredCertificate(); - // Wait for the service to start - // Check result is OK. - } - - private void testEmptyCertificate() { - preferences.edit().putString(PROVIDER_VPN_CERTIFICATE, "").apply(); - startService(EIP_ACTION_CHECK_CERT_VALIDITY); - } - - private void testExpiredCertificate() { - String expired_certificate = "expired certificate"; - preferences.edit().putString(PROVIDER_VPN_CERTIFICATE, expired_certificate).apply(); - startService(EIP_ACTION_CHECK_CERT_VALIDITY); - } - - private void startService(String action) { - intent.setAction(action); - startService(intent); - } -} diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/BaseTestDashboardFragment.java b/app/src/androidTest/legacy/BaseTestDashboardFragment.java index e187d424..e187d424 100644 --- a/app/src/androidTest/java/se/leap/bitmaskclient/test/BaseTestDashboardFragment.java +++ b/app/src/androidTest/legacy/BaseTestDashboardFragment.java diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/ConnectionManager.java b/app/src/androidTest/legacy/ConnectionManager.java index 6fb7d8a9..6fb7d8a9 100644 --- a/app/src/androidTest/java/se/leap/bitmaskclient/test/ConnectionManager.java +++ b/app/src/androidTest/legacy/ConnectionManager.java diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/FromAssets.java b/app/src/androidTest/legacy/FromAssets.java index 6a4c1ee2..6a4c1ee2 100644 --- a/app/src/androidTest/java/se/leap/bitmaskclient/test/FromAssets.java +++ b/app/src/androidTest/legacy/FromAssets.java diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/Screenshot.java b/app/src/androidTest/legacy/Screenshot.java index ade28b73..ade28b73 100644 --- a/app/src/androidTest/java/se/leap/bitmaskclient/test/Screenshot.java +++ b/app/src/androidTest/legacy/Screenshot.java diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/TestCalendarProvider.java b/app/src/androidTest/legacy/TestCalendarProvider.java index 82ea8b59..82ea8b59 100644 --- a/app/src/androidTest/java/se/leap/bitmaskclient/test/TestCalendarProvider.java +++ b/app/src/androidTest/legacy/TestCalendarProvider.java diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/TestConstants.java b/app/src/androidTest/legacy/TestConstants.java index 6b4cdfb1..6b4cdfb1 100644 --- a/app/src/androidTest/java/se/leap/bitmaskclient/test/TestConstants.java +++ b/app/src/androidTest/legacy/TestConstants.java diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/TestDashboardIntegration.java b/app/src/androidTest/legacy/TestDashboardIntegration.java index ad2b4a00..ad2b4a00 100644 --- a/app/src/androidTest/java/se/leap/bitmaskclient/test/TestDashboardIntegration.java +++ b/app/src/androidTest/legacy/TestDashboardIntegration.java diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/TestEipFragment.java b/app/src/androidTest/legacy/TestEipFragment.java index 4227f19a..4227f19a 100644 --- a/app/src/androidTest/java/se/leap/bitmaskclient/test/TestEipFragment.java +++ b/app/src/androidTest/legacy/TestEipFragment.java diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/TestGatewaysManager.java b/app/src/androidTest/legacy/TestGatewaysManager.java index 02c521be..02c521be 100644 --- a/app/src/androidTest/java/se/leap/bitmaskclient/test/TestGatewaysManager.java +++ b/app/src/androidTest/legacy/TestGatewaysManager.java diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/TestLeapSRPSession.java b/app/src/androidTest/legacy/TestLeapSRPSession.java index 8d0df59b..8d0df59b 100644 --- a/app/src/androidTest/java/se/leap/bitmaskclient/test/TestLeapSRPSession.java +++ b/app/src/androidTest/legacy/TestLeapSRPSession.java diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/TestProviderListActivity.java b/app/src/androidTest/legacy/TestProviderListActivity.java index 4ab705e7..4ab705e7 100644 --- a/app/src/androidTest/java/se/leap/bitmaskclient/test/TestProviderListActivity.java +++ b/app/src/androidTest/legacy/TestProviderListActivity.java diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/TestUserStatusFragment.java b/app/src/androidTest/legacy/TestUserStatusFragment.java index d77b9796..d77b9796 100644 --- a/app/src/androidTest/java/se/leap/bitmaskclient/test/TestUserStatusFragment.java +++ b/app/src/androidTest/legacy/TestUserStatusFragment.java diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/TestVpnCertificateValidator.java b/app/src/androidTest/legacy/TestVpnCertificateValidator.java index 70596c10..70596c10 100644 --- a/app/src/androidTest/java/se/leap/bitmaskclient/test/TestVpnCertificateValidator.java +++ b/app/src/androidTest/legacy/TestVpnCertificateValidator.java diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/UserStatusTestController.java b/app/src/androidTest/legacy/UserStatusTestController.java index 3b0daf9a..3b0daf9a 100644 --- a/app/src/androidTest/java/se/leap/bitmaskclient/test/UserStatusTestController.java +++ b/app/src/androidTest/legacy/UserStatusTestController.java diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/VpnTestController.java b/app/src/androidTest/legacy/VpnTestController.java index f6760161..4c6a6370 100644 --- a/app/src/androidTest/java/se/leap/bitmaskclient/test/VpnTestController.java +++ b/app/src/androidTest/legacy/VpnTestController.java @@ -6,6 +6,7 @@ import android.widget.Button; import com.robotium.solo.Condition; import com.robotium.solo.Solo; +import de.blinkt.openvpn.activities.DisconnectVPN; import mbanje.kurt.fabbutton.ProgressRingView; import se.leap.bitmaskclient.Dashboard; import se.leap.bitmaskclient.R; |