diff options
author | cyberta <cyberta@riseup.net> | 2018-02-13 04:07:25 -0800 |
---|---|---|
committer | cyberta <cyberta@riseup.net> | 2018-02-13 04:07:25 -0800 |
commit | 9b6c368a25510c462ea357121c97edb6d0310021 (patch) | |
tree | d8de88328853ad9955e7afad77ff115f55b05186 /app/src/sharedTest/java | |
parent | ba1d730c12a5168c3a261604e0efd3b77ba3ec5b (diff) | |
parent | b5483d9a799d89c99dc2389379c7cceb1e148110 (diff) |
Merge branch '8827_handle_switch_provider' into '0.9.8'
8827 handle switch provider
See merge request leap/bitmask_android!38
Diffstat (limited to 'app/src/sharedTest/java')
-rw-r--r-- | app/src/sharedTest/java/se.leap.bitmaskclient/testutils/TestSetupHelper.java | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/app/src/sharedTest/java/se.leap.bitmaskclient/testutils/TestSetupHelper.java b/app/src/sharedTest/java/se.leap.bitmaskclient/testutils/TestSetupHelper.java index 725924e6..a9584238 100644 --- a/app/src/sharedTest/java/se.leap.bitmaskclient/testutils/TestSetupHelper.java +++ b/app/src/sharedTest/java/se.leap.bitmaskclient/testutils/TestSetupHelper.java @@ -17,10 +17,17 @@ package se.leap.bitmaskclient.testutils; +import junit.framework.Test; + +import org.json.JSONException; + import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.net.URL; + +import se.leap.bitmaskclient.Provider; /** * Created by cyberta on 08.10.17. @@ -40,4 +47,30 @@ public class TestSetupHelper { return sb.toString(); } + + public static Provider getConfiguredProvider() throws IOException, JSONException { + return getProvider(null, null, null); + } + + public static Provider getProvider(String domain, String caCertFile, String jsonFile) { + if (domain == null) + domain = "https://riseup.net"; + if (caCertFile == null) + caCertFile = "riseup.net.pem"; + if (jsonFile == null) + jsonFile = "riseup.net.json"; + + try { + return new Provider( + new URL(domain), + getInputAsString(TestSetupHelper.class.getClassLoader().getResourceAsStream(caCertFile)), + getInputAsString(TestSetupHelper.class.getClassLoader().getResourceAsStream(jsonFile)) + + ); + } catch (IOException e) { + e.printStackTrace(); + } + return null; + } + } |