-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Check strict cookies for image proxy
Signed-off-by: Christoph Wurst <[email protected]>
- Loading branch information
1 parent
fdcf9a1
commit a423dc8
Showing
2 changed files
with
41 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* @author Christoph Wurst <[email protected]> | ||
* | ||
|
@@ -156,11 +158,41 @@ public function testRedirectInvalidUrl() { | |
$this->controller->redirect('ftps://example.com'); | ||
} | ||
|
||
public function testProxy() { | ||
public function testProxyWithoutCookies(): void { | ||
$src = 'http://example.com'; | ||
$httpResponse = $this->createMock(IResponse::class); | ||
$content = 'π΅π΅π΅'; | ||
$this->session->expects($this->once()) | ||
->method('close'); | ||
$client = $this->getMockBuilder(IClient::class)->getMock(); | ||
$this->clientService->expects(self::never()) | ||
->method('newClient') | ||
->willReturn($client); | ||
$unexpected = new ProxyDownloadResponse( | ||
$content, | ||
$src, | ||
'application/octet-stream' | ||
); | ||
$this->controller = new ProxyController( | ||
$this->appName, | ||
$this->request, | ||
$this->urlGenerator, | ||
$this->session, | ||
$this->clientService, | ||
$this->logger | ||
); | ||
|
||
$response = $this->controller->proxy($src); | ||
|
||
$this->assertNotEquals($unexpected, $response); | ||
} | ||
|
||
public function testProxy(): void { | ||
$src = 'http://example.com'; | ||
$httpResponse = $this->createMock(IResponse::class); | ||
$content = 'π΅π΅π΅'; | ||
$this->request->expects(self::once()) | ||
->method('passesStrictCookieCheck') | ||
->willReturn(true); | ||
$this->session->expects($this->once()) | ||
->method('close'); | ||
$client = $this->getMockBuilder(IClient::class)->getMock(); | ||
|