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 #30623

Merged
Merged
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
15 changes: 11 additions & 4 deletions tests/lib/Session/CryptoSessionDataTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
/**
* @author Joas Schilling <nickvergessen@owncloud.com>
* @author Tom Needham <tom@owncloud.com>
*
* @copyright Copyright (c) 2018, ownCloud GmbH
* @license AGPL-3.0
Expand All @@ -23,6 +24,7 @@

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

class CryptoSessionDataTest extends Session {
/** @var \PHPUnit_Framework_MockObject_MockObject|\OCP\Security\ICrypto */
Expand All @@ -34,7 +36,7 @@ class CryptoSessionDataTest extends Session {
protected function setUp() {
parent::setUp();

$this->wrappedSession = new \OC\Session\Memory($this->getUniqueID());
$this->wrappedSession = new \OC\Session\Memory(static::getUniqueID());
$this->crypto = $this->getMockBuilder('OCP\Security\ICrypto')
->disableOriginalConstructor()
->getMock();
Expand All @@ -55,10 +57,15 @@ protected function setUp() {
/**
* Thrown exception during session destruct/close should be handled silently
*/
protected function testDestructExceptionCatching() {
$instance = new CryptoSessionData($this->wrappedSession, $this->crypto, 'PASS');
public function testDestructExceptionCatching() {
/** @var Memory | \PHPUnit_Framework_MockObject_MockObject $session */
$session = $this->getMockBuilder(Memory::class)
->disableOriginalConstructor()
->getMock();
$instance = new CryptoSessionData($session, $this->crypto, 'PASS');
$instance->set('test', 'test');
$e = new SessionNotAvailableException();
$this->wrappedSession->expects($this->once())->method('set')->willThrowException($e);
$session->expects($this->exactly(2))->method('set')->willThrowException($e);
$instance->__destruct();
}
}