Skip to content

Commit

Permalink
Cancel PR #37405, remove regression code
Browse files Browse the repository at this point in the history
Signed-off-by: Gaspard d'Hautefeuille <github@dhautefeuille.eu>
  • Loading branch information
HLFH authored and skjnldsv committed Feb 22, 2024
1 parent c8704b4 commit 7418c3e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
4 changes: 2 additions & 2 deletions core/Controller/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
*/
namespace OC\Core\Controller;

use OC\AppFramework\Http\Request;
use OC\Authentication\Login\Chain;
use OC\Authentication\Login\LoginData;
use OC\Authentication\WebAuthn\Manager as WebAuthnManager;
Expand Down Expand Up @@ -105,8 +106,7 @@ public function logout() {
$this->session->set('clearingExecutionContexts', '1');
$this->session->close();

if ($this->request->getServerProtocol() === 'https') {
// This feature is available only in secure contexts
if (!$this->request->isUserAgent([Request::USER_AGENT_CHROME, Request::USER_AGENT_ANDROID_MOBILE_CHROME])) {
$response->addHeader('Clear-Site-Data', '"cache", "storage"');
}

Expand Down
29 changes: 25 additions & 4 deletions tests/Core/Controller/LoginControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,9 @@ public function testLogoutWithoutToken() {
->with('nc_token')
->willReturn(null);
$this->request
->method('getServerProtocol')
->willReturn('https');
->expects($this->once())
->method('isUserAgent')
->willReturn(false);
$this->config
->expects($this->never())
->method('deleteUserValue');
Expand All @@ -159,6 +160,26 @@ public function testLogoutWithoutToken() {
$this->assertEquals($expected, $this->loginController->logout());
}

public function testLogoutNoClearSiteData() {
$this->request
->expects($this->once())
->method('getCookie')
->with('nc_token')
->willReturn(null);
$this->request
->expects($this->once())
->method('isUserAgent')
->willReturn(true);
$this->urlGenerator
->expects($this->once())
->method('linkToRouteAbsolute')
->with('core.login.showLoginForm')
->willReturn('/login');

$expected = new RedirectResponse('/login');
$this->assertEquals($expected, $this->loginController->logout());
}

public function testLogoutWithToken() {
$this->request
->expects($this->once())
Expand All @@ -167,8 +188,8 @@ public function testLogoutWithToken() {
->willReturn('MyLoginToken');
$this->request
->expects($this->once())
->method('getServerProtocol')
->willReturn('https');
->method('isUserAgent')
->willReturn(false);
$user = $this->createMock(IUser::class);
$user
->expects($this->once())
Expand Down

0 comments on commit 7418c3e

Please sign in to comment.