use of org.fdroid.fdroid.data.Repo in project fdroidclient by f-droid.
the class AcceptableMultiRepoUpdaterTest method getConflictingRepo.
@NonNull
private Repo getConflictingRepo() {
Repo repo = RepoProvider.Helper.findByAddress(context, REPO_CONFLICTING_URI);
assertNotNull(repo);
return repo;
}
use of org.fdroid.fdroid.data.Repo in project fdroidclient by f-droid.
the class AcceptableMultiRepoUpdaterTest method getMainRepo.
@NonNull
private Repo getMainRepo() {
Repo repo = RepoProvider.Helper.findByAddress(context, REPO_MAIN_URI);
assertNotNull(repo);
return repo;
}
use of org.fdroid.fdroid.data.Repo in project fdroidclient by f-droid.
the class AcceptableMultiRepoUpdaterTest method getArchiveRepo.
@NonNull
private Repo getArchiveRepo() {
Repo repo = RepoProvider.Helper.findByAddress(context, REPO_ARCHIVE_URI);
assertNotNull(repo);
return repo;
}
use of org.fdroid.fdroid.data.Repo in project fdroidclient by f-droid.
the class IndexV1UpdaterTest method testJacksonParsing.
@Test
public void testJacksonParsing() throws IOException {
ObjectMapper mapper = IndexV1Updater.getObjectMapperInstance(FAKE_REPO_ID);
// the app ignores all unknown fields when complete, do not ignore during dev to catch mistakes
mapper.enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
JsonFactory f = mapper.getFactory();
JsonParser parser = f.createParser(TestUtils.copyResourceToTempFile("guardianproject_index-v1.json"));
Repo repo = null;
App[] apps = null;
Map<String, String[]> requests = null;
Map<String, List<Apk>> packages = null;
// go into the main object block
parser.nextToken();
while (true) {
String fieldName = parser.nextFieldName();
if (fieldName == null) {
break;
}
switch(fieldName) {
case "repo":
repo = parseRepo(mapper, parser);
break;
case "requests":
requests = parseRequests(mapper, parser);
break;
case "apps":
apps = parseApps(mapper, parser);
break;
case "packages":
packages = parsePackages(mapper, parser);
break;
}
}
// ensure resources get cleaned up timely and properly
parser.close();
RepoDetails indexV0Details = getFromFile("guardianproject_index.xml", Repo.PUSH_REQUEST_ACCEPT_ALWAYS);
indexV0Details.apps.size();
assertEquals(indexV0Details.apps.size(), apps.length);
assertEquals(apps.length, packages.size());
int totalApks = 0;
for (String packageName : packages.keySet()) {
totalApks += packages.get(packageName).size();
}
assertEquals(totalApks, indexV0Details.apks.size());
assertEquals(indexV0Details.icon, repo.icon);
// V1 is in millis
assertEquals(indexV0Details.timestamp, repo.timestamp / 1000);
assertEquals(indexV0Details.name, repo.name);
assertArrayEquals(indexV0Details.mirrors, repo.mirrors);
ArrayList<String> installRequests = new ArrayList<>();
for (RepoPushRequest repoPushRequest : indexV0Details.repoPushRequestList) {
if ("install".equals(repoPushRequest.request)) {
installRequests.add(repoPushRequest.packageName);
}
}
assertArrayEquals(installRequests.toArray(), requests.get("install"));
}
use of org.fdroid.fdroid.data.Repo in project fdroidclient by f-droid.
the class IndexV1UpdaterTest method testIndexV1WithOldTimestamp.
@Test(expected = RepoUpdater.UpdateException.class)
public void testIndexV1WithOldTimestamp() throws IOException, RepoUpdater.UpdateException {
Repo repo = MultiRepoUpdaterTest.createRepo("Testy", TESTY_JAR, context, TESTY_CERT);
repo.timestamp = System.currentTimeMillis() / 1000;
IndexV1Updater updater = new IndexV1Updater(context, repo);
JarFile jarFile = new JarFile(TestUtils.copyResourceToTempFile(TESTY_JAR), true);
JarEntry indexEntry = (JarEntry) jarFile.getEntry(IndexV1Updater.DATA_FILE_NAME);
InputStream indexInputStream = jarFile.getInputStream(indexEntry);
updater.processIndexV1(indexInputStream, indexEntry, "fakeEtag");
// it should never reach here, it should throw a SigningException
fail();
getClass().getResourceAsStream("foo");
}
Aggregations