fix: Remove unneccesary etag check

Signed-off-by: Marcel Müller <marcel-mueller@gmx.de>
pull/52546/head
Marcel Müller 5 months ago
parent f26dc79480
commit 1addd35b78
  1. 12
      core/Controller/NavigationController.php
  2. 31
      tests/Core/Controller/NavigationControllerTest.php

@ -47,12 +47,8 @@ class NavigationController extends OCSController {
$navigation = $this->rewriteToAbsoluteUrls($navigation);
}
$navigation = array_values($navigation);
$etag = $this->generateETag($navigation);
if ($this->request->getHeader('If-None-Match') === $etag) {
return new DataResponse([], Http::STATUS_NOT_MODIFIED);
}
$response = new DataResponse($navigation);
$response->setETag($etag);
$response->setETag($this->generateETag($navigation));
return $response;
}
@ -74,12 +70,8 @@ class NavigationController extends OCSController {
$navigation = $this->rewriteToAbsoluteUrls($navigation);
}
$navigation = array_values($navigation);
$etag = $this->generateETag($navigation);
if ($this->request->getHeader('If-None-Match') === $etag) {
return new DataResponse([], Http::STATUS_NOT_MODIFIED);
}
$response = new DataResponse($navigation);
$response->setETag($etag);
$response->setETag($this->generateETag($navigation));
return $response;
}

@ -7,7 +7,6 @@
namespace Tests\Core\Controller;
use OC\Core\Controller\NavigationController;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
use OCP\INavigationManager;
use OCP\IRequest;
@ -103,34 +102,4 @@ class NavigationControllerTest extends TestCase {
$this->assertEquals('/core/img/settings.svg', $actual->getData()[0]['icon']);
}
}
public function testGetAppNavigationEtagMatch(): void {
$navigation = [ ['id' => 'files', 'href' => '/index.php/apps/files', 'icon' => 'icon' ] ];
$this->request->expects($this->once())
->method('getHeader')
->with('If-None-Match')
->willReturn(md5(json_encode($navigation)));
$this->navigationManager->expects($this->once())
->method('getAll')
->with('link')
->willReturn($navigation);
$actual = $this->controller->getAppsNavigation();
$this->assertInstanceOf(DataResponse::class, $actual);
$this->assertEquals(Http::STATUS_NOT_MODIFIED, $actual->getStatus());
}
public function testGetSettingsNavigationEtagMatch(): void {
$navigation = [ ['id' => 'logout', 'href' => '/index.php/apps/files', 'icon' => 'icon' ] ];
$this->request->expects($this->once())
->method('getHeader')
->with('If-None-Match')
->willReturn(md5(json_encode([ ['id' => 'logout', 'href' => 'logout', 'icon' => 'icon' ] ])));
$this->navigationManager->expects($this->once())
->method('getAll')
->with('settings')
->willReturn($navigation);
$actual = $this->controller->getSettingsNavigation();
$this->assertInstanceOf(DataResponse::class, $actual);
$this->assertEquals(Http::STATUS_NOT_MODIFIED, $actual->getStatus());
}
}

Loading…
Cancel
Save