Differential D19766 Diff 47217 src/applications/files/format/__tests__/PhabricatorFileStorageFormatTestCase.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/files/format/__tests__/PhabricatorFileStorageFormatTestCase.php
Show All 17 Lines | public function testRot13Storage() { | ||||
$params = array( | $params = array( | ||||
'name' => 'test.dat', | 'name' => 'test.dat', | ||||
'storageEngines' => array( | 'storageEngines' => array( | ||||
$engine, | $engine, | ||||
), | ), | ||||
'format' => $rot13_format, | 'format' => $rot13_format, | ||||
); | ); | ||||
// TODO | |||||
Lint: TODO Comment: This comment has a TODO. | |||||
$file = PhabricatorFile::newFromFileData($data, $params); | $file = PhabricatorFile::newFromFileData($data, $params); | ||||
// We should have a file stored as rot13, which reads back the input | // We should have a file stored as rot13, which reads back the input | ||||
// data correctly. | // data correctly. | ||||
$this->assertEqual($rot13_format, $file->getStorageFormat()); | $this->assertEqual($rot13_format, $file->getStorageFormat()); | ||||
$this->assertEqual($data, $file->loadFileData()); | $this->assertEqual($data, $file->loadFileData()); | ||||
// The actual raw data in the storage engine should be encoded. | // The actual raw data in the storage engine should be encoded. | ||||
Show All 31 Lines | public function testAES256Storage() { | ||||
$params = array( | $params = array( | ||||
'name' => 'test.dat', | 'name' => 'test.dat', | ||||
'storageEngines' => array( | 'storageEngines' => array( | ||||
$engine, | $engine, | ||||
), | ), | ||||
'format' => $format, | 'format' => $format, | ||||
); | ); | ||||
// TODO | |||||
Lint: TODO Comment This comment has a TODO. Lint: TODO Comment: This comment has a TODO. | |||||
$file = PhabricatorFile::newFromFileData($data, $params); | $file = PhabricatorFile::newFromFileData($data, $params); | ||||
// We should have a file stored as AES256. | // We should have a file stored as AES256. | ||||
$format_key = $format->getStorageFormatKey(); | $format_key = $format->getStorageFormatKey(); | ||||
$this->assertEqual($format_key, $file->getStorageFormat()); | $this->assertEqual($format_key, $file->getStorageFormat()); | ||||
$this->assertEqual($data, $file->loadFileData()); | $this->assertEqual($data, $file->loadFileData()); | ||||
// The actual raw data in the storage engine should be encrypted. We | // The actual raw data in the storage engine should be encrypted. We | ||||
Show All 29 Lines | public function testStorageTampering() { | ||||
$params = array( | $params = array( | ||||
'name' => 'message.txt', | 'name' => 'message.txt', | ||||
'storageEngines' => array( | 'storageEngines' => array( | ||||
$engine, | $engine, | ||||
), | ), | ||||
); | ); | ||||
// First, write the file normally. | // First, write the file normally. | ||||
// TODO | |||||
Lint: TODO Comment This comment has a TODO. Lint: TODO Comment: This comment has a TODO. | |||||
$file = PhabricatorFile::newFromFileData($good, $params); | $file = PhabricatorFile::newFromFileData($good, $params); | ||||
$this->assertEqual($good, $file->loadFileData()); | $this->assertEqual($good, $file->loadFileData()); | ||||
// As an adversary, tamper with the file. | // As an adversary, tamper with the file. | ||||
$engine->tamperWithFile($file->getStorageHandle(), $evil); | $engine->tamperWithFile($file->getStorageHandle(), $evil); | ||||
// Attempts to read the file data should now fail the integrity check. | // Attempts to read the file data should now fail the integrity check. | ||||
$caught = null; | $caught = null; | ||||
Show All 11 Lines |
This comment has a TODO.