Skip to content

Commit 3294b9c

Browse files
test(Session): adjust CryptoWrappingTest attributes and docbock
Signed-off-by: Josh <[email protected]>
1 parent 4feb4ca commit 3294b9c

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

tests/lib/Session/CryptoWrappingTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,25 @@
1414
use OCP\IRequest;
1515
use OCP\Security\ICrypto;
1616
use OCP\Security\ISecureRandom;
17+
use PHPUnit\Framework\Attributes\CoversClass;
18+
use PHPUnit\Framework\Attributes\UsesClass;
1719
use PHPUnit\Framework\MockObject\MockObject;
1820
use Test\TestCase;
1921

2022
/**
21-
* Test cases for CryptoWrapper+CryptoSessionData wrapping logic.
22-
* - Focuses on correct session wrapping.
23-
* - Ensures passphrase handling (cookie, random generation).
24-
* - Validates integration and robustness.
23+
* Unit tests for CryptoWrapper, focusing on session wrapping logic,
24+
* passphrase handling (cookie and generation), and integration with
25+
* CryptoSessionData. Ensures robust construction and non-duplication
26+
* of crypto-wrapped sessions.
2527
*
26-
* @see Test\Session\CryptoSessionDataTest for crypto storage testing logic.
28+
* Only wrapper-specific crypto behavior is tested here;
29+
* core session encryption contract is covered in CryptoSessionDataTest.
30+
*
31+
* @see Test\Session\CryptoSessionDataTest For crypto storage testing logic.
2732
*/
2833
#[CoversClass(CryptoWrapper::class)]
34+
#[UsesClass(Memory::class)]
35+
#[UsesClass(CryptoSessionData::class)]
2936
class CryptoWrappingTest extends TestCase {
3037
private const DUMMY_PASSPHRASE = 'dummyPassphrase';
3138
private const COOKIE_PASSPHRASE = 'cookiePassphrase';
@@ -47,7 +54,6 @@ protected function setUp(): void {
4754
/**
4855
* Ensure wrapSession returns a CryptoSessionData when passed a basic session.
4956
*/
50-
#[CoversMethod(CryptoWrapper::class, 'wrapSession')]
5157
public function testWrapSessionReturnsCryptoSessionData(): void {
5258
$generatedPassphrase128 = str_pad(self::GENERATED_PASSPHRASE, 128, '_' . __FUNCTION__, STR_PAD_RIGHT);
5359
$this->random->method('generate')->willReturn($generatedPassphrase128);
@@ -66,7 +72,6 @@ public function testWrapSessionReturnsCryptoSessionData(): void {
6672
/**
6773
* Ensure wrapSession returns the same instance if already wrapped.
6874
*/
69-
#[CoversMethod(CryptoWrapper::class, 'wrapSession')]
7075
public function testWrapSessionDoesNotDoubleWrap(): void {
7176
$alreadyWrapped = $this->createMock(CryptoSessionData::class);
7277

@@ -79,7 +84,6 @@ public function testWrapSessionDoesNotDoubleWrap(): void {
7984
/**
8085
* Ensure a passphrase is generated and stored if no cookie is present.
8186
*/
82-
#[CoversMethod(CryptoWrapper::class, '__construct__')]
8387
public function testPassphraseGeneratedIfNoCookie(): void {
8488
$expectedPassphrase = str_pad(self::GENERATED_PASSPHRASE, 128, '_' . __FUNCTION__, STR_PAD_RIGHT);
8589
$this->random->expects($this->once())->method('generate')->with(128)->willReturn($expectedPassphrase);
@@ -98,7 +102,6 @@ public function testPassphraseGeneratedIfNoCookie(): void {
98102
/**
99103
* Ensure only the passphrase from cookie is used if present.
100104
*/
101-
#[CoversMethod(CryptoWrapper::class, '__construct__')]
102105
public function testPassphraseReusedIfCookiePresent(): void {
103106
$cookieVal = self::COOKIE_PASSPHRASE;
104107
$this->request->method('getCookie')->willReturn($cookieVal);
@@ -116,7 +119,6 @@ public function testPassphraseReusedIfCookiePresent(): void {
116119
/**
117120
* Ensure wrapSession throws if passed a non-ISession object (robustness).
118121
*/
119-
#[CoversMethod(CryptoWrapper::class, 'wrapSession')]
120122
public function testWrapSessionThrowsTypeErrorOnInvalidInput(): void {
121123
$cryptoWrapper = new CryptoWrapper($this->crypto, $this->random, $this->request);
122124
$this->expectException(\TypeError::class);
@@ -126,8 +128,6 @@ public function testWrapSessionThrowsTypeErrorOnInvalidInput(): void {
126128
/**
127129
* Full integration: wrap, set, get, flush, and encrypted blob.
128130
*/
129-
#[CoversMethod(CryptoWrapper::class, 'wrapSession')]
130-
#[CoversClass(CryptoSessionData::class)]
131131
public function testIntegrationWrapSetAndGet(): void {
132132
$keyName = 'someKey';
133133
$unencryptedValue = 'foobar';

0 commit comments

Comments
 (0)