test(blossom-bridge): inline the share.yabu.me URL literally
Building the URL from extracted prefix/blob constants could mask a parser bug that splits the path the same way the test constructs it. Use the full URL from the bug report as a single literal so the test only agrees with the parser if the parser actually parses the URL correctly.
This commit is contained in:
+8
-4
@@ -135,13 +135,17 @@ class LocalBlossomCacheRedirectInterceptorTest {
|
|||||||
@Test
|
@Test
|
||||||
fun bridgeOnPicksRightmostShaWhenPathHasTwoHashes() {
|
fun bridgeOnPicksRightmostShaWhenPathHasTwoHashes() {
|
||||||
// share.yabu.me layout: <cache-prefix-sha>/<blob-sha>.<ext>
|
// share.yabu.me layout: <cache-prefix-sha>/<blob-sha>.<ext>
|
||||||
val prefix = "84b0c46ab699ac35eb2ca286470b85e081db2087cdef63932236c397417782f5"
|
|
||||||
val blob = "28fa4d999af6ae3e4e11bfc2727130ef1b3a13cc0f981e5a93c3996cb2f524e5"
|
|
||||||
val interceptor = LocalBlossomCacheRedirectInterceptor { true }
|
val interceptor = LocalBlossomCacheRedirectInterceptor { true }
|
||||||
val captured = mutableListOf<String>()
|
val captured = mutableListOf<String>()
|
||||||
val response = interceptor.intercept(fakeChain("https://share.yabu.me/$prefix/$blob.webp", captured))
|
val response =
|
||||||
|
interceptor.intercept(
|
||||||
|
fakeChain(
|
||||||
|
"https://share.yabu.me/84b0c46ab699ac35eb2ca286470b85e081db2087cdef63932236c397417782f5/28fa4d999af6ae3e4e11bfc2727130ef1b3a13cc0f981e5a93c3996cb2f524e5.webp",
|
||||||
|
captured,
|
||||||
|
),
|
||||||
|
)
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"http://127.0.0.1:24242/$blob.webp?xs=https%3A%2F%2Fshare.yabu.me%2F$prefix",
|
"http://127.0.0.1:24242/28fa4d999af6ae3e4e11bfc2727130ef1b3a13cc0f981e5a93c3996cb2f524e5.webp?xs=https%3A%2F%2Fshare.yabu.me%2F84b0c46ab699ac35eb2ca286470b85e081db2087cdef63932236c397417782f5",
|
||||||
captured.single(),
|
captured.single(),
|
||||||
)
|
)
|
||||||
response.close()
|
response.close()
|
||||||
|
|||||||
+11
-9
@@ -177,23 +177,25 @@ class MediaUrlContentExtTest {
|
|||||||
@Test
|
@Test
|
||||||
fun bridgeOnPicksRightmostShaWhenPathHasTwoHashes() {
|
fun bridgeOnPicksRightmostShaWhenPathHasTwoHashes() {
|
||||||
// share.yabu.me layout: <cache-prefix-sha>/<blob-sha>.<ext>
|
// share.yabu.me layout: <cache-prefix-sha>/<blob-sha>.<ext>
|
||||||
val prefix = "84b0c46ab699ac35eb2ca286470b85e081db2087cdef63932236c397417782f5"
|
val image =
|
||||||
val blob = "28fa4d999af6ae3e4e11bfc2727130ef1b3a13cc0f981e5a93c3996cb2f524e5"
|
MediaUrlImage(
|
||||||
val image = MediaUrlImage(url = "https://share.yabu.me/$prefix/$blob.webp", hash = null)
|
url = "https://share.yabu.me/84b0c46ab699ac35eb2ca286470b85e081db2087cdef63932236c397417782f5/28fa4d999af6ae3e4e11bfc2727130ef1b3a13cc0f981e5a93c3996cb2f524e5.webp",
|
||||||
|
hash = null,
|
||||||
|
)
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"blossom:$blob.webp?xs=https://share.yabu.me/$prefix",
|
"blossom:28fa4d999af6ae3e4e11bfc2727130ef1b3a13cc0f981e5a93c3996cb2f524e5.webp?xs=https://share.yabu.me/84b0c46ab699ac35eb2ca286470b85e081db2087cdef63932236c397417782f5",
|
||||||
image.toCoilModel(useLocalBlossomBridge = true),
|
image.toCoilModel(useLocalBlossomBridge = true),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun bridgeProfilePictureUrlPicksRightmostShaWhenPathHasTwoHashes() {
|
fun bridgeProfilePictureUrlPicksRightmostShaWhenPathHasTwoHashes() {
|
||||||
val prefix = "84b0c46ab699ac35eb2ca286470b85e081db2087cdef63932236c397417782f5"
|
|
||||||
val blob = "28fa4d999af6ae3e4e11bfc2727130ef1b3a13cc0f981e5a93c3996cb2f524e5"
|
|
||||||
val url = "https://share.yabu.me/$prefix/$blob.webp"
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"http://127.0.0.1:24242/$blob.webp?xs=https%3A%2F%2Fshare.yabu.me%2F$prefix",
|
"http://127.0.0.1:24242/28fa4d999af6ae3e4e11bfc2727130ef1b3a13cc0f981e5a93c3996cb2f524e5.webp?xs=https%3A%2F%2Fshare.yabu.me%2F84b0c46ab699ac35eb2ca286470b85e081db2087cdef63932236c397417782f5",
|
||||||
bridgeProfilePictureUrl(url, useBridge = true),
|
bridgeProfilePictureUrl(
|
||||||
|
"https://share.yabu.me/84b0c46ab699ac35eb2ca286470b85e081db2087cdef63932236c397417782f5/28fa4d999af6ae3e4e11bfc2727130ef1b3a13cc0f981e5a93c3996cb2f524e5.webp",
|
||||||
|
useBridge = true,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user