From 3cc60ff642134e7442500e309c6b1248c819c0e8 Mon Sep 17 00:00:00 2001 From: Fup Duck Date: Tue, 13 Feb 2018 11:31:18 +0100 Subject: 8827 - add ProviderTest & DefaultedURLTest --- .../testutils/TestSetupHelper.java | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'app/src/sharedTest/java/se.leap.bitmaskclient') 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; + } + } -- cgit v1.2.3