Commit a2aeb0bc authored by catch's avatar catch
Browse files

task: #3633167 Add test coverage for SA-CORE-2026-008

By: xjm
By: larowlan
By: longwave
By: mcdruid
By: phenaproxima
By: seanb
By: smustgrave
(cherry picked from commit 1e502a34)
parent c1f39e82
Loading
Loading
Loading
Loading
Loading
+7 −3
Changes for core/modules/media/tests/src/Unit/UrlResolverTest.php: 7 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
use GuzzleHttp\Psr7\Response;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\TestWith;

/**
 * Tests the oEmbed URL resolver.
@@ -66,7 +67,10 @@ public function discoverResourceUrl($url): string|false {
  /**
   * Tests that discoverResourceUrl parses HTML responses.
   */
  public function testDiscoverResourceUrlParsesHtml(): void {
  #[TestWith(['https://example.com/some-page', 'https://example.com/oembed?url=test'])]
  #[TestWith(['https://evil.com/some-page', FALSE])]
  #[TestWith(['look-ma-no-host', FALSE])]
  public function testDiscoverResourceUrlParsesHtml(string $url, string|bool $expected): void {
    $html_with_oembed = <<<HTML
<!DOCTYPE html>
<html>
@@ -82,9 +86,9 @@ public function testDiscoverResourceUrlParsesHtml(): void {
    $client = new Client(['handler' => HandlerStack::create($mock_handler)]);

    $url_resolver = $this->createTestableUrlResolver($client);
    $result = $url_resolver->discoverResourceUrl('https://example.com/some-page');
    $result = $url_resolver->discoverResourceUrl($url);

    $this->assertSame('https://example.com/oembed?url=test', $result);
    $this->assertSame($expected, $result);
  }

  /**