rename RepoUpdater to IndexUpdater

This commit is contained in:
Hans-Christoph Steiner 2018-12-17 17:03:36 +01:00
parent 148d1cdc8a
commit 0e6b4acabf
No known key found for this signature in database
GPG Key ID: 3E177817BA1B9BFA
14 changed files with 109 additions and 109 deletions

View File

@ -16,8 +16,8 @@ import android.text.TextUtils;
import android.util.Log;
import org.fdroid.fdroid.FDroidApp;
import org.fdroid.fdroid.Hasher;
import org.fdroid.fdroid.IndexUpdater;
import org.fdroid.fdroid.Preferences;
import org.fdroid.fdroid.RepoUpdater;
import org.fdroid.fdroid.Utils;
import org.fdroid.fdroid.data.Apk;
import org.fdroid.fdroid.data.App;
@ -104,7 +104,7 @@ public final class LocalRepoManager {
repoDir = new SanitizedFile(fdroidDir, "repo");
repoDirCaps = new SanitizedFile(fdroidDirCaps, "REPO");
iconsDir = new SanitizedFile(repoDir, "icons");
xmlIndexJar = new SanitizedFile(repoDir, RepoUpdater.SIGNED_FILE_NAME);
xmlIndexJar = new SanitizedFile(repoDir, IndexUpdater.SIGNED_FILE_NAME);
xmlIndexJarUnsigned = new SanitizedFile(repoDir, "index.unsigned.jar");
if (!fdroidDir.exists() && !fdroidDir.mkdir()) {
@ -496,7 +496,7 @@ public final class LocalRepoManager {
public void writeIndexJar() throws IOException, XmlPullParserException, LocalRepoKeyStore.InitException {
BufferedOutputStream bo = new BufferedOutputStream(new FileOutputStream(xmlIndexJarUnsigned));
JarOutputStream jo = new JarOutputStream(bo);
JarEntry je = new JarEntry(RepoUpdater.DATA_FILE_NAME);
JarEntry je = new JarEntry(IndexUpdater.DATA_FILE_NAME);
jo.putNextEntry(je);
new IndexXmlBuilder().build(context, apps, jo);
jo.close();

View File

@ -80,8 +80,8 @@ import java.util.jar.JarFile;
* FDroid! Avoid modifying it when possible, if you absolutely must, be very,
* very careful with the changes that you are making!
*/
public class RepoUpdater {
private static final String TAG = "RepoUpdater";
public class IndexUpdater {
private static final String TAG = "IndexUpdater";
public static final String SIGNED_FILE_NAME = "index.jar";
public static final String DATA_FILE_NAME = "index.xml";
@ -106,7 +106,7 @@ public class RepoUpdater {
*
* @param repo A {@link Repo} read out of the local database
*/
public RepoUpdater(@NonNull Context context, @NonNull Repo repo) {
public IndexUpdater(@NonNull Context context, @NonNull Repo repo) {
this.context = context;
this.repo = repo;
this.persister = new RepoPersister(context, repo);
@ -208,7 +208,7 @@ public class RepoUpdater {
FDroidApp.disableBouncyCastleOnLollipop();
JarFile jarFile = new JarFile(downloadedFile, true);
JarEntry indexEntry = (JarEntry) jarFile.getEntry(RepoUpdater.DATA_FILE_NAME);
JarEntry indexEntry = (JarEntry) jarFile.getEntry(IndexUpdater.DATA_FILE_NAME);
indexInputStream = new ProgressBufferedInputStream(jarFile.getInputStream(indexEntry),
processIndexListener, repo.address, (int) indexEntry.getSize());
@ -249,14 +249,14 @@ public class RepoUpdater {
protected final ProgressListener downloadListener = new ProgressListener() {
@Override
public void onProgress(String urlString, long bytesRead, long totalBytes) {
UpdateService.reportDownloadProgress(context, RepoUpdater.this, bytesRead, totalBytes);
UpdateService.reportDownloadProgress(context, IndexUpdater.this, bytesRead, totalBytes);
}
};
protected final ProgressListener processIndexListener = new ProgressListener() {
@Override
public void onProgress(String urlString, long bytesRead, long totalBytes) {
UpdateService.reportProcessIndexProgress(context, RepoUpdater.this, bytesRead, totalBytes);
UpdateService.reportProcessIndexProgress(context, IndexUpdater.this, bytesRead, totalBytes);
}
};

View File

@ -84,7 +84,7 @@ import java.util.jar.JarFile;
* App/Apk classes, resulting in malicious servers being able to populate those
* variables.
*/
public class IndexV1Updater extends RepoUpdater {
public class IndexV1Updater extends IndexUpdater {
public static final String TAG = "IndexV1Updater";
private static final String SIGNED_FILE_NAME = "index-v1.jar";
@ -101,11 +101,11 @@ public class IndexV1Updater extends RepoUpdater {
/**
* @return whether this successfully found an index of this version
* @throws RepoUpdater.UpdateException
* @throws IndexUpdater.UpdateException
* @see org.fdroid.fdroid.net.DownloaderService#handleIntent(android.content.Intent)
*/
@Override
public boolean update() throws RepoUpdater.UpdateException {
public boolean update() throws IndexUpdater.UpdateException {
if (repo.isSwap) {
// swap repos do not support index-v1
@ -167,7 +167,7 @@ public class IndexV1Updater extends RepoUpdater {
if (downloader != null) {
FileUtils.deleteQuietly(downloader.outputFile);
}
throw new RepoUpdater.UpdateException("Error getting index file", e2);
throw new IndexUpdater.UpdateException("Error getting index file", e2);
} catch (InterruptedException e2) {
// ignored if canceled, the local database just won't be updated
}
@ -176,7 +176,7 @@ public class IndexV1Updater extends RepoUpdater {
if (downloader != null) {
FileUtils.deleteQuietly(downloader.outputFile);
}
throw new RepoUpdater.UpdateException("Error getting index file", e);
throw new IndexUpdater.UpdateException("Error getting index file", e);
} catch (InterruptedException e) {
// ignored if canceled, the local database just won't be updated
}
@ -185,7 +185,7 @@ public class IndexV1Updater extends RepoUpdater {
}
private void processDownloadedIndex(File outputFile, String cacheTag)
throws IOException, RepoUpdater.UpdateException {
throws IOException, IndexUpdater.UpdateException {
JarFile jarFile = new JarFile(outputFile, true);
JarEntry indexEntry = (JarEntry) jarFile.getEntry(DATA_FILE_NAME);
InputStream indexInputStream = new ProgressBufferedInputStream(jarFile.getInputStream(indexEntry),
@ -268,7 +268,7 @@ public class IndexV1Updater extends RepoUpdater {
long timestamp = (Long) repoMap.get("timestamp") / 1000;
if (repo.timestamp > timestamp) {
throw new RepoUpdater.UpdateException("index.jar is older that current index! "
throw new IndexUpdater.UpdateException("index.jar is older that current index! "
+ timestamp + " < " + repo.timestamp);
}
@ -429,15 +429,15 @@ public class IndexV1Updater extends RepoUpdater {
* This is also responsible for adding the {@link Repo} instance to the
* database for the first time.
* <p>
* This is the same as {@link RepoUpdater#verifyCerts(String, X509Certificate)},
* {@link RepoUpdater#verifyAndStoreTOFUCerts(String, X509Certificate)}, and
* {@link RepoUpdater#assertSigningCertFromXmlCorrect()} except there is no
* This is the same as {@link IndexUpdater#verifyCerts(String, X509Certificate)},
* {@link IndexUpdater#verifyAndStoreTOFUCerts(String, X509Certificate)}, and
* {@link IndexUpdater#assertSigningCertFromXmlCorrect()} except there is no
* embedded copy of the signing certificate in the index data.
*
* @param rawCertFromJar the {@link X509Certificate} embedded in the downloaded jar
* @see RepoUpdater#verifyAndStoreTOFUCerts(String, X509Certificate)
* @see RepoUpdater#verifyCerts(String, X509Certificate)
* @see RepoUpdater#assertSigningCertFromXmlCorrect()
* @see IndexUpdater#verifyAndStoreTOFUCerts(String, X509Certificate)
* @see IndexUpdater#verifyCerts(String, X509Certificate)
* @see IndexUpdater#assertSigningCertFromXmlCorrect()
*/
private void verifySigningCertificate(X509Certificate rawCertFromJar) throws SigningException {
String certFromJar = Hasher.hex(rawCertFromJar);
@ -473,7 +473,7 @@ public class IndexV1Updater extends RepoUpdater {
}
/**
* The {@code index-v1} version of {@link RepoUpdater#processRepoPushRequests(List)}
* The {@code index-v1} version of {@link IndexUpdater#processRepoPushRequests(List)}
*/
private void processRepoPushRequests(Map<String, String[]> requests) {
if (requests == null) {

View File

@ -518,7 +518,7 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh
* Whether push requests are globally enabled or disabled.
*
* @see org.fdroid.fdroid.data.RepoPushRequest
* @see RepoUpdater#processRepoPushRequests(List)
* @see IndexUpdater#processRepoPushRequests(List)
*/
public boolean allowPushRequests() {
return preferences.getBoolean(PREF_ALLOW_PUSH_REQUESTS, IGNORED_B);

View File

@ -467,9 +467,9 @@ public class UpdateService extends JobIntentService {
sendStatus(this, STATUS_INFO, getString(R.string.status_connecting_to_repo, repo.address));
try {
RepoUpdater updater = new IndexV1Updater(this, repo);
IndexUpdater updater = new IndexV1Updater(this, repo);
if (Preferences.get().isForceOldIndexEnabled() || !updater.update()) {
updater = new RepoUpdater(getBaseContext(), repo);
updater = new IndexUpdater(getBaseContext(), repo);
updater.update();
}
@ -479,7 +479,7 @@ public class UpdateService extends JobIntentService {
} else {
unchangedRepos++;
}
} catch (RepoUpdater.UpdateException e) {
} catch (IndexUpdater.UpdateException e) {
errorRepos++;
repoErrors.add(e.getMessage());
Log.e(TAG, "Error updating repository " + repo.address, e);
@ -555,7 +555,7 @@ public class UpdateService extends JobIntentService {
}
}
public static void reportDownloadProgress(Context context, RepoUpdater updater,
public static void reportDownloadProgress(Context context, IndexUpdater updater,
long bytesRead, long totalBytes) {
Utils.debugLog(TAG, "Downloading " + updater.indexUrl + "(" + bytesRead + "/" + totalBytes + ")");
String downloadedSizeFriendly = Utils.getFriendlySize(bytesRead);
@ -576,7 +576,7 @@ public class UpdateService extends JobIntentService {
sendStatus(context, STATUS_INFO, message, percent);
}
public static void reportProcessIndexProgress(Context context, RepoUpdater updater,
public static void reportProcessIndexProgress(Context context, IndexUpdater updater,
long bytesRead, long totalBytes) {
Utils.debugLog(TAG, "Processing " + updater.indexUrl + "(" + bytesRead + "/" + totalBytes + ")");
String downloadedSize = Utils.getFriendlySize(bytesRead);
@ -598,7 +598,7 @@ public class UpdateService extends JobIntentService {
* "Saving app details" sent to the user. If you know how many apps you have
* processed, then a message of "Saving app details (x/total)" is displayed.
*/
public static void reportProcessingAppsProgress(Context context, RepoUpdater updater,
public static void reportProcessingAppsProgress(Context context, IndexUpdater updater,
int appsSaved, int totalApps) {
Utils.debugLog(TAG, "Committing " + updater.indexUrl + "(" + appsSaved + "/" + totalApps + ")");
if (totalApps > 0) {

View File

@ -9,7 +9,7 @@ import android.os.RemoteException;
import android.support.annotation.NonNull;
import org.fdroid.fdroid.CompatibilityChecker;
import org.fdroid.fdroid.RepoUpdater;
import org.fdroid.fdroid.IndexUpdater;
import org.fdroid.fdroid.Utils;
import java.util.ArrayList;
@ -55,7 +55,7 @@ public class RepoPersister {
checker = new CompatibilityChecker(context);
}
public void saveToDb(App app, List<Apk> packages) throws RepoUpdater.UpdateException {
public void saveToDb(App app, List<Apk> packages) throws IndexUpdater.UpdateException {
appsToSave.add(app);
apksToSave.put(app.packageName, packages);
@ -64,13 +64,13 @@ public class RepoPersister {
}
}
public void commit(ContentValues repoDetailsToSave, long repoIdToCommit) throws RepoUpdater.UpdateException {
public void commit(ContentValues repoDetailsToSave, long repoIdToCommit) throws IndexUpdater.UpdateException {
flushBufferToDb();
TempAppProvider.Helper.commitAppsAndApks(context, repoIdToCommit);
RepoProvider.Helper.update(context, repo, repoDetailsToSave);
}
private void flushBufferToDb() throws RepoUpdater.UpdateException {
private void flushBufferToDb() throws IndexUpdater.UpdateException {
if (!hasBeenInitialized) {
// This is where we will store all of the metadata before commiting at the
// end of the process. This is due to the fact that we can't verify the cert
@ -90,7 +90,7 @@ public class RepoPersister {
}
}
private void flushApksToDbInBatch(Map<String, Long> appIds) throws RepoUpdater.UpdateException {
private void flushApksToDbInBatch(Map<String, Long> appIds) throws IndexUpdater.UpdateException {
List<Apk> apksToSaveList = new ArrayList<>();
for (Map.Entry<String, List<Apk>> entries : apksToSave.entrySet()) {
for (Apk apk : entries.getValue()) {
@ -106,7 +106,7 @@ public class RepoPersister {
try {
context.getContentResolver().applyBatch(TempApkProvider.getAuthority(), apkOperations);
} catch (RemoteException | OperationApplicationException e) {
throw new RepoUpdater.UpdateException("An internal error occurred while updating the database", e);
throw new IndexUpdater.UpdateException("An internal error occurred while updating the database", e);
}
}
@ -115,14 +115,14 @@ public class RepoPersister {
* Then, will query the database for the ID + packageName for each of these apps, so that they
* can be returned and the relevant apks can be joined to the app table correctly.
*/
private Map<String, Long> flushAppsToDbInBatch() throws RepoUpdater.UpdateException {
private Map<String, Long> flushAppsToDbInBatch() throws IndexUpdater.UpdateException {
ArrayList<ContentProviderOperation> appOperations = insertApps(appsToSave);
try {
context.getContentResolver().applyBatch(TempAppProvider.getAuthority(), appOperations);
return getIdsForPackages(appsToSave);
} catch (RemoteException | OperationApplicationException e) {
throw new RepoUpdater.UpdateException("An internal error occurred while updating the database", e);
throw new IndexUpdater.UpdateException("An internal error occurred while updating the database", e);
}
}

View File

@ -54,8 +54,8 @@ import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import org.fdroid.fdroid.FDroidApp;
import org.fdroid.fdroid.IndexUpdater;
import org.fdroid.fdroid.R;
import org.fdroid.fdroid.RepoUpdater;
import org.fdroid.fdroid.UpdateService;
import org.fdroid.fdroid.Utils;
import org.fdroid.fdroid.compat.CursorAdapterCompat;
@ -568,7 +568,7 @@ public class ManageReposActivity extends AppCompatActivity
return addressWithoutIndex;
}
final Uri uri = builder.appendPath(RepoUpdater.SIGNED_FILE_NAME).build();
final Uri uri = builder.appendPath(IndexUpdater.SIGNED_FILE_NAME).build();
try {
if (checkForRepository(uri)) {

View File

@ -5,7 +5,7 @@ import android.content.ContentValues;
import android.support.annotation.NonNull;
import android.util.Log;
import org.fdroid.fdroid.BuildConfig;
import org.fdroid.fdroid.RepoUpdater.UpdateException;
import org.fdroid.fdroid.IndexUpdater.UpdateException;
import org.fdroid.fdroid.data.Repo;
import org.fdroid.fdroid.data.RepoProvider;
import org.fdroid.fdroid.data.Schema.RepoTable.Cols;
@ -21,7 +21,7 @@ import static org.junit.Assert.assertNotNull;
@Config(constants = BuildConfig.class)
@RunWith(RobolectricTestRunner.class)
public class AcceptableMultiRepoUpdaterTest extends MultiRepoUpdaterTest {
public class AcceptableMultiIndexUpdaterTest extends MultiIndexUpdaterTest {
private static final String TAG = "AcceptableMultiRepoTest";
private void assertSomewhatAcceptable() {

View File

@ -2,7 +2,7 @@
package org.fdroid.fdroid.updater;
import org.fdroid.fdroid.BuildConfig;
import org.fdroid.fdroid.RepoUpdater;
import org.fdroid.fdroid.IndexUpdater;
import org.fdroid.fdroid.Utils;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -16,7 +16,7 @@ import org.robolectric.annotation.Config;
*/
@Config(constants = BuildConfig.class)
@RunWith(RobolectricTestRunner.class)
public class FDroidRepoUpdateTest extends MultiRepoUpdaterTest {
public class FDroidRepoUpdateTest extends MultiIndexUpdaterTest {
private static final String TAG = "FDroidRepoUpdateTest";
@ -25,26 +25,26 @@ public class FDroidRepoUpdateTest extends MultiRepoUpdaterTest {
private static final String REPO_FDROID_PUB_KEY = "3082035e30820246a00302010202044c49cd00300d06092a864886f70d01010505003071310b300906035504061302554b3110300e06035504081307556e6b6e6f776e3111300f0603550407130857657468657262793110300e060355040a1307556e6b6e6f776e3110300e060355040b1307556e6b6e6f776e311930170603550403131043696172616e2047756c746e69656b73301e170d3130303732333137313032345a170d3337313230383137313032345a3071310b300906035504061302554b3110300e06035504081307556e6b6e6f776e3111300f0603550407130857657468657262793110300e060355040a1307556e6b6e6f776e3110300e060355040b1307556e6b6e6f776e311930170603550403131043696172616e2047756c746e69656b7330820122300d06092a864886f70d01010105000382010f003082010a028201010096d075e47c014e7822c89fd67f795d23203e2a8843f53ba4e6b1bf5f2fd0e225938267cfcae7fbf4fe596346afbaf4070fdb91f66fbcdf2348a3d92430502824f80517b156fab00809bdc8e631bfa9afd42d9045ab5fd6d28d9e140afc1300917b19b7c6c4df4a494cf1f7cb4a63c80d734265d735af9e4f09455f427aa65a53563f87b336ca2c19d244fcbba617ba0b19e56ed34afe0b253ab91e2fdb1271f1b9e3c3232027ed8862a112f0706e234cf236914b939bcf959821ecb2a6c18057e070de3428046d94b175e1d89bd795e535499a091f5bc65a79d539a8d43891ec504058acb28c08393b5718b57600a211e803f4a634e5c57f25b9b8c4422c6fd90203010001300d06092a864886f70d0101050500038201010008e4ef699e9807677ff56753da73efb2390d5ae2c17e4db691d5df7a7b60fc071ae509c5414be7d5da74df2811e83d3668c4a0b1abc84b9fa7d96b4cdf30bba68517ad2a93e233b042972ac0553a4801c9ebe07bf57ebe9a3b3d6d663965260e50f3b8f46db0531761e60340a2bddc3426098397fda54044a17e5244549f9869b460ca5e6e216b6f6a2db0580b480ca2afe6ec6b46eedacfa4aa45038809ece0c5978653d6c85f678e7f5a2156d1bedd8117751e64a4b0dcd140f3040b021821a8d93aed8d01ba36db6c82372211fed714d9a32607038cdfd565bd529ffc637212aaa2c224ef22b603eccefb5bf1e085c191d4b24fe742b17ab3f55d4e6f05ef"; // NOCHECKSTYLE LineLength
@Test
public void doesntCrash() throws RepoUpdater.UpdateException {
public void doesntCrash() throws IndexUpdater.UpdateException {
assertEmpty();
updateEarlier();
updateLater();
updateV1Later();
}
protected void updateEarlier() throws RepoUpdater.UpdateException {
protected void updateEarlier() throws IndexUpdater.UpdateException {
Utils.debugLog(TAG, "Updating earlier version of F-Droid repo");
updateRepo(createRepoUpdater(REPO_FDROID, REPO_FDROID_URI, context, REPO_FDROID_PUB_KEY),
"index.fdroid.2016-10-30.jar");
}
protected void updateLater() throws RepoUpdater.UpdateException {
protected void updateLater() throws IndexUpdater.UpdateException {
Utils.debugLog(TAG, "Updating later version of F-Droid repo");
updateRepo(createRepoUpdater(REPO_FDROID, REPO_FDROID_URI, context, REPO_FDROID_PUB_KEY),
"index.fdroid.2016-11-10.jar");
}
protected void updateV1Later() throws RepoUpdater.UpdateException {
protected void updateV1Later() throws IndexUpdater.UpdateException {
Utils.debugLog(TAG, "Updating later version of F-Droid index-v1");
updateRepo(createIndexV1Updater(REPO_FDROID, REPO_FDROID_URI, context, REPO_FDROID_PUB_KEY),
"index-v1.fdroid.2017-07-07.jar");

View File

@ -12,9 +12,9 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectReader;
import org.apache.commons.io.IOUtils;
import org.fdroid.fdroid.BuildConfig;
import org.fdroid.fdroid.IndexUpdater;
import org.fdroid.fdroid.IndexV1Updater;
import org.fdroid.fdroid.Preferences;
import org.fdroid.fdroid.RepoUpdater;
import org.fdroid.fdroid.TestUtils;
import org.fdroid.fdroid.data.Apk;
import org.fdroid.fdroid.data.ApkProvider;
@ -71,14 +71,14 @@ public class IndexV1UpdaterTest extends FDroidProviderTest {
}
@Test
public void testIndexV1Processing() throws IOException, RepoUpdater.UpdateException {
public void testIndexV1Processing() throws IOException, IndexUpdater.UpdateException {
List<Repo> repos = RepoProvider.Helper.all(context);
for (Repo repo : repos) {
RepoProvider.Helper.remove(context, repo.getId());
}
assertEquals("No repos present", 0, RepoProvider.Helper.all(context).size());
assertEquals("No apps present", 0, AppProvider.Helper.all(context.getContentResolver()).size());
Repo repo = MultiRepoUpdaterTest.createRepo("Testy", TESTY_JAR, context, TESTY_CERT);
Repo repo = MultiIndexUpdaterTest.createRepo("Testy", TESTY_JAR, context, TESTY_CERT);
repo.timestamp = 1481222110;
IndexV1Updater updater = new IndexV1Updater(context, repo);
JarFile jarFile = new JarFile(TestUtils.copyResourceToTempFile(TESTY_JAR), true);
@ -131,10 +131,10 @@ public class IndexV1UpdaterTest extends FDroidProviderTest {
assertEquals(1, AppProvider.Helper.findInstalledAppsWithKnownVulns(context).size());
}
@Test(expected = RepoUpdater.SigningException.class)
public void testIndexV1WithWrongCert() throws IOException, RepoUpdater.UpdateException {
@Test(expected = IndexUpdater.SigningException.class)
public void testIndexV1WithWrongCert() throws IOException, IndexUpdater.UpdateException {
String badCert = "308202ed308201d5a003020102020426ffa009300d06092a864886f70d01010b05003027310b300906035504061302444531183016060355040a130f4e4f47415050532050726f6a656374301e170d3132313030363132303533325a170d3337303933303132303533325a3027310b300906035504061302444531183016060355040a130f4e4f47415050532050726f6a65637430820122300d06092a864886f70d01010105000382010f003082010a02820101009a8d2a5336b0eaaad89ce447828c7753b157459b79e3215dc962ca48f58c2cd7650df67d2dd7bda0880c682791f32b35c504e43e77b43c3e4e541f86e35a8293a54fb46e6b16af54d3a4eda458f1a7c8bc1b7479861ca7043337180e40079d9cdccb7e051ada9b6c88c9ec635541e2ebf0842521c3024c826f6fd6db6fd117c74e859d5af4db04448965ab5469b71ce719939a06ef30580f50febf96c474a7d265bb63f86a822ff7b643de6b76e966a18553c2858416cf3309dd24278374bdd82b4404ef6f7f122cec93859351fc6e5ea947e3ceb9d67374fe970e593e5cd05c905e1d24f5a5484f4aadef766e498adf64f7cf04bddd602ae8137b6eea40722d0203010001a321301f301d0603551d0e04160414110b7aa9ebc840b20399f69a431f4dba6ac42a64300d06092a864886f70d01010b0500038201010007c32ad893349cf86952fb5a49cfdc9b13f5e3c800aece77b2e7e0e9c83e34052f140f357ec7e6f4b432dc1ed542218a14835acd2df2deea7efd3fd5e8f1c34e1fb39ec6a427c6e6f4178b609b369040ac1f8844b789f3694dc640de06e44b247afed11637173f36f5886170fafd74954049858c6096308fc93c1bc4dd5685fa7a1f982a422f2a3b36baa8c9500474cf2af91c39cbec1bc898d10194d368aa5e91f1137ec115087c31962d8f76cd120d28c249cf76f4c70f5baa08c70a7234ce4123be080cee789477401965cfe537b924ef36747e8caca62dfefdd1a6288dcb1c4fd2aaa6131a7ad254e9742022cfd597d2ca5c660ce9e41ff537e5a4041e37"; // NOCHECKSTYLE LineLength
Repo repo = MultiRepoUpdaterTest.createRepo("Testy", TESTY_JAR, context, badCert);
Repo repo = MultiIndexUpdaterTest.createRepo("Testy", TESTY_JAR, context, badCert);
IndexV1Updater updater = new IndexV1Updater(context, repo);
JarFile jarFile = new JarFile(TestUtils.copyResourceToTempFile(TESTY_JAR), true);
JarEntry indexEntry = (JarEntry) jarFile.getEntry(IndexV1Updater.DATA_FILE_NAME);
@ -144,9 +144,9 @@ public class IndexV1UpdaterTest extends FDroidProviderTest {
getClass().getResourceAsStream("foo");
}
@Test(expected = RepoUpdater.UpdateException.class)
public void testIndexV1WithOldTimestamp() throws IOException, RepoUpdater.UpdateException {
Repo repo = MultiRepoUpdaterTest.createRepo("Testy", TESTY_JAR, context, TESTY_CERT);
@Test(expected = IndexUpdater.UpdateException.class)
public void testIndexV1WithOldTimestamp() throws IOException, IndexUpdater.UpdateException {
Repo repo = MultiIndexUpdaterTest.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);
@ -157,28 +157,28 @@ public class IndexV1UpdaterTest extends FDroidProviderTest {
getClass().getResourceAsStream("foo");
}
@Test(expected = RepoUpdater.SigningException.class)
public void testIndexV1WithBadTestyJarNoManifest() throws IOException, RepoUpdater.UpdateException {
@Test(expected = IndexUpdater.SigningException.class)
public void testIndexV1WithBadTestyJarNoManifest() throws IOException, IndexUpdater.UpdateException {
testBadTestyJar("testy.at.or.at_no-MANIFEST.MF_index-v1.jar");
}
@Test(expected = RepoUpdater.SigningException.class)
public void testIndexV1WithBadTestyJarNoSigningCert() throws IOException, RepoUpdater.UpdateException {
@Test(expected = IndexUpdater.SigningException.class)
public void testIndexV1WithBadTestyJarNoSigningCert() throws IOException, IndexUpdater.UpdateException {
testBadTestyJar("testy.at.or.at_no-.RSA_index-v1.jar");
}
@Test(expected = RepoUpdater.SigningException.class)
public void testIndexV1WithBadTestyJarNoSignature() throws IOException, RepoUpdater.UpdateException {
@Test(expected = IndexUpdater.SigningException.class)
public void testIndexV1WithBadTestyJarNoSignature() throws IOException, IndexUpdater.UpdateException {
testBadTestyJar("testy.at.or.at_no-.SF_index-v1.jar");
}
@Test(expected = RepoUpdater.SigningException.class)
public void testIndexV1WithBadTestyJarNoSignatureFiles() throws IOException, RepoUpdater.UpdateException {
@Test(expected = IndexUpdater.SigningException.class)
public void testIndexV1WithBadTestyJarNoSignatureFiles() throws IOException, IndexUpdater.UpdateException {
testBadTestyJar("testy.at.or.at_no-signature_index-v1.jar");
}
private void testBadTestyJar(String jar) throws IOException, RepoUpdater.UpdateException {
Repo repo = MultiRepoUpdaterTest.createRepo("Testy", jar, context, TESTY_CERT);
private void testBadTestyJar(String jar) throws IOException, IndexUpdater.UpdateException {
Repo repo = MultiIndexUpdaterTest.createRepo("Testy", jar, context, TESTY_CERT);
IndexV1Updater updater = new IndexV1Updater(context, repo);
JarFile jarFile = new JarFile(TestUtils.copyResourceToTempFile(jar), true);
JarEntry indexEntry = (JarEntry) jarFile.getEntry(IndexV1Updater.DATA_FILE_NAME);

View File

@ -2,7 +2,7 @@ package org.fdroid.fdroid.updater;
import android.content.ContentValues;
import org.fdroid.fdroid.BuildConfig;
import org.fdroid.fdroid.RepoUpdater;
import org.fdroid.fdroid.IndexUpdater;
import org.fdroid.fdroid.data.Apk;
import org.fdroid.fdroid.data.ApkProvider;
import org.fdroid.fdroid.data.Repo;
@ -21,7 +21,7 @@ import static org.junit.Assert.assertEquals;
@Config(constants = BuildConfig.class)
@RunWith(RobolectricTestRunner.class)
@SuppressWarnings("LineLength")
public class Issue763MultiRepo extends MultiRepoUpdaterTest {
public class Issue763MultiRepo extends MultiIndexUpdaterTest {
private Repo microGRepo;
private Repo antoxRepo;
@ -42,31 +42,31 @@ public class Issue763MultiRepo extends MultiRepoUpdaterTest {
}
@Test
public void antoxRepo() throws RepoUpdater.UpdateException {
public void antoxRepo() throws IndexUpdater.UpdateException {
assertAntoxEmpty();
setEnabled(microGRepo, true);
updateAntox();
assertAntoxExists();
}
private void updateAntox() throws RepoUpdater.UpdateException {
updateRepo(new RepoUpdater(context, antoxRepo), "index.antox.jar");
private void updateAntox() throws IndexUpdater.UpdateException {
updateRepo(new IndexUpdater(context, antoxRepo), "index.antox.jar");
}
@Test
public void microGRepo() throws RepoUpdater.UpdateException {
public void microGRepo() throws IndexUpdater.UpdateException {
assertMicroGEmpty();
setEnabled(microGRepo, true);
updateMicroG();
assertMicroGExists();
}
private void updateMicroG() throws RepoUpdater.UpdateException {
updateRepo(new RepoUpdater(context, microGRepo), "index.microg.jar");
private void updateMicroG() throws IndexUpdater.UpdateException {
updateRepo(new IndexUpdater(context, microGRepo), "index.microg.jar");
}
@Test
public void antoxAndMicroG() throws RepoUpdater.UpdateException {
public void antoxAndMicroG() throws IndexUpdater.UpdateException {
assertMicroGEmpty();
assertAntoxEmpty();

View File

@ -7,8 +7,8 @@ import android.support.annotation.NonNull;
import android.text.TextUtils;
import org.fdroid.fdroid.IndexV1Updater;
import org.fdroid.fdroid.Preferences;
import org.fdroid.fdroid.RepoUpdater;
import org.fdroid.fdroid.RepoUpdater.UpdateException;
import org.fdroid.fdroid.IndexUpdater;
import org.fdroid.fdroid.IndexUpdater.UpdateException;
import org.fdroid.fdroid.TestUtils;
import org.fdroid.fdroid.data.Apk;
import org.fdroid.fdroid.data.ApkProvider;
@ -31,9 +31,9 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
public abstract class MultiRepoUpdaterTest extends FDroidProviderTest {
public abstract class MultiIndexUpdaterTest extends FDroidProviderTest {
@SuppressWarnings("unused")
private static final String TAG = "AcceptableMultiRepoUpdaterTest"; // NOPMD
private static final String TAG = "AcceptableMultiIndexUpdaterTest"; // NOPMD
protected static final String REPO_MAIN = "Test F-Droid repo";
protected static final String REPO_ARCHIVE = "Test F-Droid repo (Archive)";
@ -171,12 +171,12 @@ public abstract class MultiRepoUpdaterTest extends FDroidProviderTest {
return RepoProvider.Helper.findByAddress(context, uri);
}
protected RepoUpdater createRepoUpdater(String name, String uri, Context context) {
return new RepoUpdater(context, createRepo(name, uri, context));
protected IndexUpdater createRepoUpdater(String name, String uri, Context context) {
return new IndexUpdater(context, createRepo(name, uri, context));
}
protected RepoUpdater createRepoUpdater(String name, String uri, Context context, String signingCert) {
return new RepoUpdater(context, createRepo(name, uri, context, signingCert));
protected IndexUpdater createRepoUpdater(String name, String uri, Context context, String signingCert) {
return new IndexUpdater(context, createRepo(name, uri, context, signingCert));
}
protected IndexV1Updater createIndexV1Updater(String name, String uri, Context context, String signingCert) {
@ -195,7 +195,7 @@ public abstract class MultiRepoUpdaterTest extends FDroidProviderTest {
updateRepo(createRepoUpdater(REPO_ARCHIVE, REPO_ARCHIVE_URI, context), "multiRepo.archive.jar");
}
protected void updateRepo(RepoUpdater updater, String indexJarPath) throws UpdateException {
protected void updateRepo(IndexUpdater updater, String indexJarPath) throws UpdateException {
File indexJar = TestUtils.copyResourceToTempFile(indexJarPath);
try {
if (updater instanceof IndexV1Updater) {

View File

@ -5,7 +5,7 @@ import android.content.ContentValues;
import android.support.annotation.StringDef;
import android.util.Log;
import org.fdroid.fdroid.BuildConfig;
import org.fdroid.fdroid.RepoUpdater;
import org.fdroid.fdroid.IndexUpdater;
import org.fdroid.fdroid.TestUtils;
import org.fdroid.fdroid.data.Apk;
import org.fdroid.fdroid.data.ApkProvider;
@ -34,9 +34,9 @@ import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@Config(constants = BuildConfig.class, shadows = ProperMultiRepoUpdaterTest.ArmSystemProperties.class)
@Config(constants = BuildConfig.class, shadows = ProperMultiIndexUpdaterTest.ArmSystemProperties.class)
@RunWith(RobolectricTestRunner.class)
public class ProperMultiRepoUpdaterTest extends MultiRepoUpdaterTest {
public class ProperMultiIndexUpdaterTest extends MultiIndexUpdaterTest {
private static final String TAG = "ProperMultiRepoSupport";
@Retention(RetentionPolicy.SOURCE)
@ -44,7 +44,7 @@ public class ProperMultiRepoUpdaterTest extends MultiRepoUpdaterTest {
public @interface RepoIdentifier { }
@Test
public void appsRemovedFromRepo() throws RepoUpdater.UpdateException {
public void appsRemovedFromRepo() throws IndexUpdater.UpdateException {
assertEquals(0, AppProvider.Helper.all(context.getContentResolver()).size());
updateMain();
@ -56,7 +56,7 @@ public class ProperMultiRepoUpdaterTest extends MultiRepoUpdaterTest {
assertEquals(2, ApkProvider.Helper.findByPackageName(context, "com.uberspot.a2048").size());
assertEquals(1, ApkProvider.Helper.findByPackageName(context, "siir.es.adbWireless").size());
RepoUpdater updater = new RepoUpdater(context, RepoProvider.Helper.findByAddress(context, repo.address));
IndexUpdater updater = new IndexUpdater(context, RepoProvider.Helper.findByAddress(context, repo.address));
updateRepo(updater, "multiRepo.conflicting.jar");
assertEquals(2, AppProvider.Helper.all(context.getContentResolver()).size());
@ -66,7 +66,7 @@ public class ProperMultiRepoUpdaterTest extends MultiRepoUpdaterTest {
}
@Test
public void mainRepo() throws RepoUpdater.UpdateException {
public void mainRepo() throws IndexUpdater.UpdateException {
assertEmpty();
updateMain();
assertMainRepo();
@ -76,7 +76,7 @@ public class ProperMultiRepoUpdaterTest extends MultiRepoUpdaterTest {
}
@Test
public void archiveRepo() throws RepoUpdater.UpdateException {
public void archiveRepo() throws IndexUpdater.UpdateException {
assertEmpty();
updateArchive();
assertMainArchiveRepoMetadata();
@ -85,7 +85,7 @@ public class ProperMultiRepoUpdaterTest extends MultiRepoUpdaterTest {
}
@Test
public void conflictingRepo() throws RepoUpdater.UpdateException {
public void conflictingRepo() throws IndexUpdater.UpdateException {
assertEmpty();
updateConflicting();
assertConflictingRepo();
@ -103,7 +103,7 @@ public class ProperMultiRepoUpdaterTest extends MultiRepoUpdaterTest {
}
@Test
public void metadataWithRepoPriority() throws RepoUpdater.UpdateException {
public void metadataWithRepoPriority() throws IndexUpdater.UpdateException {
updateMain();
updateArchive();
updateConflicting();
@ -163,7 +163,7 @@ public class ProperMultiRepoUpdaterTest extends MultiRepoUpdaterTest {
}
@Test
public void testCorrectConflictingThenMainThenArchive() throws RepoUpdater.UpdateException {
public void testCorrectConflictingThenMainThenArchive() throws IndexUpdater.UpdateException {
assertEmpty();
updateConflicting();
@ -174,7 +174,7 @@ public class ProperMultiRepoUpdaterTest extends MultiRepoUpdaterTest {
}
@Test
public void testCorrectConflictingThenArchiveThenMain() throws RepoUpdater.UpdateException {
public void testCorrectConflictingThenArchiveThenMain() throws IndexUpdater.UpdateException {
assertEmpty();
updateConflicting();
@ -185,7 +185,7 @@ public class ProperMultiRepoUpdaterTest extends MultiRepoUpdaterTest {
}
@Test
public void testCorrectArchiveThenMainThenConflicting() throws RepoUpdater.UpdateException {
public void testCorrectArchiveThenMainThenConflicting() throws IndexUpdater.UpdateException {
assertEmpty();
updateArchive();
@ -196,7 +196,7 @@ public class ProperMultiRepoUpdaterTest extends MultiRepoUpdaterTest {
}
@Test
public void testCorrectArchiveThenConflictingThenMain() throws RepoUpdater.UpdateException {
public void testCorrectArchiveThenConflictingThenMain() throws IndexUpdater.UpdateException {
assertEmpty();
updateArchive();
@ -207,7 +207,7 @@ public class ProperMultiRepoUpdaterTest extends MultiRepoUpdaterTest {
}
@Test
public void testCorrectMainThenArchiveThenConflicting() throws RepoUpdater.UpdateException {
public void testCorrectMainThenArchiveThenConflicting() throws IndexUpdater.UpdateException {
assertEmpty();
updateMain();
@ -218,7 +218,7 @@ public class ProperMultiRepoUpdaterTest extends MultiRepoUpdaterTest {
}
@Test
public void testCorrectMainThenConflictingThenArchive() throws RepoUpdater.UpdateException {
public void testCorrectMainThenConflictingThenArchive() throws IndexUpdater.UpdateException {
assertEmpty();
updateMain();
@ -310,7 +310,7 @@ public class ProperMultiRepoUpdaterTest extends MultiRepoUpdaterTest {
assertAdAwayMetadata(adaway, id);
}
/** @see ProperMultiRepoUpdaterTest#assert2048Metadata(Repo, String) */
/** @see ProperMultiIndexUpdaterTest#assert2048Metadata(Repo, String) */
private void assertAdAwayMetadata(App adaway, @RepoIdentifier String id) {
assertNotNull(adaway);
assertEquals(String.format("AdAway", id),
@ -338,7 +338,7 @@ public class ProperMultiRepoUpdaterTest extends MultiRepoUpdaterTest {
assertAdbMetadata(adb, id);
}
/** @see ProperMultiRepoUpdaterTest#assert2048Metadata(Repo, String) */
/** @see ProperMultiIndexUpdaterTest#assert2048Metadata(Repo, String) */
private void assertAdbMetadata(App adb, @RepoIdentifier String id) {
assertNotNull(adb);
assertEquals("adbWireless", adb.name);
@ -355,7 +355,7 @@ public class ProperMultiRepoUpdaterTest extends MultiRepoUpdaterTest {
assertCalendarMetadata(calendar, id);
}
/** @see ProperMultiRepoUpdaterTest#assert2048Metadata(Repo, String) */
/** @see ProperMultiIndexUpdaterTest#assert2048Metadata(Repo, String) */
private void assertCalendarMetadata(App calendar, @RepoIdentifier String id) {
assertNotNull(calendar);
assertEquals("Add to calendar",

View File

@ -3,7 +3,7 @@ package org.fdroid.fdroid.localrepo;
import android.content.Context;
import android.text.TextUtils;
import org.apache.commons.io.IOUtils;
import org.fdroid.fdroid.RepoUpdater;
import org.fdroid.fdroid.IndexUpdater;
import org.fdroid.fdroid.Utils;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -28,13 +28,13 @@ import static org.junit.Assert.assertNotNull;
public class LocalRepoKeyStoreTest {
@Test
public void testSignZip() throws IOException, LocalRepoKeyStore.InitException, RepoUpdater.SigningException {
public void testSignZip() throws IOException, LocalRepoKeyStore.InitException, IndexUpdater.SigningException {
Context context = RuntimeEnvironment.application;
File xmlIndexJarUnsigned = File.createTempFile(getClass().getName(), "unsigned.jar");
BufferedOutputStream bo = new BufferedOutputStream(new FileOutputStream(xmlIndexJarUnsigned));
JarOutputStream jo = new JarOutputStream(bo);
JarEntry je = new JarEntry(RepoUpdater.DATA_FILE_NAME);
JarEntry je = new JarEntry(IndexUpdater.DATA_FILE_NAME);
jo.putNextEntry(je);
InputStream inputStream = getClass().getClassLoader().getResourceAsStream("smallRepo.xml");
IOUtils.copy(inputStream, jo);
@ -45,13 +45,13 @@ public class LocalRepoKeyStoreTest {
Certificate localCert = localRepoKeyStore.getCertificate();
assertFalse(TextUtils.isEmpty(Utils.calcFingerprint(localCert)));
File xmlIndexJar = File.createTempFile(getClass().getName(), RepoUpdater.SIGNED_FILE_NAME);
File xmlIndexJar = File.createTempFile(getClass().getName(), IndexUpdater.SIGNED_FILE_NAME);
localRepoKeyStore.signZip(xmlIndexJarUnsigned, xmlIndexJar);
JarFile jarFile = new JarFile(xmlIndexJar, true);
JarEntry indexEntry = (JarEntry) jarFile.getEntry(RepoUpdater.DATA_FILE_NAME);
JarEntry indexEntry = (JarEntry) jarFile.getEntry(IndexUpdater.DATA_FILE_NAME);
byte[] data = IOUtils.toByteArray(jarFile.getInputStream(indexEntry));
assertEquals(17187, data.length);
assertNotNull(RepoUpdater.getSigningCertFromJar(indexEntry));
assertNotNull(IndexUpdater.getSigningCertFromJar(indexEntry));
}
}