aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/Session
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/Session')
-rw-r--r--tests/lib/Session/CryptoSessionDataTest.php29
-rw-r--r--tests/lib/Session/CryptoWrappingTest.php28
-rw-r--r--tests/lib/Session/MemoryTest.php18
-rw-r--r--tests/lib/Session/Session.php23
4 files changed, 38 insertions, 60 deletions
diff --git a/tests/lib/Session/CryptoSessionDataTest.php b/tests/lib/Session/CryptoSessionDataTest.php
index 10bc62e099c..a30a3297094 100644
--- a/tests/lib/Session/CryptoSessionDataTest.php
+++ b/tests/lib/Session/CryptoSessionDataTest.php
@@ -1,40 +1,29 @@
<?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/>
- *
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Session;
use OC\Session\CryptoSessionData;
+use OC\Session\Memory;
+use OCP\ISession;
use OCP\Security\ICrypto;
class CryptoSessionDataTest extends Session {
- /** @var \PHPUnit\Framework\MockObject\MockObject|\OCP\Security\ICrypto */
+ /** @var \PHPUnit\Framework\MockObject\MockObject|ICrypto */
protected $crypto;
- /** @var \OCP\ISession */
+ /** @var ISession */
protected $wrappedSession;
protected function setUp(): void {
parent::setUp();
- $this->wrappedSession = new \OC\Session\Memory($this->getUniqueID());
+ $this->wrappedSession = new Memory();
$this->crypto = $this->createMock(ICrypto::class);
$this->crypto->expects($this->any())
->method('encrypt')
diff --git a/tests/lib/Session/CryptoWrappingTest.php b/tests/lib/Session/CryptoWrappingTest.php
index b8635b99120..2bc09e0903a 100644
--- a/tests/lib/Session/CryptoWrappingTest.php
+++ b/tests/lib/Session/CryptoWrappingTest.php
@@ -1,35 +1,23 @@
<?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/>
- *
+ * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Session;
use OC\Session\CryptoSessionData;
use OCP\ISession;
+use OCP\Security\ICrypto;
use Test\TestCase;
class CryptoWrappingTest extends TestCase {
- /** @var \PHPUnit\Framework\MockObject\MockObject|\OCP\Security\ICrypto */
+ /** @var \PHPUnit\Framework\MockObject\MockObject|ICrypto */
protected $crypto;
- /** @var \PHPUnit\Framework\MockObject\MockObject|\OCP\ISession */
+ /** @var \PHPUnit\Framework\MockObject\MockObject|ISession */
protected $wrappedSession;
/** @var \OC\Session\CryptoSessionData */
@@ -61,7 +49,7 @@ class CryptoWrappingTest extends TestCase {
$this->instance = new CryptoSessionData($this->wrappedSession, $this->crypto, 'PASS');
}
- public function testUnwrappingGet() {
+ public function testUnwrappingGet(): void {
$unencryptedValue = 'foobar';
$encryptedValue = $this->crypto->encrypt($unencryptedValue);
diff --git a/tests/lib/Session/MemoryTest.php b/tests/lib/Session/MemoryTest.php
index fab7292ae00..40977f1f3fb 100644
--- a/tests/lib/Session/MemoryTest.php
+++ b/tests/lib/Session/MemoryTest.php
@@ -1,23 +1,25 @@
<?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.
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Session;
+use OC\Session\Memory;
+use OCP\Session\Exceptions\SessionNotAvailableException;
+
class MemoryTest extends Session {
protected function setUp(): void {
parent::setUp();
- $this->instance = new \OC\Session\Memory($this->getUniqueID());
+ $this->instance = new Memory();
}
-
- public function testThrowsExceptionOnGetId() {
- $this->expectException(\OCP\Session\Exceptions\SessionNotAvailableException::class);
+
+ public function testThrowsExceptionOnGetId(): void {
+ $this->expectException(SessionNotAvailableException::class);
$this->instance->getId();
}
diff --git a/tests/lib/Session/Session.php b/tests/lib/Session/Session.php
index 0c947b8d302..1e2e9370825 100644
--- a/tests/lib/Session/Session.php
+++ b/tests/lib/Session/Session.php
@@ -1,10 +1,9 @@
<?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.
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Session;
@@ -20,43 +19,43 @@ abstract class Session extends \Test\TestCase {
parent::tearDown();
}
- public function testNotExistsEmpty() {
+ public function testNotExistsEmpty(): void {
$this->assertFalse($this->instance->exists('foo'));
}
- public function testExistsAfterSet() {
+ public function testExistsAfterSet(): void {
$this->instance->set('foo', 1);
$this->assertTrue($this->instance->exists('foo'));
}
- public function testNotExistsAfterRemove() {
+ public function testNotExistsAfterRemove(): void {
$this->instance->set('foo', 1);
$this->instance->remove('foo');
$this->assertFalse($this->instance->exists('foo'));
}
- public function testGetNonExisting() {
+ public function testGetNonExisting(): void {
$this->assertNull($this->instance->get('foo'));
}
- public function testGetAfterSet() {
+ public function testGetAfterSet(): void {
$this->instance->set('foo', 'bar');
$this->assertEquals('bar', $this->instance->get(('foo')));
}
- public function testRemoveNonExisting() {
+ public function testRemoveNonExisting(): void {
$this->assertFalse($this->instance->exists('foo'));
$this->instance->remove('foo');
$this->assertFalse($this->instance->exists('foo'));
}
- public function testNotExistsAfterClear() {
+ public function testNotExistsAfterClear(): void {
$this->instance->set('foo', 1);
$this->instance->clear();
$this->assertFalse($this->instance->exists('foo'));
}
- public function testArrayInterface() {
+ public function testArrayInterface(): void {
$this->assertFalse(isset($this->instance['foo']));
$this->instance['foo'] = 'bar';
$this->assertTrue(isset($this->instance['foo']));