correctly handle root favicons for non-default ports

This commit is contained in:
Athou
2026-08-02 07:26:44 +02:00
parent e404c9ce3b
commit 5d64e2f21e
2 changed files with 26 additions and 1 deletions

View File

@@ -47,6 +47,26 @@ class RootFaviconFetcherTest {
Assertions.assertTrue(result.mediaType().isCompatible(MediaType.valueOf(contentType)));
}
@Test
void testFetchUsesLinkWhenAvailableWithNonDefaultPort() throws Exception {
Feed feed = new Feed();
feed.setUrl("https://feeds.example.com:8000/feed");
feed.setLink("https://www.example.com:8000/blog");
byte[] iconBytes = new byte[1000];
String contentType = "image/x-icon";
HttpResult httpResult =
new HttpResult(iconBytes, contentType, null, null, null, Duration.ZERO);
Mockito.when(httpGetter.get("https://www.example.com:8000/favicon.ico"))
.thenReturn(httpResult);
Favicon result = faviconFetcher.fetch(feed);
Assertions.assertNotNull(result);
Assertions.assertEquals(iconBytes, result.icon());
Assertions.assertTrue(result.mediaType().isCompatible(MediaType.valueOf(contentType)));
}
@Test
void testFetchFallsBackToUrlWhenLinkIsNull() throws Exception {
Feed feed = new Feed();