diff options
author | cyBerta <cyberta@riseup.net> | 2024-11-07 17:22:19 +0100 |
---|---|---|
committer | cyberta <cyberta@riseup.net> | 2024-12-11 00:09:34 +0000 |
commit | ab4c3397c501e059849d16f05fa211d5ebd3c4db (patch) | |
tree | 2bcce219b2c0df1d17affb1bba2068f3416d937b /app/src/test/java/se/leap | |
parent | 44b33d83bdb1f5670eb0eb2adb13695aa8388667 (diff) |
add CredentialsParser which is responsible to parse the reponse from /api/5/openvpn/cert endpoint
Diffstat (limited to 'app/src/test/java/se/leap')
-rw-r--r-- | app/src/test/java/se/leap/bitmaskclient/base/utils/CredentialsParserTest.java | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/app/src/test/java/se/leap/bitmaskclient/base/utils/CredentialsParserTest.java b/app/src/test/java/se/leap/bitmaskclient/base/utils/CredentialsParserTest.java new file mode 100644 index 00000000..c8bfd21f --- /dev/null +++ b/app/src/test/java/se/leap/bitmaskclient/base/utils/CredentialsParserTest.java @@ -0,0 +1,48 @@ +package se.leap.bitmaskclient.base.utils; + +import static org.junit.Assert.assertEquals; + +import android.os.Build; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.robolectric.RobolectricTestRunner; +import org.robolectric.annotation.Config; +import org.xmlpull.v1.XmlPullParserException; + +import java.io.IOException; + +import se.leap.bitmaskclient.base.models.Provider; +import se.leap.bitmaskclient.testutils.TestSetupHelper; + +@RunWith(RobolectricTestRunner.class) +@Config(sdk = {Build.VERSION_CODES.LOLLIPOP, Build.VERSION_CODES.P}) +public class CredentialsParserTest { + + @Test + public void testCertificateResponse() throws IOException, XmlPullParserException { + String ed25519_creds = TestSetupHelper.getInputAsString(getClass().getClassLoader().getResourceAsStream("ed25519_credentials.pem")); + Provider provider = new Provider("https://demo.bitmask.net"); + CredentialsParser.parseXml(ed25519_creds, provider); + assertEquals("MC4CAQAwBQYDK2VwBCIEIF+HZvpSdhnTbYeT635bT2+IU4FbW3EWlHuUnXvhb10m", provider.getPrivateKeyString()); + assertEquals("M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zXCe81gbQCeaTFRws7D4Es\n" + + "MAoGCCqGSM49BAMCA0kAMEYCIQCw88nXg/vs/KgGqH1uPs9oZkOxucVn/ZEznYzg\n" + + "szLhtAIhAPY32oHwmj3yHO9H2Jp7x0CoHuu1fKd9fQTBvEEbi7o9", provider.getCaCert()); + } + +} |