diff --git a/app/src/androidTest/java/org/fdroid/fdroid/net/HttpDownloaderTest.java b/app/src/androidTest/java/org/fdroid/fdroid/net/HttpDownloaderTest.java index 25d47892b..62f9b70d2 100644 --- a/app/src/androidTest/java/org/fdroid/fdroid/net/HttpDownloaderTest.java +++ b/app/src/androidTest/java/org/fdroid/fdroid/net/HttpDownloaderTest.java @@ -13,6 +13,7 @@ import org.fdroid.download.Mirror; import org.fdroid.fdroid.FDroidApp; import org.fdroid.fdroid.ProgressListener; import org.fdroid.fdroid.Utils; +import org.fdroid.index.v1.IndexV1UpdaterKt; import org.junit.Test; import java.io.File; @@ -38,20 +39,20 @@ public class HttpDownloaderTest { // https://developer.android.com/reference/javax/net/ssl/SSLContext static { ArrayList> tempUrls = new ArrayList<>(Arrays.asList( - new Pair<>("https://f-droid.org/repo", "index-v1.jar"), + new Pair<>("https://f-droid.org/repo", IndexV1UpdaterKt.SIGNED_FILE_NAME), // sites that use SNI for HTTPS new Pair<>("https://mirrors.edge.kernel.org/", "debian/dists/stable/Release"), - new Pair<>("https://fdroid.tetaneutral.net/fdroid/repo/", "index-v1.jar"), - new Pair<>("https://ftp.fau.de/fdroid/repo/", "index-v1.jar"), + new Pair<>("https://fdroid.tetaneutral.net/fdroid/repo/", IndexV1UpdaterKt.SIGNED_FILE_NAME), + new Pair<>("https://ftp.fau.de/fdroid/repo/", IndexV1UpdaterKt.SIGNED_FILE_NAME), new Pair<>("https://ftp.fau.de/fdroid/repo", "dev.lonami.klooni/en-US/phoneScreenshots/1-game.jpg"), //new Pair<>("https://microg.org/fdroid/repo/index-v1.jar"), //new Pair<>("https://grobox.de/fdroid/repo/index.jar"), - new Pair<>("https://guardianproject.info/fdroid/repo", "index-v1.jar") + new Pair<>("https://guardianproject.info/fdroid/repo", IndexV1UpdaterKt.SIGNED_FILE_NAME) )); if (Build.VERSION.SDK_INT >= 22) { tempUrls.addAll(Arrays.asList( new Pair<>("https://en.wikipedia.org", "/wiki/Index.html"), // no SNI but weird ipv6 lookup issues - new Pair<>("https://mirror.cyberbits.eu/fdroid/repo/", "index-v1.jar") // TLSv1.2 only and SNI + new Pair<>("https://mirror.cyberbits.eu/fdroid/repo/", IndexV1UpdaterKt.SIGNED_FILE_NAME) // TLSv1.2 only and SNI )); } URLS = tempUrls; diff --git a/app/src/full/java/org/fdroid/fdroid/nearby/LocalRepoManager.java b/app/src/full/java/org/fdroid/fdroid/nearby/LocalRepoManager.java index 61aae7960..9d16c4085 100644 --- a/app/src/full/java/org/fdroid/fdroid/nearby/LocalRepoManager.java +++ b/app/src/full/java/org/fdroid/fdroid/nearby/LocalRepoManager.java @@ -16,6 +16,8 @@ import org.fdroid.fdroid.data.SanitizedFile; import org.fdroid.index.v1.AppV1; import org.fdroid.index.v1.IndexV1; import org.fdroid.index.v1.IndexV1Creator; +import org.fdroid.index.v1.IndexV1UpdaterKt; +import org.fdroid.index.v1.IndexV1VerifierKt; import org.fdroid.index.v1.PackageV1; import org.fdroid.index.v1.RepoV1; @@ -94,7 +96,7 @@ public final class LocalRepoManager { fdroidDirCaps = new SanitizedFile(webRoot, "FDROID"); repoDir = new SanitizedFile(fdroidDir, "repo"); repoDirCaps = new SanitizedFile(fdroidDirCaps, "REPO"); - indexJar = new SanitizedFile(repoDir, "index-v1.jar"); + indexJar = new SanitizedFile(repoDir, IndexV1UpdaterKt.SIGNED_FILE_NAME); indexJarUnsigned = new SanitizedFile(repoDir, "index-v1.unsigned.jar"); if (!fdroidDir.exists() && !fdroidDir.mkdir()) { @@ -257,7 +259,7 @@ public final class LocalRepoManager { IndexV1 indexV1 = creator.createRepo(); cacheApps(indexV1); writeIndexPage(address); - SanitizedFile indexJson = new SanitizedFile(repoDir, "index-v1.json"); + SanitizedFile indexJson = new SanitizedFile(repoDir, IndexV1VerifierKt.DATA_FILE_NAME); writeIndexJar(indexJson); } diff --git a/app/src/full/java/org/fdroid/fdroid/nearby/SDCardScannerService.java b/app/src/full/java/org/fdroid/fdroid/nearby/SDCardScannerService.java index eaac0a445..e479f3fa7 100644 --- a/app/src/full/java/org/fdroid/fdroid/nearby/SDCardScannerService.java +++ b/app/src/full/java/org/fdroid/fdroid/nearby/SDCardScannerService.java @@ -32,6 +32,7 @@ import android.util.Log; import org.fdroid.fdroid.Utils; import org.fdroid.index.SigningException; +import org.fdroid.index.v1.IndexV1UpdaterKt; import java.io.File; import java.io.FileInputStream; @@ -144,7 +145,7 @@ public class SDCardScannerService extends IntentService { if (file.isDirectory()) { searchDirectory(file); } else { - if (TreeUriUtils.SIGNED_FILE_NAME.equals(file.getName())) { + if (IndexV1UpdaterKt.SIGNED_FILE_NAME.equals(file.getName())) { registerRepo(file); } } diff --git a/app/src/full/java/org/fdroid/fdroid/nearby/SwapService.java b/app/src/full/java/org/fdroid/fdroid/nearby/SwapService.java index 88a8ffa00..aabcfda44 100644 --- a/app/src/full/java/org/fdroid/fdroid/nearby/SwapService.java +++ b/app/src/full/java/org/fdroid/fdroid/nearby/SwapService.java @@ -33,6 +33,7 @@ import org.fdroid.index.IndexParser; import org.fdroid.index.IndexParserKt; import org.fdroid.index.SigningException; import org.fdroid.index.v1.IndexV1; +import org.fdroid.index.v1.IndexV1UpdaterKt; import org.fdroid.index.v1.IndexV1Verifier; import org.fdroid.index.v2.FileV2; @@ -131,8 +132,11 @@ public class SwapService extends Service { private void updateRepo(@NonNull Peer peer, Repository repo) throws IOException, InterruptedException, SigningException, NotFoundException { - Uri uri = Uri.parse(repo.getAddress()).buildUpon().appendPath("index-v1.jar").build(); - FileV2 indexFile = FileV2.fromPath("/index-v1.jar"); + Uri uri = Uri.parse(repo.getAddress()) + .buildUpon() + .appendPath(IndexV1UpdaterKt.SIGNED_FILE_NAME) + .build(); + FileV2 indexFile = FileV2.fromPath("/" + IndexV1UpdaterKt.SIGNED_FILE_NAME); File swapJarFile = File.createTempFile("swap", "", getApplicationContext().getCacheDir()); try { diff --git a/app/src/full/java/org/fdroid/fdroid/nearby/TreeUriScannerIntentService.java b/app/src/full/java/org/fdroid/fdroid/nearby/TreeUriScannerIntentService.java index 53fc745b9..2c7e2b06b 100644 --- a/app/src/full/java/org/fdroid/fdroid/nearby/TreeUriScannerIntentService.java +++ b/app/src/full/java/org/fdroid/fdroid/nearby/TreeUriScannerIntentService.java @@ -38,6 +38,8 @@ import org.fdroid.fdroid.FDroidApp; import org.fdroid.fdroid.R; import org.fdroid.fdroid.Utils; import org.fdroid.index.SigningException; +import org.fdroid.index.v1.IndexV1UpdaterKt; +import org.fdroid.index.v1.IndexV1VerifierKt; import java.io.File; import java.io.IOException; @@ -129,7 +131,7 @@ public class TreeUriScannerIntentService extends IntentService { } /** - * Recursively search for {@link TreeUriUtils#SIGNED_FILE_NAME} starting + * Recursively search for {@link IndexV1UpdaterKt#SIGNED_FILE_NAME} starting * from the given directory, looking at files first before recursing into * directories. This is "depth last" since the index file is much more * likely to be shallow than deep, and there can be a lot of files to @@ -147,7 +149,7 @@ public class TreeUriScannerIntentService extends IntentService { if (documentFile.isDirectory()) { dirs.add(documentFile); } else if (!foundIndex) { - if (TreeUriUtils.SIGNED_FILE_NAME.equals(documentFile.getName())) { + if (IndexV1UpdaterKt.SIGNED_FILE_NAME.equals(documentFile.getName())) { registerRepo(documentFile); foundIndex = true; } @@ -159,7 +161,7 @@ public class TreeUriScannerIntentService extends IntentService { } /** - * For all files called {@link TreeUriUtils#SIGNED_FILE_NAME} found, check + * For all files called {@link IndexV1UpdaterKt#SIGNED_FILE_NAME} found, check * the JAR signature and read the fingerprint of the signing certificate. * The fingerprint is then used to find whether this local repo is a mirror * of an existing repo, or a totally new repo. In order to verify the @@ -184,10 +186,10 @@ public class TreeUriScannerIntentService extends IntentService { if (inputStream == null) { return; } - File destFile = File.createTempFile("dl-", TreeUriUtils.SIGNED_FILE_NAME, context.getCacheDir()); + File destFile = File.createTempFile("dl-", IndexV1UpdaterKt.SIGNED_FILE_NAME, context.getCacheDir()); FileUtils.copyInputStreamToFile(inputStream, destFile); JarFile jarFile = new JarFile(destFile, true); - JarEntry indexEntry = (JarEntry) jarFile.getEntry(TreeUriUtils.DATA_FILE_NAME); + JarEntry indexEntry = (JarEntry) jarFile.getEntry(IndexV1VerifierKt.DATA_FILE_NAME); IOUtils.readLines(jarFile.getInputStream(indexEntry)); Certificate certificate = getSigningCertFromJar(indexEntry); String fingerprint = Utils.calcFingerprint(certificate); diff --git a/app/src/full/java/org/fdroid/fdroid/nearby/TreeUriUtils.java b/app/src/full/java/org/fdroid/fdroid/nearby/TreeUriUtils.java deleted file mode 100644 index 47bc4cb9b..000000000 --- a/app/src/full/java/org/fdroid/fdroid/nearby/TreeUriUtils.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.fdroid.fdroid.nearby; - -/** - * @see Android 5.0 DocumentFile from tree URI - */ -public final class TreeUriUtils { - public static final String TAG = "TreeUriUtils"; - - static final String SIGNED_FILE_NAME = "index-v1.jar"; - static final String DATA_FILE_NAME = "index-v1.json"; - -} \ No newline at end of file diff --git a/app/src/main/java/org/fdroid/fdroid/views/ManageReposActivity.java b/app/src/main/java/org/fdroid/fdroid/views/ManageReposActivity.java index f98b5a3e9..7be133089 100644 --- a/app/src/main/java/org/fdroid/fdroid/views/ManageReposActivity.java +++ b/app/src/main/java/org/fdroid/fdroid/views/ManageReposActivity.java @@ -63,6 +63,7 @@ import org.fdroid.fdroid.Utils; import org.fdroid.fdroid.data.App; import org.fdroid.fdroid.data.DBHelper; import org.fdroid.fdroid.data.NewRepoConfig; +import org.fdroid.index.v1.IndexV1UpdaterKt; import java.io.File; import java.io.IOException; @@ -621,7 +622,7 @@ public class ManageReposActivity extends AppCompatActivity implements RepoAdapte } // check for v1 index as this is the last one we can still handle - final Uri uri = builder.appendPath("index-v1.jar").build(); + final Uri uri = builder.appendPath(IndexV1UpdaterKt.SIGNED_FILE_NAME).build(); try { final URL url = new URL(uri.toString()); diff --git a/app/src/test/java/org/fdroid/fdroid/RepoUrlsTest.java b/app/src/test/java/org/fdroid/fdroid/RepoUrlsTest.java index b0c7c02dd..e27297221 100644 --- a/app/src/test/java/org/fdroid/fdroid/RepoUrlsTest.java +++ b/app/src/test/java/org/fdroid/fdroid/RepoUrlsTest.java @@ -20,6 +20,7 @@ package org.fdroid.fdroid; import org.fdroid.fdroid.data.Apk; +import org.fdroid.index.v1.IndexV1UpdaterKt; import org.fdroid.index.v2.FileV1; import org.junit.Before; import org.junit.Test; @@ -125,8 +126,8 @@ public class RepoUrlsTest { @Test public void testIndexV1Urls() { - testReposWithFile("index-v1.jar", tr -> - Utils.getUri(tr.repoUrl, "index-v1.jar").toString() + testReposWithFile(IndexV1UpdaterKt.SIGNED_FILE_NAME, tr -> + Utils.getUri(tr.repoUrl, IndexV1UpdaterKt.SIGNED_FILE_NAME).toString() ); } diff --git a/app/src/testFull/java/org/fdroid/fdroid/nearby/LocalRepoKeyStoreTest.java b/app/src/testFull/java/org/fdroid/fdroid/nearby/LocalRepoKeyStoreTest.java index f66e83a06..1f6ebaa3b 100644 --- a/app/src/testFull/java/org/fdroid/fdroid/nearby/LocalRepoKeyStoreTest.java +++ b/app/src/testFull/java/org/fdroid/fdroid/nearby/LocalRepoKeyStoreTest.java @@ -6,6 +6,8 @@ import android.text.TextUtils; import org.apache.commons.io.IOUtils; import org.fdroid.fdroid.Utils; import org.fdroid.index.SigningException; +import org.fdroid.index.v1.IndexV1UpdaterKt; +import org.fdroid.index.v1.IndexV1VerifierKt; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; @@ -29,9 +31,6 @@ import static org.junit.Assert.assertNotNull; @RunWith(RobolectricTestRunner.class) public class LocalRepoKeyStoreTest { - private static final String SIGNED_FILE_NAME = "index.jar"; - private static final String DATA_FILE_NAME = "index.xml"; - @Test public void testSignZip() throws IOException, LocalRepoKeyStore.InitException, SigningException { Context context = ApplicationProvider.getApplicationContext(); @@ -39,7 +38,7 @@ public class LocalRepoKeyStoreTest { File xmlIndexJarUnsigned = File.createTempFile(getClass().getName(), "unsigned.jar"); BufferedOutputStream bo = new BufferedOutputStream(new FileOutputStream(xmlIndexJarUnsigned)); JarOutputStream jo = new JarOutputStream(bo); - JarEntry je = new JarEntry(DATA_FILE_NAME); + JarEntry je = new JarEntry(IndexV1VerifierKt.DATA_FILE_NAME); jo.putNextEntry(je); InputStream inputStream = getClass().getClassLoader().getResourceAsStream("all_fields_index-v1.json"); @@ -51,11 +50,11 @@ public class LocalRepoKeyStoreTest { Certificate localCert = localRepoKeyStore.getCertificate(); assertFalse(TextUtils.isEmpty(Utils.calcFingerprint(localCert))); - File xmlIndexJar = File.createTempFile(getClass().getName(), SIGNED_FILE_NAME); + File xmlIndexJar = File.createTempFile(getClass().getName(), IndexV1UpdaterKt.SIGNED_FILE_NAME); localRepoKeyStore.signZip(xmlIndexJarUnsigned, xmlIndexJar); JarFile jarFile = new JarFile(xmlIndexJar, true); - JarEntry indexEntry = (JarEntry) jarFile.getEntry(DATA_FILE_NAME); + JarEntry indexEntry = (JarEntry) jarFile.getEntry(IndexV1VerifierKt.DATA_FILE_NAME); byte[] data = IOUtils.toByteArray(jarFile.getInputStream(indexEntry)); assertEquals(6431, data.length); assertNotNull(TreeUriScannerIntentService.getSigningCertFromJar(indexEntry)); diff --git a/libs/database/src/dbTest/java/org/fdroid/index/IndexUpdaterTest.kt b/libs/database/src/dbTest/java/org/fdroid/index/IndexUpdaterTest.kt index 3929946e9..a20d3b6e2 100644 --- a/libs/database/src/dbTest/java/org/fdroid/index/IndexUpdaterTest.kt +++ b/libs/database/src/dbTest/java/org/fdroid/index/IndexUpdaterTest.kt @@ -2,6 +2,7 @@ package org.fdroid.index import androidx.test.ext.junit.runners.AndroidJUnit4 import org.fdroid.database.Repository +import org.fdroid.index.v2.SIGNED_FILE_NAME import org.junit.Test import org.junit.runner.RunWith import kotlin.test.assertEquals @@ -21,8 +22,8 @@ internal class IndexUpdaterTest { weight = 0, lastUpdated = 23L, ) - val uri = defaultRepoUriBuilder.getUri(repo, "entry.jar") - assertEquals("http://example.org/entry.jar", uri.toString()) + val uri = defaultRepoUriBuilder.getUri(repo, SIGNED_FILE_NAME) + assertEquals("http://example.org/$SIGNED_FILE_NAME", uri.toString()) } } diff --git a/libs/database/src/dbTest/java/org/fdroid/index/v1/IndexV1UpdaterTest.kt b/libs/database/src/dbTest/java/org/fdroid/index/v1/IndexV1UpdaterTest.kt index 17a1cd93b..cd8079bfb 100644 --- a/libs/database/src/dbTest/java/org/fdroid/index/v1/IndexV1UpdaterTest.kt +++ b/libs/database/src/dbTest/java/org/fdroid/index/v1/IndexV1UpdaterTest.kt @@ -191,8 +191,8 @@ internal class IndexV1UpdaterTest : DbTest() { @Suppress("DEPRECATION") private fun downloadIndex(repo: Repository, jar: String) { - val uri = Uri.parse("${repo.address}/index-v1.jar") - val indexFile = FileV2.fromPath("/index-v1.jar") + val uri = Uri.parse("${repo.address}/$SIGNED_FILE_NAME") + val indexFile = FileV2.fromPath("/$SIGNED_FILE_NAME") val jarFile = tmpFolder.newFile() assets.open(jar).use { inputStream -> diff --git a/libs/database/src/dbTest/java/org/fdroid/index/v2/IndexV2UpdaterTest.kt b/libs/database/src/dbTest/java/org/fdroid/index/v2/IndexV2UpdaterTest.kt index 312f3982d..337208df0 100644 --- a/libs/database/src/dbTest/java/org/fdroid/index/v2/IndexV2UpdaterTest.kt +++ b/libs/database/src/dbTest/java/org/fdroid/index/v2/IndexV2UpdaterTest.kt @@ -60,7 +60,7 @@ internal class IndexV2UpdaterTest : DbTest() { val repoId = repoDao.insertEmptyRepo("http://example.org") val repo = prepareUpdate( repoId = repoId, - entryPath = "diff-empty-min/entry.jar", + entryPath = "diff-empty-min/$SIGNED_FILE_NAME", jsonPath = "index-min-v2.json", indexFileV2 = TestDataEntry.emptyToMin.index ) @@ -80,7 +80,7 @@ internal class IndexV2UpdaterTest : DbTest() { val repoId = repoDao.insertEmptyRepo("http://example.org") val repo = prepareUpdate( repoId = repoId, - entryPath = "diff-empty-mid/entry.jar", + entryPath = "diff-empty-mid/$SIGNED_FILE_NAME", jsonPath = "index-mid-v2.json", indexFileV2 = TestDataEntry.emptyToMid.index ) @@ -95,7 +95,7 @@ internal class IndexV2UpdaterTest : DbTest() { val repoId = repoDao.insertEmptyRepo("http://example.org") val repo = prepareUpdate( repoId = repoId, - entryPath = "diff-empty-max/entry.jar", + entryPath = "diff-empty-max/$SIGNED_FILE_NAME", jsonPath = "index-max-v2.json", indexFileV2 = TestDataEntry.emptyToMax.index ) @@ -110,7 +110,7 @@ internal class IndexV2UpdaterTest : DbTest() { val repoId = streamIndexV2IntoDb("index-min-v2.json") val repo = prepareUpdate( repoId = repoId, - entryPath = "diff-empty-mid/entry.jar", + entryPath = "diff-empty-mid/$SIGNED_FILE_NAME", jsonPath = "diff-empty-mid/42.json", indexFileV2 = TestDataEntry.emptyToMid.diffs["42"] ?: fail() ) @@ -126,7 +126,7 @@ internal class IndexV2UpdaterTest : DbTest() { repoDao.updateRepository(repoId, CERTIFICATE) val repo = prepareUpdate( repoId = repoId, - entryPath = "diff-empty-min/entry.jar", + entryPath = "diff-empty-min/$SIGNED_FILE_NAME", jsonPath = "diff-empty-min/23.json", indexFileV2 = TestDataEntry.emptyToMin.diffs["23"] ?: fail() ) @@ -142,7 +142,7 @@ internal class IndexV2UpdaterTest : DbTest() { repoDao.updateRepository(repoId, CERTIFICATE) val repo = prepareUpdate( repoId = repoId, - entryPath = "diff-empty-max/entry.jar", + entryPath = "diff-empty-max/$SIGNED_FILE_NAME", jsonPath = "diff-empty-max/1337.json", indexFileV2 = TestDataEntry.emptyToMax.diffs["1337"] ?: fail() ) @@ -158,7 +158,7 @@ internal class IndexV2UpdaterTest : DbTest() { repoDao.updateRepository(repoId, CERTIFICATE) val repo = prepareUpdate( repoId = repoId, - entryPath = "diff-empty-min/entry.jar", + entryPath = "diff-empty-min/$SIGNED_FILE_NAME", jsonPath = "diff-empty-min/23.json", indexFileV2 = TestDataEntry.emptyToMin.diffs["23"] ?: fail() ) @@ -174,7 +174,7 @@ internal class IndexV2UpdaterTest : DbTest() { repoDao.updateRepository(repoId, CERTIFICATE) val repo = prepareUpdate( repoId = repoId, - entryPath = "diff-empty-min/entry.jar", + entryPath = "diff-empty-min/$SIGNED_FILE_NAME", jsonPath = "diff-empty-min/23.json", indexFileV2 = TestDataEntry.emptyToMin.diffs["23"] ?: fail() ) @@ -192,7 +192,7 @@ internal class IndexV2UpdaterTest : DbTest() { repoDao.updateRepository(newRepo) val repo = prepareUpdate( repoId = repoId, - entryPath = "diff-empty-min/entry.jar", + entryPath = "diff-empty-min/$SIGNED_FILE_NAME", jsonPath = "index-min-v2.json", indexFileV2 = TestDataEntry.emptyToMin.index ) @@ -206,7 +206,7 @@ internal class IndexV2UpdaterTest : DbTest() { val repoId = repoDao.insertEmptyRepo("http://example.org") val repo = prepareUpdate( repoId = repoId, - entryPath = "diff-empty-min/entry.jar", + entryPath = "diff-empty-min/$SIGNED_FILE_NAME", jsonPath = "index-min-v2.json", indexFileV2 = TestDataEntry.emptyToMin.index ) @@ -220,7 +220,7 @@ internal class IndexV2UpdaterTest : DbTest() { val repoId = repoDao.insertEmptyRepo("http://example.org") val repo = prepareUpdate( repoId = repoId, - entryPath = "diff-empty-min/entry.jar", + entryPath = "diff-empty-min/$SIGNED_FILE_NAME", jsonPath = "index-min-v2.json", indexFileV2 = TestDataEntry.emptyToMin.index ) @@ -238,7 +238,7 @@ internal class IndexV2UpdaterTest : DbTest() { val repoId = streamIndexV1IntoDb("index-min-v1.json") val repo = prepareUpdate( repoId = repoId, - entryPath = "diff-empty-mid/entry.jar", + entryPath = "diff-empty-mid/$SIGNED_FILE_NAME", jsonPath = "index-mid-v2.json", indexFileV2 = TestDataEntry.emptyToMid.index, ) @@ -261,7 +261,7 @@ internal class IndexV2UpdaterTest : DbTest() { val entryFile = tmpFolder.newFile() val indexFile = tmpFolder.newFile() val repo = repoDao.getRepository(repoId) ?: fail() - val entryUri = Uri.parse("${repo.address}/entry.jar") + val entryUri = Uri.parse("${repo.address}/$SIGNED_FILE_NAME") val indexUri = Uri.parse("${repo.address}/${indexFileV2.name.trimStart('/')}") assets.open(entryPath).use { inputStream -> diff --git a/libs/database/src/main/java/org/fdroid/index/v1/IndexV1Updater.kt b/libs/database/src/main/java/org/fdroid/index/v1/IndexV1Updater.kt index 43a7b9771..535342588 100644 --- a/libs/database/src/main/java/org/fdroid/index/v1/IndexV1Updater.kt +++ b/libs/database/src/main/java/org/fdroid/index/v1/IndexV1Updater.kt @@ -20,7 +20,7 @@ import org.fdroid.index.defaultRepoUriBuilder import org.fdroid.index.setIndexUpdateListener import org.fdroid.index.v2.FileV2 -internal const val SIGNED_FILE_NAME = "index-v1.jar" +public const val SIGNED_FILE_NAME: String = "index-v1.jar" public class IndexV1Updater( database: FDroidDatabase, diff --git a/libs/database/src/main/java/org/fdroid/index/v2/IndexV2Updater.kt b/libs/database/src/main/java/org/fdroid/index/v2/IndexV2Updater.kt index c7021e115..f13c54b80 100644 --- a/libs/database/src/main/java/org/fdroid/index/v2/IndexV2Updater.kt +++ b/libs/database/src/main/java/org/fdroid/index/v2/IndexV2Updater.kt @@ -20,7 +20,7 @@ import org.fdroid.index.defaultRepoUriBuilder import org.fdroid.index.parseEntry import org.fdroid.index.setIndexUpdateListener -internal const val SIGNED_FILE_NAME = "entry.jar" +public const val SIGNED_FILE_NAME: String = "entry.jar" public class IndexV2Updater( database: FDroidDatabase, diff --git a/libs/index/src/androidAndroidTest/kotlin/org/fdroid/index/v1/IndexV1CreatorTest.kt b/libs/index/src/androidAndroidTest/kotlin/org/fdroid/index/v1/IndexV1CreatorTest.kt index 0ea809f0d..bf41365af 100644 --- a/libs/index/src/androidAndroidTest/kotlin/org/fdroid/index/v1/IndexV1CreatorTest.kt +++ b/libs/index/src/androidAndroidTest/kotlin/org/fdroid/index/v1/IndexV1CreatorTest.kt @@ -33,7 +33,7 @@ internal class IndexV1CreatorTest { val indexCreator = IndexV1Creator(context.packageManager, repoDir, packageNames, repo) val indexV1 = indexCreator.createRepo() - val indexFile = File(repoDir, JSON_FILE_NAME) + val indexFile = File(repoDir, DATA_FILE_NAME) assertTrue(indexFile.exists()) val indexStr = indexFile.readBytes().decodeToString() assertEquals(indexV1, IndexParser.parseV1(indexStr)) diff --git a/libs/index/src/androidMain/kotlin/org/fdroid/index/v1/IndexV1Creator.kt b/libs/index/src/androidMain/kotlin/org/fdroid/index/v1/IndexV1Creator.kt index 1d1686e9f..8f4d2eed3 100644 --- a/libs/index/src/androidMain/kotlin/org/fdroid/index/v1/IndexV1Creator.kt +++ b/libs/index/src/androidMain/kotlin/org/fdroid/index/v1/IndexV1Creator.kt @@ -34,7 +34,7 @@ public class IndexV1Creator( public override fun createRepo(): IndexV1 { prepareIconFolders() val index = createIndex() - val indexJsonFile = File(repoDir, JSON_FILE_NAME) + val indexJsonFile = File(repoDir, DATA_FILE_NAME) indexJsonFile.outputStream().use { outputStream -> IndexParser.json.encodeToStream(index, outputStream) } diff --git a/libs/index/src/androidMain/kotlin/org/fdroid/index/v1/IndexV1Verifier.kt b/libs/index/src/androidMain/kotlin/org/fdroid/index/v1/IndexV1Verifier.kt index 14deca174..69364f352 100644 --- a/libs/index/src/androidMain/kotlin/org/fdroid/index/v1/IndexV1Verifier.kt +++ b/libs/index/src/androidMain/kotlin/org/fdroid/index/v1/IndexV1Verifier.kt @@ -5,7 +5,7 @@ import org.fdroid.index.SigningException import java.io.File import java.util.jar.Attributes -internal const val JSON_FILE_NAME = "index-v1.json" +public const val DATA_FILE_NAME: String = "index-v1.json" private const val SUPPORTED_DIGEST = "SHA1-Digest" /** @@ -26,7 +26,7 @@ public class IndexV1Verifier( expectedSigningFingerprint: String?, ) : JarIndexVerifier(jarFile, expectedSigningCertificate, expectedSigningFingerprint) { - protected override val jsonFileName: String = JSON_FILE_NAME + protected override val jsonFileName: String = DATA_FILE_NAME @Throws(SigningException::class) protected override fun checkAttributes(attributes: Attributes) { diff --git a/libs/index/src/androidMain/kotlin/org/fdroid/index/v2/EntryVerifier.kt b/libs/index/src/androidMain/kotlin/org/fdroid/index/v2/EntryVerifier.kt index 3feae6818..9311be05b 100644 --- a/libs/index/src/androidMain/kotlin/org/fdroid/index/v2/EntryVerifier.kt +++ b/libs/index/src/androidMain/kotlin/org/fdroid/index/v2/EntryVerifier.kt @@ -5,7 +5,7 @@ import org.fdroid.index.SigningException import java.io.File import java.util.jar.Attributes -private const val JSON_FILE_NAME = "entry.json" +public const val DATA_FILE_NAME: String = "entry.json" private val FORBIDDEN_DIGESTS = listOf( "MD5-Digest", "SHA1-Digest", @@ -29,7 +29,7 @@ public class EntryVerifier( expectedSigningFingerprint: String?, ) : JarIndexVerifier(jarFile, expectedSigningCertificate, expectedSigningFingerprint) { - protected override val jsonFileName: String = JSON_FILE_NAME + protected override val jsonFileName: String = DATA_FILE_NAME @Throws(SigningException::class) protected override fun checkAttributes(attributes: Attributes) { diff --git a/libs/index/src/androidTest/kotlin/org/fdroid/index/v1/IndexV1VerifierTest.kt b/libs/index/src/androidTest/kotlin/org/fdroid/index/v1/IndexV1VerifierTest.kt index 8cc8d9bd6..730bc035e 100644 --- a/libs/index/src/androidTest/kotlin/org/fdroid/index/v1/IndexV1VerifierTest.kt +++ b/libs/index/src/androidTest/kotlin/org/fdroid/index/v1/IndexV1VerifierTest.kt @@ -113,7 +113,7 @@ internal class IndexV1VerifierTest { assertEquals("foo\n", inputStream.readBytes().decodeToString()) } } - assertTrue(e.message!!.contains("index-v1.json")) + assertTrue(e.message!!.contains(DATA_FILE_NAME)) } @Test diff --git a/libs/index/src/androidTest/kotlin/org/fdroid/index/v2/EntryVerifierTest.kt b/libs/index/src/androidTest/kotlin/org/fdroid/index/v2/EntryVerifierTest.kt index 535a0e532..04680a4aa 100644 --- a/libs/index/src/androidTest/kotlin/org/fdroid/index/v2/EntryVerifierTest.kt +++ b/libs/index/src/androidTest/kotlin/org/fdroid/index/v2/EntryVerifierTest.kt @@ -120,7 +120,7 @@ internal class EntryVerifierTest { val e = assertFailsWith { verifier.getStreamAndVerify { } } - assertTrue(e.message!!.contains("entry.json")) + assertTrue(e.message!!.contains(DATA_FILE_NAME)) } @Test diff --git a/libs/index/src/commonTest/kotlin/org/fdroid/index/v2/EntryTest.kt b/libs/index/src/commonTest/kotlin/org/fdroid/index/v2/EntryTest.kt index 9b391fc19..a3d88dacc 100644 --- a/libs/index/src/commonTest/kotlin/org/fdroid/index/v2/EntryTest.kt +++ b/libs/index/src/commonTest/kotlin/org/fdroid/index/v2/EntryTest.kt @@ -19,17 +19,17 @@ internal class EntryTest { @Test fun testEmptyToMin() { - testEntryEquality("$assetPath/diff-empty-min/entry.json", TestDataEntry.emptyToMin) + testEntryEquality("$assetPath/diff-empty-min/$DATA_FILE_NAME", TestDataEntry.emptyToMin) } @Test fun testEmptyToMid() { - testEntryEquality("$assetPath/diff-empty-mid/entry.json", TestDataEntry.emptyToMid) + testEntryEquality("$assetPath/diff-empty-mid/$DATA_FILE_NAME", TestDataEntry.emptyToMid) } @Test fun testEmptyToMax() { - testEntryEquality("$assetPath/diff-empty-max/entry.json", TestDataEntry.emptyToMax) + testEntryEquality("$assetPath/diff-empty-max/$DATA_FILE_NAME", TestDataEntry.emptyToMax) } @Test