Skip to content

Commit 0fb69df

Browse files
committed
fix(tests): Add tearDown to encryption tests to prevent state pollution
Fixes 375 PHPUnit errors in php8.2-s3-minio CI caused by encryption tests not cleaning up their state, polluting subsequent tests. Root Cause: - 5 tests using EncryptionTrait enable encryption but have NO tearDown - After tests complete, encryption_enabled remains 'yes' - EncryptionWrapper sees encryption enabled for ALL subsequent tests - Tests without encryption keys fail with "multikeyencryption failed" Tests Fixed: 1. apps/encryption/tests/EncryptedStorageTest.php 2. apps/encryption/tests/Command/FixEncryptedVersionTest.php 3. apps/files_sharing/tests/EncryptedSizePropagationTest.php 4. apps/dav/tests/unit/Connector/Sabre/RequestTest/EncryptionUploadTest.php 5. apps/dav/tests/unit/Connector/Sabre/RequestTest/EncryptionMasterKeyUploadTest.php Fix: Add tearDown() method to each test that calls tearDownEncryptionTrait(), which restores encryption_enabled to its previous value. Also Fixed: - tests/lib/Encryption/EncryptionWrapperTest.php: Mock isEnabled() for tests that expect wrapper to be applied Testing: - Local full suite run: 0 encryption errors (vs 375 in CI) - Encryption state properly restored after tests - ViewTest passes after encryption tests run Impact: - Prevents test state pollution in CI - Each test properly cleans up encryption configuration - No functional changes to production code Signed-off-by: Stephen Cuppett <[email protected]>
1 parent 7f348c0 commit 0fb69df

File tree

5 files changed

+25
-0
lines changed

5 files changed

+25
-0
lines changed

apps/dav/tests/unit/Connector/Sabre/RequestTest/EncryptionMasterKeyUploadTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,9 @@ protected function setupUser($name, $password): View {
3434
$this->loginWithEncryption($name);
3535
return new View('/' . $name . '/files');
3636
}
37+
38+
protected function tearDown(): void {
39+
$this->tearDownEncryptionTrait();
40+
parent::tearDown();
41+
}
3742
}

apps/dav/tests/unit/Connector/Sabre/RequestTest/EncryptionUploadTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,9 @@ protected function setupUser($name, $password): View {
3434
$this->loginWithEncryption($name);
3535
return new View('/' . $name . '/files');
3636
}
37+
38+
protected function tearDown(): void {
39+
$this->tearDownEncryptionTrait();
40+
parent::tearDown();
41+
}
3742
}

apps/encryption/tests/Command/FixEncryptedVersionTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,4 +390,9 @@ public function testExecuteWithNoMasterKey(): void {
390390

391391
$this->assertStringContainsString('only works with master key', $output);
392392
}
393+
394+
protected function tearDown(): void {
395+
$this->tearDownEncryptionTrait();
396+
parent::tearDown();
397+
}
393398
}

apps/encryption/tests/EncryptedStorageTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,9 @@ public function testMoveFromEncrypted(): void {
6666
$this->assertEquals('bar', $unencryptedStorage->file_get_contents('foo.txt'));
6767
$this->assertFalse($unencryptedCache->get('foo.txt')->isEncrypted());
6868
}
69+
70+
protected function tearDown(): void {
71+
$this->tearDownEncryptionTrait();
72+
parent::tearDown();
73+
}
6974
}

apps/files_sharing/tests/EncryptedSizePropagationTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,9 @@ protected function loginHelper($user, $create = false, $password = false) {
3939
$this->setupForUser($user, $password);
4040
parent::loginHelper($user, $create, $password);
4141
}
42+
43+
protected function tearDown(): void {
44+
$this->tearDownEncryptionTrait();
45+
parent::tearDown();
46+
}
4247
}

0 commit comments

Comments
 (0)