summaryrefslogtreecommitdiff
path: root/app/src/sharedTest/java/se.leap.bitmaskclient
diff options
context:
space:
mode:
authorFup Duck <fupduck@sacknagel.com>2018-02-13 11:31:18 +0100
committerFup Duck <fupduck@sacknagel.com>2018-02-13 11:31:18 +0100
commit3cc60ff642134e7442500e309c6b1248c819c0e8 (patch)
tree894e21a8863c1b53976c2d7948a5dc60381d937c /app/src/sharedTest/java/se.leap.bitmaskclient
parent710fdd182dc1a470c949f50701d3aace4d67134c (diff)
8827 - add ProviderTest & DefaultedURLTest
Diffstat (limited to 'app/src/sharedTest/java/se.leap.bitmaskclient')
-rw-r--r--app/src/sharedTest/java/se.leap.bitmaskclient/testutils/TestSetupHelper.java33
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;
+ }
+
}