function testSetFileKey() { # NOTE: This cannot be tested until we are able to break out # of the FileSystemView data directory root $key = Encryption\Crypt::symmetricEncryptFileContentKeyfile($this->randomKey, 'hat'); $file = 'unittest-' . time() . '.txt'; // Disable encryption proxy to prevent recursive calls $proxyStatus = \OC_FileProxy::$enabled; \OC_FileProxy::$enabled = false; $this->view->file_put_contents($this->userId . '/files/' . $file, $key['encrypted']); // Re-enable proxy - our work is done \OC_FileProxy::$enabled = $proxyStatus; //$view = new \OC_FilesystemView( '/' . $this->userId . '/files_encryption/keyfiles' ); Encryption\Keymanager::setFileKey($this->view, $file, $this->userId, $key['key']); // enable encryption proxy $proxyStatus = \OC_FileProxy::$enabled; \OC_FileProxy::$enabled = true; // cleanup $this->view->unlink('/' . $this->userId . '/files/' . $file); // change encryption proxy to previous state \OC_FileProxy::$enabled = $proxyStatus; }
function testSymmetricEncryptFileContentKeyfile() { # TODO: search in keyfile for actual content as IV will ensure this test always passes $crypted = Encryption\Crypt::symmetricEncryptFileContentKeyfile($this->dataUrl); $this->assertNotEquals($this->dataUrl, $crypted['encrypted']); $decrypt = Encryption\Crypt::symmetricDecryptFileContent($crypted['encrypted'], $crypted['key']); $this->assertEquals($this->dataUrl, $decrypt); }