diff options
Diffstat (limited to 'tests/lib/session')
-rw-r--r-- | tests/lib/session/cryptosessiondatatest.php | 53 | ||||
-rw-r--r-- | tests/lib/session/cryptowrappingtest.php | 73 | ||||
-rw-r--r-- | tests/lib/session/memory.php | 17 | ||||
-rw-r--r-- | tests/lib/session/session.php | 67 |
4 files changed, 0 insertions, 210 deletions
diff --git a/tests/lib/session/cryptosessiondatatest.php b/tests/lib/session/cryptosessiondatatest.php deleted file mode 100644 index ee6bcbf11c1..00000000000 --- a/tests/lib/session/cryptosessiondatatest.php +++ /dev/null @@ -1,53 +0,0 @@ -<?php -/** - * @author Joas Schilling <nickvergessen@owncloud.com> - * - * @copyright Copyright (c) 2015, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ - -namespace Test\Session; - -use OC\Session\CryptoSessionData; - -class CryptoSessionDataTest extends Session { - /** @var \PHPUnit_Framework_MockObject_MockObject|\OCP\Security\ICrypto */ - protected $crypto; - - /** @var \OCP\ISession */ - protected $wrappedSession; - - protected function setUp() { - parent::setUp(); - - $this->wrappedSession = new \OC\Session\Memory($this->getUniqueID()); - $this->crypto = $this->getMockBuilder('OCP\Security\ICrypto') - ->disableOriginalConstructor() - ->getMock(); - $this->crypto->expects($this->any()) - ->method('encrypt') - ->willReturnCallback(function ($input) { - return '#' . $input . '#'; - }); - $this->crypto->expects($this->any()) - ->method('decrypt') - ->willReturnCallback(function ($input) { - return substr($input, 1, -1); - }); - - $this->instance = new CryptoSessionData($this->wrappedSession, $this->crypto, 'PASS'); - } -} diff --git a/tests/lib/session/cryptowrappingtest.php b/tests/lib/session/cryptowrappingtest.php deleted file mode 100644 index e1fadbf933f..00000000000 --- a/tests/lib/session/cryptowrappingtest.php +++ /dev/null @@ -1,73 +0,0 @@ -<?php -/** - * @author Joas Schilling <nickvergessen@owncloud.com> - * - * @copyright Copyright (c) 2015, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ - -namespace Test\Session; - -use OC\Session\CryptoSessionData; -use Test\TestCase; - -class CryptoWrappingTest extends TestCase { - /** @var \PHPUnit_Framework_MockObject_MockObject|\OCP\Security\ICrypto */ - protected $crypto; - - /** @var \PHPUnit_Framework_MockObject_MockObject|\OCP\ISession */ - protected $wrappedSession; - - /** @var \OC\Session\CryptoSessionData */ - protected $instance; - - protected function setUp() { - parent::setUp(); - - $this->wrappedSession = $this->getMockBuilder('OCP\ISession') - ->disableOriginalConstructor() - ->getMock(); - $this->crypto = $this->getMockBuilder('OCP\Security\ICrypto') - ->disableOriginalConstructor() - ->getMock(); - $this->crypto->expects($this->any()) - ->method('encrypt') - ->willReturnCallback(function ($input) { - return $input; - }); - $this->crypto->expects($this->any()) - ->method('decrypt') - ->willReturnCallback(function ($input) { - return substr($input, 1, -1); - }); - - $this->instance = new CryptoSessionData($this->wrappedSession, $this->crypto, 'PASS'); - } - - public function testUnwrappingGet() { - $unencryptedValue = 'foobar'; - $encryptedValue = $this->crypto->encrypt($unencryptedValue); - - $this->wrappedSession->expects($this->once()) - ->method('get') - ->with('encrypted_session_data') - ->willReturnCallback(function () use ($encryptedValue) { - return $encryptedValue; - }); - - $this->assertSame($unencryptedValue, $this->wrappedSession->get('encrypted_session_data')); - } -} diff --git a/tests/lib/session/memory.php b/tests/lib/session/memory.php deleted file mode 100644 index 1ca4956c6ea..00000000000 --- a/tests/lib/session/memory.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -/** - * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com> - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ - -namespace Test\Session; - -class Memory extends Session { - protected function setUp() { - parent::setUp(); - $this->instance = new \OC\Session\Memory($this->getUniqueID()); - } -} diff --git a/tests/lib/session/session.php b/tests/lib/session/session.php deleted file mode 100644 index a1ed01b2ec8..00000000000 --- a/tests/lib/session/session.php +++ /dev/null @@ -1,67 +0,0 @@ -<?php - -/** - * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com> - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ - -namespace Test\Session; - -abstract class Session extends \Test\TestCase { - /** - * @var \OC\Session\Session - */ - protected $instance; - - protected function tearDown() { - $this->instance->clear(); - parent::tearDown(); - } - - public function testNotExistsEmpty() { - $this->assertFalse($this->instance->exists('foo')); - } - - public function testExistsAfterSet() { - $this->instance->set('foo', 1); - $this->assertTrue($this->instance->exists('foo')); - } - - public function testNotExistsAfterRemove() { - $this->instance->set('foo', 1); - $this->instance->remove('foo'); - $this->assertFalse($this->instance->exists('foo')); - } - - public function testGetNonExisting() { - $this->assertNull($this->instance->get('foo')); - } - - public function testGetAfterSet() { - $this->instance->set('foo', 'bar'); - $this->assertEquals('bar', $this->instance->get(('foo'))); - } - - public function testRemoveNonExisting() { - $this->assertFalse($this->instance->exists('foo')); - $this->instance->remove('foo'); - $this->assertFalse($this->instance->exists('foo')); - } - - public function testNotExistsAfterClear() { - $this->instance->set('foo', 1); - $this->instance->clear(); - $this->assertFalse($this->instance->exists('foo')); - } - - public function testArrayInterface() { - $this->assertFalse(isset($this->instance['foo'])); - $this->instance['foo'] = 'bar'; - $this->assertTrue(isset($this->instance['foo'])); - $this->assertEquals('bar', $this->instance['foo']); - unset($this->instance['foo']); - $this->assertFalse(isset($this->instance['foo'])); - } -} |