Added more storage test assertions
This commit is contained in:
parent
4fef427088
commit
2e0bec5699
2 changed files with 14 additions and 3 deletions
|
@ -468,7 +468,11 @@ $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,
|
||||
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue