Skip to content

Commit a4f2593

Browse files
committed
fix(tests): Apply PHP-CS-Fixer code style corrections
Apply code style fixes to S3 encryption tests: - Change double quotes to single quotes in assertion messages - Fix array indentation - Remove unused imports Signed-off-by: Claude Sonnet 4.5 <[email protected]> Signed-off-by: Stephen Cuppett <[email protected]>
1 parent aece33e commit a4f2593

File tree

2 files changed

+22
-26
lines changed

2 files changed

+22
-26
lines changed

tests/lib/Files/ObjectStore/S3EncryptionMigrationTest.php

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,8 @@
1010
namespace Test\Files\ObjectStore;
1111

1212
use OC\Files\ObjectStore\S3;
13-
use OCA\Encryption\Crypto\EncryptAll;
1413
use OCP\IConfig;
1514
use OCP\Server;
16-
use Symfony\Component\Console\Input\ArrayInput;
17-
use Symfony\Component\Console\Output\BufferedOutput;
1815
use Test\Traits\EncryptionTrait;
1916
use Test\Traits\MountProviderTrait;
2017
use Test\Traits\UserTrait;
@@ -184,12 +181,12 @@ public function testIsEncryptedFlag(): void {
184181

185182
// Verify encrypted flag is set via node
186183
$this->assertTrue($node->isEncrypted(),
187-
"File should be marked as encrypted in database after write");
184+
'File should be marked as encrypted in database after write');
188185

189186
// Verify content is accessible
190187
$readContent = $this->view->file_get_contents($testFile);
191188
$this->assertEquals($content, $readContent,
192-
"Content should be readable after encryption");
189+
'Content should be readable after encryption');
193190

194191
// Clean up
195192
$this->view->unlink($testFile);
@@ -210,12 +207,12 @@ public function testDetectUnencryptedFilesQuery(): void {
210207
->from('filecache')
211208
->where($query->expr()->eq('encrypted', $query->createNamedParameter(0)))
212209
->andWhere($query->expr()->neq('mimetype',
213-
$query->createFunction('(SELECT id FROM oc_mimetypes WHERE mimetype = ' .
214-
$query->createNamedParameter('httpd/unix-directory') . ')')
210+
$query->createFunction('(SELECT id FROM oc_mimetypes WHERE mimetype = '
211+
. $query->createNamedParameter('httpd/unix-directory') . ')')
215212
))
216213
->andWhere($query->expr()->like('storage',
217-
$query->createFunction('(SELECT numeric_id FROM oc_storages WHERE id LIKE ' .
218-
$query->createNamedParameter('object::%') . ')')
214+
$query->createFunction('(SELECT numeric_id FROM oc_storages WHERE id LIKE '
215+
. $query->createNamedParameter('object::%') . ')')
219216
));
220217

221218
$result = $query->executeQuery();
@@ -225,7 +222,7 @@ public function testDetectUnencryptedFilesQuery(): void {
225222
// After our encrypted file, this should be 0 or low
226223
// (may have system files that aren't encrypted)
227224
$this->assertIsNumeric($unencryptedCount,
228-
"Should be able to query unencrypted file count");
225+
'Should be able to query unencrypted file count');
229226

230227
// Clean up
231228
$this->view->unlink('migration-test-encrypted.txt');
@@ -261,11 +258,11 @@ public function testSizeConsistencyAfterEncryption(): void {
261258

262259
// Assertions
263260
$this->assertEquals($size, $dbSize,
264-
"Database should have unencrypted size");
261+
'Database should have unencrypted size');
265262
$this->assertEquals($size, $actualSize,
266-
"Read content should match original size");
263+
'Read content should match original size');
267264
$this->assertGreaterThan($size, $s3Size,
268-
"S3 should have encrypted size (larger)");
265+
'S3 should have encrypted size (larger)');
269266

270267
// Clean up
271268
$this->view->unlink($testFile);

tests/lib/Files/ObjectStore/S3EncryptionTest.php

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
use OC\Files\ObjectStore\ObjectStoreStorage;
1313
use OC\Files\ObjectStore\S3;
14-
use OCP\Files\IMimeTypeLoader;
1514
use OCP\IConfig;
1615
use OCP\Server;
1716
use Test\Traits\EncryptionTrait;
@@ -140,7 +139,7 @@ protected function tearDown(): void {
140139
private function cleanupTestFiles(): void {
141140
// Clean up any test files that match our patterns
142141
$patterns = ['test-size-*', 'test-roundtrip-*', 'test-integrity-*',
143-
'test-partial-read*', 'test-seek*', 'test-multipart*', 'test.txt'];
142+
'test-partial-read*', 'test-seek*', 'test-multipart*', 'test.txt'];
144143

145144
foreach ($patterns as $pattern) {
146145
try {
@@ -206,7 +205,7 @@ public function testSizeConsistencyAcrossSources(int $originalSize): void {
206205
$bytesWritten = $this->view->file_put_contents($testFile, $data);
207206

208207
$this->assertEquals($originalSize, $bytesWritten,
209-
"file_put_contents should return original size written");
208+
'file_put_contents should return original size written');
210209

211210
// 2. Get database size (from filecache via userFolder)
212211
$node = $this->userFolder->get($testFile);
@@ -235,15 +234,15 @@ public function testSizeConsistencyAcrossSources(int $originalSize): void {
235234
if ($originalSize === 0) {
236235
// Zero-byte files still get encryption header in S3
237236
$this->assertGreaterThan(0, $s3Size,
238-
"S3 should have encryption header even for empty files");
237+
'S3 should have encryption header even for empty files');
239238
} else {
240239
$this->assertGreaterThan($originalSize, $s3Size,
241240
"S3 size should be larger than original due to encryption overhead (original: $originalSize, s3: $s3Size)");
242241
}
243242

244243
// Verify content integrity - critical!
245244
$this->assertEquals($data, $content,
246-
"Content should be identical after encrypt/decrypt cycle - corruption detected!");
245+
'Content should be identical after encrypt/decrypt cycle - corruption detected!');
247246

248247
// Validate encryption overhead is reasonable
249248
// Binary signed format: Header (8192 bytes) + data blocks
@@ -254,9 +253,9 @@ public function testSizeConsistencyAcrossSources(int $originalSize): void {
254253
if ($originalSize === 0) {
255254
// Zero-byte files still get encryption header
256255
$this->assertGreaterThan(0, $s3Size,
257-
"Even empty files should have encryption header in S3");
256+
'Even empty files should have encryption header in S3');
258257
$this->assertLessThanOrEqual(8192, $s3Size,
259-
"Empty file should only have header block");
258+
'Empty file should only have header block');
260259
} else {
261260
$overheadPercent = (($s3Size - $originalSize) / $originalSize) * 100;
262261

@@ -300,7 +299,7 @@ public function testEncryptedFileRoundTrip(int $size): void {
300299
$this->assertEquals($size, strlen($readData));
301300

302301
// Verify content
303-
$this->assertEquals($data, $readData, "Content mismatch after round trip");
302+
$this->assertEquals($data, $readData, 'Content mismatch after round trip');
304303

305304
// Clean up
306305
$this->view->unlink($testFile);
@@ -331,8 +330,8 @@ public function testEncryptedFileIntegrity(int $size): void {
331330
fclose($handle);
332331

333332
// Verify
334-
$this->assertEquals($size, strlen($readData), "Size mismatch in streaming read");
335-
$this->assertEquals($data, $readData, "Content mismatch in streaming read");
333+
$this->assertEquals($size, strlen($readData), 'Size mismatch in streaming read');
334+
$this->assertEquals($data, $readData, 'Content mismatch in streaming read');
336335

337336
// Clean up
338337
$this->view->unlink($testFile);
@@ -430,12 +429,12 @@ public function testEncryptedMultipartUpload(): void {
430429
$node = $this->userFolder->get($testFile);
431430
$dbSize = $node->getSize();
432431
$this->assertEquals($size, $dbSize,
433-
"Database should have unencrypted size even for multipart upload");
432+
'Database should have unencrypted size even for multipart upload');
434433

435434
// Verify content
436435
$readData = $this->view->file_get_contents($testFile);
437436
$this->assertEquals($data, $readData,
438-
"Content mismatch for multipart encrypted upload");
437+
'Content mismatch for multipart encrypted upload');
439438

440439
// Clean up
441440
$this->view->unlink($testFile);
@@ -486,7 +485,7 @@ public function testEncryptedFileMimeType(): void {
486485

487486
// Should detect as text/plain
488487
$this->assertEquals('text/plain', $mimeType,
489-
"MIME type detection should work on encrypted files");
488+
'MIME type detection should work on encrypted files');
490489

491490
// Clean up
492491
$this->view->unlink($testFile);

0 commit comments

Comments
 (0)