Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable10] Catch session unavailable exception #30347

Merged
merged 1 commit into from
Feb 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/private/Session/Memory.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function reopen() {
*/
private function validateSession() {
if ($this->sessionClosed) {
throw new Exception('Session has been closed - no further changes to the session are allowed');
throw new SessionNotAvailableException('Session has been closed - no further changes to the session are allowed');
}
}
}
11 changes: 11 additions & 0 deletions tests/lib/Session/CryptoSessionDataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
namespace Test\Session;

use OC\Session\CryptoSessionData;
use OCP\Session\Exceptions\SessionNotAvailableException;

class CryptoSessionDataTest extends Session {
/** @var \PHPUnit_Framework_MockObject_MockObject|\OCP\Security\ICrypto */
Expand Down Expand Up @@ -50,4 +51,14 @@ protected function setUp() {

$this->instance = new CryptoSessionData($this->wrappedSession, $this->crypto, 'PASS');
}

/**
* Thrown exception during session destruct/close should be handled silently
*/
protected function testDestructExceptionCatching() {
$instance = new CryptoSessionData($this->wrappedSession, $this->crypto, 'PASS');
$e = new SessionNotAvailableException();
$this->wrappedSession->expects($this->once())->method('set')->willThrowException($e);
$instance->__destruct();
}
}