summaryrefslogtreecommitdiff
path: root/app/src/test
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2024-10-11 13:31:55 +0200
committercyberta <cyberta@riseup.net>2024-12-11 00:09:34 +0000
commit323d503750cdd737015816a1fddc8ae0ae19af77 (patch)
tree9cf47ca2a346fa2d1539357771e0ff935f3c78f4 /app/src/test
parent63891a0efb1d8fb49af1a18b505fffc1343274cc (diff)
add helper method to parse a list of x509 Certificates to a pem formatted string
Diffstat (limited to 'app/src/test')
-rw-r--r--app/src/test/java/se/leap/bitmaskclient/base/utils/ConfigHelperTest.java22
1 files changed, 22 insertions, 0 deletions
diff --git a/app/src/test/java/se/leap/bitmaskclient/base/utils/ConfigHelperTest.java b/app/src/test/java/se/leap/bitmaskclient/base/utils/ConfigHelperTest.java
index 6e0ceb56..c6387165 100644
--- a/app/src/test/java/se/leap/bitmaskclient/base/utils/ConfigHelperTest.java
+++ b/app/src/test/java/se/leap/bitmaskclient/base/utils/ConfigHelperTest.java
@@ -1,6 +1,7 @@
package se.leap.bitmaskclient.base.utils;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import com.tngtech.java.junit.dataprovider.DataProvider;
import com.tngtech.java.junit.dataprovider.DataProviderRunner;
@@ -11,6 +12,12 @@ import org.junit.runner.RunWith;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.modules.junit4.PowerMockRunnerDelegate;
+import java.io.IOException;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+
+import se.leap.bitmaskclient.testutils.TestSetupHelper;
+
@RunWith(PowerMockRunner.class)
@PowerMockRunnerDelegate(DataProviderRunner.class)
public class ConfigHelperTest {
@@ -57,4 +64,19 @@ public class ConfigHelperTest {
assertEquals("domain.co.uk", ConfigHelper.getDomainFromMainURL("https://subdomain.domain.co.uk"));
assertEquals("domain.co.uk", ConfigHelper.getDomainFromMainURL("https://domain.co.uk"));
}
+
+ @Test
+ public void testParseX509CertificatesFromString() throws IOException {
+ ArrayList<X509Certificate> certs = ConfigHelper.parseX509CertificatesFromString(TestSetupHelper.getInputAsString(getClass().getClassLoader().getResourceAsStream("updated_cert.pem")));
+ assertTrue(certs != null);
+ }
+
+ @Test
+ public void testParseX509CertificatesToString() throws IOException {
+ String certsString = TestSetupHelper.getInputAsString(getClass().getClassLoader().getResourceAsStream("updated_cert.pem"));
+ ArrayList<X509Certificate> certs = ConfigHelper.parseX509CertificatesFromString(certsString);
+ String parsedCerts = ConfigHelper.parseX509CertificatesToString(certs);
+ assertEquals(certsString, parsedCerts);
+ }
+
} \ No newline at end of file