/** * @medium * test detection of encrypted files */ function testIsEncryptedPath() { $util = new \OCA\Files_Encryption\Util($this->view, $this->userId); self::loginHelper($this->userId); $unencryptedFile = '/tmpUnencrypted-' . $this->getUniqueID() . '.txt'; $encryptedFile = '/tmpEncrypted-' . $this->getUniqueID() . '.txt'; // Disable encryption proxy to write a unencrypted file $proxyStatus = \OC_FileProxy::$enabled; \OC_FileProxy::$enabled = false; $this->view->file_put_contents($this->userId . '/files/' . $unencryptedFile, $this->dataShort); // Re-enable proxy - our work is done \OC_FileProxy::$enabled = $proxyStatus; // write a encrypted file $this->view->file_put_contents($this->userId . '/files/' . $encryptedFile, $this->dataShort); // test if both files are detected correctly $this->assertFalse($util->isEncryptedPath($this->userId . '/files/' . $unencryptedFile)); $this->assertTrue($util->isEncryptedPath($this->userId . '/files/' . $encryptedFile)); // cleanup $this->view->unlink($this->userId . '/files/' . $unencryptedFile); $this->view->unlink($this->userId . '/files/' . $encryptedFile); }