mirror of
https://github.com/f-droid/fdroidclient.git
synced 2026-06-21 22:30:43 -04:00
added parsing for repository signing key property to provisioning files
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package org.fdroid.fdroid;
|
||||
|
||||
import org.fdroid.fdroid.shadows.ShadowLog;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
@@ -19,6 +21,11 @@ import java.util.List;
|
||||
@SuppressWarnings("LineLength")
|
||||
public class ProvisionerTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
ShadowLog.stream = System.out;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void provisionLookup() throws IOException {
|
||||
// wired hack for getting resource dir path ...
|
||||
@@ -59,7 +66,7 @@ public class ProvisionerTest {
|
||||
List<Provisioner.ProvisionPlaintext> result = p.extractProvisionsPlaintext(files);
|
||||
|
||||
Assert.assertEquals(result.size(), 1);
|
||||
Assert.assertEquals("{\"username\": \"user2\", \"name\": \"test repo a\", \"password\": \"other secret\", \"url\": \"https://example.com/repo\"}", result.get(0).getRepositoryProvision());
|
||||
Assert.assertEquals("{\"username\": \"user2\", \"password\": \"other secret\", \"name\": \"Example Repo\", \"url\": \"https://example.com/fdroid/repo\", \"sigfp\": \"1111222233334444555566667777888899990000aaaabbbbccccddddeeeeffff\"}", result.get(0).getRepositoryProvision());
|
||||
Assert.assertTrue(String.valueOf(result.get(0).getProvisionPath()).endsWith("demo_credentials_user2.fdrp"));
|
||||
}
|
||||
|
||||
@@ -70,7 +77,7 @@ public class ProvisionerTest {
|
||||
List<Provisioner.ProvisionPlaintext> result = p.extractProvisionsPlaintext(files);
|
||||
|
||||
Assert.assertEquals(result.size(), 1);
|
||||
Assert.assertEquals("{\"username\": \"user1\", \"password\": \"secret1\", \"name\": \"test repo a\", \"url\": \"https://example.com/repo\"}", result.get(0).getRepositoryProvision());
|
||||
Assert.assertEquals("{\"sigfp\": \"1111222233334444555566667777888899990000aaaabbbbccccddddeeeeffff\", \"name\": \"Example Repo\", \"password\": \"secret1\", \"url\": \"https://example.com/fdroid/repo\", \"username\": \"user1\"}", result.get(0).getRepositoryProvision());
|
||||
Assert.assertTrue(String.valueOf(result.get(0).getProvisionPath()).endsWith("demo_credentials_user1.fdrp"));
|
||||
}
|
||||
|
||||
@@ -79,22 +86,24 @@ public class ProvisionerTest {
|
||||
|
||||
List<Provisioner.ProvisionPlaintext> plaintexts = Arrays.asList(new Provisioner.ProvisionPlaintext(), new Provisioner.ProvisionPlaintext());
|
||||
plaintexts.get(0).setProvisionPath("/some/dir/abc.fdrp");
|
||||
plaintexts.get(0).setRepositoryProvision("{\"username\": \"user1\", \"password\": \"secret1\", \"name\": \"test repo a\", \"url\": \"https://example.com/repo\"}");
|
||||
plaintexts.get(0).setRepositoryProvision("{\"username\": \"user1\", \"password\": \"secret1\", \"name\": \"test repo a\", \"url\": \"https://example.com/fdroid/repo\", \"sigfp\": \"1111222233334444555566667777888899990000aaaabbbbccccddddeeeeffff\"}");
|
||||
plaintexts.get(1).setProvisionPath("/some/dir/def.fdrp");
|
||||
plaintexts.get(1).setRepositoryProvision("{\"username\": \"user2\", \"name\": \"test repo a\", \"password\": \"other secret\", \"url\": \"https://example.com/repo\"}");
|
||||
plaintexts.get(1).setRepositoryProvision("{\"username\": \"user2\", \"name\": \"test repo a\", \"password\": \"other secret\", \"url\": \"https://example.com/fdroid/repo\", \"sigfp\": \"1111222233334444555566667777888899990000aaaabbbbccccddddeeeeffff\"}");
|
||||
|
||||
Provisioner p = new Provisioner();
|
||||
List<Provisioner.Provision> result = p.parseProvisions(plaintexts);
|
||||
|
||||
Assert.assertEquals("/some/dir/abc.fdrp", result.get(0).getProvisonPath());
|
||||
Assert.assertEquals("test repo a", result.get(0).getRepositoryProvision().getName());
|
||||
Assert.assertEquals("https://example.com/repo", result.get(0).getRepositoryProvision().getUrl());
|
||||
Assert.assertEquals("https://example.com/fdroid/repo", result.get(0).getRepositoryProvision().getUrl());
|
||||
Assert.assertEquals("1111222233334444555566667777888899990000aaaabbbbccccddddeeeeffff", result.get(0).getRepositoryProvision().getSigfp());
|
||||
Assert.assertEquals("user1", result.get(0).getRepositoryProvision().getUsername());
|
||||
Assert.assertEquals("secret1", result.get(0).getRepositoryProvision().getPassword());
|
||||
|
||||
Assert.assertEquals("/some/dir/def.fdrp", result.get(1).getProvisonPath());
|
||||
Assert.assertEquals("test repo a", result.get(1).getRepositoryProvision().getName());
|
||||
Assert.assertEquals("https://example.com/repo", result.get(1).getRepositoryProvision().getUrl());
|
||||
Assert.assertEquals("https://example.com/fdroid/repo", result.get(1).getRepositoryProvision().getUrl());
|
||||
Assert.assertEquals("1111222233334444555566667777888899990000aaaabbbbccccddddeeeeffff", result.get(1).getRepositoryProvision().getSigfp());
|
||||
Assert.assertEquals("user2", result.get(1).getRepositoryProvision().getUsername());
|
||||
Assert.assertEquals("other secret", result.get(1).getRepositoryProvision().getPassword());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user