diff options
author | Marcel Müller <marcel-mueller@gmx.de> | 2025-04-29 22:14:25 +0200 |
---|---|---|
committer | Marcel Müller <marcel-mueller@gmx.de> | 2025-04-29 23:15:50 +0200 |
commit | 1addd35b7831d42c9cd0a8c6e50b08a065fd5784 (patch) | |
tree | aa35346bdbba5974dbc2385f9e2f9439e2014337 | |
parent | f26dc79480e75b0dc2f80c9dfc08fada0f6beb68 (diff) | |
download | nextcloud-server-1addd35b7831d42c9cd0a8c6e50b08a065fd5784.tar.gz nextcloud-server-1addd35b7831d42c9cd0a8c6e50b08a065fd5784.zip |
fix: Remove unneccesary etag check
Signed-off-by: Marcel Müller <marcel-mueller@gmx.de>
-rw-r--r-- | core/Controller/NavigationController.php | 12 | ||||
-rw-r--r-- | tests/Core/Controller/NavigationControllerTest.php | 31 |
2 files changed, 2 insertions, 41 deletions
diff --git a/core/Controller/NavigationController.php b/core/Controller/NavigationController.php index de72e412945..5fc929b4eb4 100644 --- a/core/Controller/NavigationController.php +++ b/core/Controller/NavigationController.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; } diff --git a/tests/Core/Controller/NavigationControllerTest.php b/tests/Core/Controller/NavigationControllerTest.php index 7ebfbc139cd..acbee5a72f0 100644 --- a/tests/Core/Controller/NavigationControllerTest.php +++ b/tests/Core/Controller/NavigationControllerTest.php @@ -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()); - } } |