diff options
author | Parménides GV <parmegv@sdf.org> | 2013-11-22 16:00:07 +0100 |
---|---|---|
committer | Parménides GV <parmegv@sdf.org> | 2013-11-22 16:00:07 +0100 |
commit | 52843b4ff8cd70abf93a0aeb230e83b4af50d92a (patch) | |
tree | d2b291405d8552390ef11922f9f27704c6eb7ad3 /tests/src | |
parent | a713e970ff19d3cc93db359cb1095a2a4426aa05 (diff) |
I'm not showing parmegv account pass.
I'm using a new testing account, parmegvtest1
Diffstat (limited to 'tests/src')
3 files changed, 2 insertions, 222 deletions
diff --git a/tests/src/se/leap/bitmaskclient/test/testConfigurationWizard.java b/tests/src/se/leap/bitmaskclient/test/testConfigurationWizard.java index 5abb6d90..501530a5 100644 --- a/tests/src/se/leap/bitmaskclient/test/testConfigurationWizard.java +++ b/tests/src/se/leap/bitmaskclient/test/testConfigurationWizard.java @@ -3,7 +3,6 @@ package se.leap.bitmaskclient.test; import java.io.IOException; import se.leap.bitmaskclient.AboutFragment; -import se.leap.bitmaskclient.ConfigHelper; import se.leap.bitmaskclient.ConfigurationWizard; import se.leap.bitmaskclient.ProviderDetailFragment; import se.leap.bitmaskclient.R; @@ -46,7 +45,7 @@ public class testConfigurationWizard extends ActivityInstrumentationTestCase2<Co } public void testAddNewProvider() { - solo.clickOnText(solo.getString(R.string.new_provider_button)); + solo.clickOnActionBarItem(R.id.new_provider); solo.enterText(0, "dev.bitmask.net"); solo.clickOnCheckBox(0); solo.clickOnText(solo.getString(R.string.save)); diff --git a/tests/src/se/leap/bitmaskclient/test/testDashboard.java b/tests/src/se/leap/bitmaskclient/test/testDashboard.java index 5ba4868a..31039797 100644 --- a/tests/src/se/leap/bitmaskclient/test/testDashboard.java +++ b/tests/src/se/leap/bitmaskclient/test/testDashboard.java @@ -66,7 +66,7 @@ public class testDashboard extends ActivityInstrumentationTestCase2<Dashboard> { public void testLogInAndOut() { long miliseconds_to_log_in = 40 * 1000; solo.clickOnActionBarItem(R.id.login_button); - solo.enterText(0, "parmegv"); + solo.enterText(0, "parmegvtest1"); solo.enterText(1, " S_Zw3'-"); solo.clickOnText("Log In"); solo.waitForDialogToClose(); diff --git a/tests/src/se/leap/bitmaskclient/test/testProviderAPI.java b/tests/src/se/leap/bitmaskclient/test/testProviderAPI.java deleted file mode 100644 index 0df59f9b..00000000 --- a/tests/src/se/leap/bitmaskclient/test/testProviderAPI.java +++ /dev/null @@ -1,219 +0,0 @@ -/** - * - */ -package se.leap.bitmaskclient.test; - -import java.io.IOException; -import java.io.InputStreamReader; -import java.math.BigInteger; -import java.util.Map; -import java.util.Scanner; -import java.util.concurrent.CountDownLatch; - -import org.json.JSONException; -import org.json.JSONObject; - -import se.leap.bitmaskclient.ConfigHelper; -import se.leap.bitmaskclient.ConfigurationWizard; -import se.leap.bitmaskclient.Dashboard; -import se.leap.bitmaskclient.LeapSRPSession; -import se.leap.bitmaskclient.LogInDialog; -import se.leap.bitmaskclient.Provider; -import se.leap.bitmaskclient.ProviderAPI; -import android.app.Application; -import android.content.Intent; -import android.content.res.AssetManager; -import android.os.Bundle; -import android.os.ResultReceiver; -import android.test.ServiceTestCase; - -/** - * @author parmegv - * - */ -public class testProviderAPI extends ServiceTestCase<ProviderAPI> { - - /** - * @param providerAPI_class - */ - public testProviderAPI() { - super(ProviderAPI.class); - } - - /* (non-Javadoc) - * @see android.test.ServiceTestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - - ConfigHelper.setSharedPreferences(getContext().getSharedPreferences(Dashboard.SHARED_PREFERENCES, Application.MODE_PRIVATE)); - } - - /* (non-Javadoc) - * @see android.test.ServiceTestCase#tearDown() - */ - protected void tearDown() throws Exception { - super.tearDown(); - } - - public void testGetHexString() throws InterruptedException { - String expected_hex_representation = "44eba0239ddfcc5a488d208df32a89eb00e93e6576b22ba2e4410085a413cf64e9c2f08ebc36a788a0761391150ad4a0507ca43f9ca659e2734f0457a85358c0bb39fa87183c9d3f9f8a3b148dab6303a4e796294f3e956472ba0e2ea5697382acd93c8b8f1b3a7a9d8517eebffd6301bfc8de7f7b701f0878a71faae1e25ad4"; - byte[] byte_representation = new BigInteger(expected_hex_representation, 16).toByteArray(); - - String hex_representation = new BigInteger(byte_representation).toString(16); - assertEquals(expected_hex_representation, hex_representation); - } - - public void testAuthenticateBySRP() throws InterruptedException, IOException, JSONException { - int number_of_trials_per_login = 5; - int trial = 0; - int total_different_logins = 5; - String username = "", password = "", api_url = ""; - AssetManager assets_manager = this.getContext().getAssets(); - String tests_string = new Scanner(new InputStreamReader(assets_manager.open("testAuthenticateBySRP_data"))).useDelimiter("\\A").next(); - JSONObject all_tests = new JSONObject(tests_string); - JSONObject current_test; - for(int current_login = 3; current_login < current_login + total_different_logins ; current_login++) - { - current_test = all_tests.getJSONObject(String.valueOf(current_login+1)); - username = current_test.getString("username"); - password = current_test.getString("password"); - api_url = current_test.getString("api-url"); - for(trial = 0; trial < number_of_trials_per_login; trial++) - { - System.out.println("Login " + current_login + ". Trial " + trial); - - CountDownLatch done_signal = new CountDownLatch(1); - JSONObject result = new JSONObject(); - new Thread(new RunAuthenticateBySRP(done_signal, result, username, password, api_url)).run(); - done_signal.await(); - assertEquals(ProviderAPI.SRP_AUTHENTICATION_SUCCESSFUL, result.getInt(ProviderAPI.RESULT_KEY)); - - result = new JSONObject(); - done_signal = new CountDownLatch(1); - new Thread(new RunLogOut(done_signal, result, api_url)).run(); - done_signal.await(); - assertEquals(ProviderAPI.LOGOUT_SUCCESSFUL, result.getInt(ProviderAPI.RESULT_KEY)); - } - } - } - - public class RunGetHexString implements Runnable { - - private CountDownLatch done_signal; - private Map<String, Integer> result; - - public RunGetHexString(CountDownLatch cdl, Map<String, Integer> result, byte[] byte_representation) { - this.done_signal = cdl; - this.result = result; - } - - @Override - public void run() { - Intent provider_API_command = new Intent(); - - Bundle parameters = new Bundle(); - parameters.putString("cert", "https://bitmask.net/ca.crt"); - parameters.putString("eip", "https://api.bitmask.net/1/config/eip-service.json"); - - provider_API_command.putExtra(ProviderAPI.DOWNLOAD_JSON_FILES_BUNDLE_EXTRA, parameters); - provider_API_command.putExtra(ProviderAPI.PARAMETERS, parameters); - ResultReceiver result_receiver = new ResultReceiver(null) { - @Override - protected void onReceiveResult(int result_code, Bundle resultData) { - result.put("result", result_code); - done_signal.countDown(); - } - }; - - provider_API_command.putExtra("receiver", result_receiver); - startService(provider_API_command); - } - } - - public class RunAuthenticateBySRP implements Runnable { - - private CountDownLatch done_signal; - private JSONObject result; - private String username; - private String password; - private String api_url; - - public RunAuthenticateBySRP(CountDownLatch cdl, JSONObject result, String username, String password, String api_url) { - this.done_signal = cdl; - this.result = result; - this.username = username; - this.password = password; - this.api_url = api_url; - } - - @Override - public void run() { - Intent provider_API_command = new Intent(); - - Bundle parameters = new Bundle(); - parameters.putString(LogInDialog.USERNAME, username); - parameters.putString(LogInDialog.PASSWORD, password); - parameters.putString(Provider.API_URL, api_url); - - provider_API_command.setAction(ProviderAPI.SRP_AUTH); - provider_API_command.putExtra(ProviderAPI.PARAMETERS, parameters); - ResultReceiver result_receiver = new ResultReceiver(null) { - @Override - protected void onReceiveResult(int result_code, Bundle resultData) { - try { - result.put("result", result_code); - result.put("session_id_cookie_key", resultData.getString("session_id_cookie_key")); - result.put("session_id", resultData.getString("session_id")); - } catch (JSONException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - done_signal.countDown(); - } - }; - - provider_API_command.putExtra(ProviderAPI.RECEIVER_KEY, result_receiver); - startService(provider_API_command); - } - } - - public class RunLogOut implements Runnable { - - private CountDownLatch done_signal; - private JSONObject result; - private String api_url; - - public RunLogOut(CountDownLatch cdl, JSONObject result, String api_url) { - this.done_signal = cdl; - this.result = result; - this.api_url = api_url; - } - - @Override - public void run() { - Intent provider_API_command = new Intent(); - - Bundle parameters = new Bundle(); - parameters.putString(Provider.API_URL, api_url); - - provider_API_command.setAction(ProviderAPI.LOG_OUT); - provider_API_command.putExtra(ProviderAPI.PARAMETERS, parameters); - ResultReceiver result_receiver = new ResultReceiver(null) { - @Override - protected void onReceiveResult(int result_code, Bundle resultData) { - try { - result.put("result", result_code); - } catch (JSONException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - done_signal.countDown(); - } - }; - provider_API_command.putExtra(ProviderAPI.RECEIVER_KEY, result_receiver); - - startService(provider_API_command); - } - } -} |