1
0
Fork 0
mirror of synced 2024-06-25 17:50:38 +12:00

Added more storage test assertions

This commit is contained in:
eldadfux 2019-11-17 20:49:01 +02:00
parent 4fef427088
commit 2e0bec5699
2 changed files with 14 additions and 3 deletions

View file

@ -468,8 +468,12 @@ $utopia->post('/v1/storage/files')
$iv = OpenSSL::randomPseudoBytes(OpenSSL::cipherIVLength(OpenSSL::CIPHER_AES_128_GCM));
$data = OpenSSL::encrypt($data, OpenSSL::CIPHER_AES_128_GCM, $key, 0, $iv, $tag);
$sizeCompressed = (int) $device->write($path, $data);
if(!$device->write($path, $data)) {
throw new Exception('Failed to save file', 500);
}
$sizeActual = $device->getFileSize($path);
$file = $projectDB->createDocument([
'$collection' => Database::SYSTEM_COLLECTION_FILES,
'$permissions' => [
@ -483,7 +487,7 @@ $utopia->post('/v1/storage/files')
'signature' => $device->getFileHash($path),
'mimeType' => $mimeType,
'sizeOriginal' => $size,
'sizeCompressed' => $sizeCompressed,
'sizeActual' => $sizeActual,
'algorithm' => $compressor->getName(),
'token' => bin2hex(random_bytes(64)),
'comment' => '',
@ -503,7 +507,7 @@ $utopia->post('/v1/storage/files')
;
$usage
->setParam('storage', $sizeCompressed)
->setParam('storage', $sizeActual)
;
$list[] = $file->getArrayCopy();

View file

@ -28,12 +28,19 @@ class ProjectStorafeTest extends BaseProjects
'folderId' => 'xyz',
]);
$this->assertEquals($file['headers']['status-code'], 201);
$this->assertNotEmpty($file['body'][0]['$uid']);
$this->assertEquals('files', $file['body'][0]['$collection']);
$this->assertIsInt($file['body'][0]['dateCreated']);
$this->assertEquals('logo.png', $file['body'][0]['name']);
$this->assertEquals('image/png', $file['body'][0]['mimeType']);
$this->assertEquals(47218, $file['body'][0]['sizeOriginal']);
$this->assertEquals(54944, $file['body'][0]['sizeActual']);
$this->assertEquals('gzip', $file['body'][0]['algorithm']);
$this->assertEquals('1', $file['body'][0]['fileOpenSSLVersion']);
$this->assertEquals('aes-128-gcm', $file['body'][0]['fileOpenSSLCipher']);
$this->assertNotEmpty($file['body'][0]['fileOpenSSLTag']);
$this->assertNotEmpty($file['body'][0]['fileOpenSSLIV']);
return $data;
}