|
|
|
|
@ -11,10 +11,7 @@ import org.koitharu.kotatsu.parsers.model.SortOrder
|
|
|
|
|
import org.koitharu.kotatsu.parsers.util.domain
|
|
|
|
|
import org.koitharu.kotatsu.parsers.util.medianOrNull
|
|
|
|
|
import org.koitharu.kotatsu.parsers.util.mimeType
|
|
|
|
|
import org.koitharu.kotatsu.test_util.isDistinct
|
|
|
|
|
import org.koitharu.kotatsu.test_util.isDistinctBy
|
|
|
|
|
import org.koitharu.kotatsu.test_util.isUrlAbsolute
|
|
|
|
|
import org.koitharu.kotatsu.test_util.maxDuplicates
|
|
|
|
|
import org.koitharu.kotatsu.test_util.*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ExtendWith(AuthCheckExtension::class)
|
|
|
|
|
@ -105,9 +102,9 @@ internal class MangaParserTest {
|
|
|
|
|
"Chapters are not distinct by number: ${c.maxDuplicates { it.number to it.branch }} for $publicUrl"
|
|
|
|
|
}
|
|
|
|
|
assert(c.all { it.source == source })
|
|
|
|
|
checkImageRequest(coverUrl, publicUrl)
|
|
|
|
|
checkImageRequest(coverUrl, source)
|
|
|
|
|
largeCoverUrl?.let {
|
|
|
|
|
checkImageRequest(it, publicUrl)
|
|
|
|
|
checkImageRequest(it, source)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -129,7 +126,7 @@ internal class MangaParserTest {
|
|
|
|
|
val pageUrl = parser.getPageUrl(page)
|
|
|
|
|
assert(pageUrl.isNotEmpty())
|
|
|
|
|
assert(pageUrl.isUrlAbsolute())
|
|
|
|
|
checkImageRequest(pageUrl, page.referer)
|
|
|
|
|
checkImageRequest(pageUrl, page.source)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ParameterizedTest(name = "{index}|favicon|{0}")
|
|
|
|
|
@ -145,7 +142,7 @@ internal class MangaParserTest {
|
|
|
|
|
}
|
|
|
|
|
val favicon = favicons.find(24)
|
|
|
|
|
checkNotNull(favicon)
|
|
|
|
|
checkImageRequest(favicon.url, favicons.referer)
|
|
|
|
|
checkImageRequest(favicon.url, source)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ParameterizedTest(name = "{index}|domain|{0}")
|
|
|
|
|
@ -157,7 +154,7 @@ internal class MangaParserTest {
|
|
|
|
|
.host(defaultDomain)
|
|
|
|
|
.scheme("https")
|
|
|
|
|
.toString()
|
|
|
|
|
val response = context.doRequest(url, extraHeaders = parser.headers)
|
|
|
|
|
val response = context.doRequest(url, source)
|
|
|
|
|
val realUrl = response.request.url
|
|
|
|
|
val realDomain = realUrl.topPrivateDomain()
|
|
|
|
|
val realHost = realUrl.host
|
|
|
|
|
@ -189,11 +186,11 @@ internal class MangaParserTest {
|
|
|
|
|
assert(item.publicUrl.isUrlAbsolute())
|
|
|
|
|
}
|
|
|
|
|
val testItem = list.random()
|
|
|
|
|
checkImageRequest(testItem.coverUrl, testItem.publicUrl)
|
|
|
|
|
checkImageRequest(testItem.coverUrl, testItem.source)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private suspend fun checkImageRequest(url: String, referer: String?) {
|
|
|
|
|
context.doRequest(url, referer).use {
|
|
|
|
|
private suspend fun checkImageRequest(url: String, source: MangaSource) {
|
|
|
|
|
context.doRequest(url, source).use {
|
|
|
|
|
assert(it.isSuccessful) { "Request failed: ${it.code}(${it.message}): $url" }
|
|
|
|
|
assert(it.mimeType?.startsWith("image/") == true) {
|
|
|
|
|
"Wrong response mime type: ${it.mimeType}"
|
|
|
|
|
|