[db] Reject invalid URIs when adding repos

This commit is contained in:
Torsten Grote
2023-08-24 16:19:18 +02:00
committed by Michael Pöhn
parent aaa4b56a9d
commit 40c71e4b06
2 changed files with 26 additions and 1 deletions

View File

@@ -107,6 +107,26 @@ internal class RepoAdderTest {
}
}
@Test
fun testInvalidUri() = runTest {
repoAdder.fetchRepositoryInt("irc://example.org/repo/") // invalid scheme
repoAdder.addRepoState.test {
val state1 = awaitItem()
assertIs<AddRepoError>(state1)
assertEquals(INVALID_INDEX, state1.errorType)
}
repoAdder.abortAddingRepo()
repoAdder.fetchRepositoryInt("https://%-") // invalid hostname
repoAdder.addRepoState.test {
val state1 = awaitItem()
assertIs<AddRepoError>(state1)
assertEquals(INVALID_INDEX, state1.errorType)
}
}
@Test
fun testAddingMinRepo() = runTest {
val url = "https://example.org/repo/"