[db] make repo certs non-null and remove repos without cert

historically, repos were added to the DB without much information and could stay in a broken state until manually removed. If a repo is updating, it should have a cert. So only repos that never did a single index update don't have a cert. Nowadays, this can not happen anymore as we get the repo and its cert before adding it to the DB. So whenever we update a repo, we know its certificate and fingerprint. Thus, this includes a DB migration removing all broken repos and making the certificate for repos in the DB non-null.
This commit is contained in:
Torsten Grote
2024-04-05 18:04:52 -03:00
committed by Hans-Christoph Steiner
parent 5cf22c5e06
commit fa65084e60
26 changed files with 2373 additions and 168 deletions

View File

@@ -27,25 +27,25 @@ internal class DbV2StreamReceiverTest {
timestamp = 42L,
)
every { db.getRepositoryDao() } returns mockk(relaxed = true)
dbV2StreamReceiver.receive(repoV2, 42L, "cert")
dbV2StreamReceiver.receive(repoV2, 42L)
// icon file without leading / does not pass
val repoV2NoSlash =
repoV2.copy(icon = mapOf("en" to FileV2(name = "foo", sha256 = "bar", size = 23L)))
assertFailsWith<SerializationException> {
dbV2StreamReceiver.receive(repoV2NoSlash, 42L, "cert")
dbV2StreamReceiver.receive(repoV2NoSlash, 42L)
}
// icon file without sha256 hash fails
val repoNoSha256 = repoV2.copy(icon = mapOf("en" to FileV2(name = "/foo", size = 23L)))
assertFailsWith<SerializationException> {
dbV2StreamReceiver.receive(repoNoSha256, 42L, "cert")
dbV2StreamReceiver.receive(repoNoSha256, 42L)
}
// icon file without size fails
val repoNoSize = repoV2.copy(icon = mapOf("en" to FileV2(name = "/foo", sha256 = "bar")))
assertFailsWith<SerializationException> {
dbV2StreamReceiver.receive(repoNoSize, 42L, "cert")
dbV2StreamReceiver.receive(repoNoSize, 42L)
}
}
}