diff options
author | Florin Peter <github@florin-peter.de> | 2013-05-15 21:00:35 +0200 |
---|---|---|
committer | Florin Peter <github@florin-peter.de> | 2013-05-15 21:00:35 +0200 |
commit | 5fcb5f3aba90e24762d031ea4481ce65e34c018f (patch) | |
tree | 5398989b11c82b014cd44be7ad7e472eaa9ed688 /apps | |
parent | 12ebc5a1b3a6435a111b155ce2fffb19ca16a64a (diff) | |
download | nextcloud-server-5fcb5f3aba90e24762d031ea4481ce65e34c018f.tar.gz nextcloud-server-5fcb5f3aba90e24762d031ea4481ce65e34c018f.zip |
added test for password change
Diffstat (limited to 'apps')
-rwxr-xr-x | apps/files_encryption/tests/crypt.php | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/apps/files_encryption/tests/crypt.php b/apps/files_encryption/tests/crypt.php index c694aa1140c..f84536aaa13 100755 --- a/apps/files_encryption/tests/crypt.php +++ b/apps/files_encryption/tests/crypt.php @@ -690,6 +690,40 @@ class Test_Crypt extends \PHPUnit_Framework_TestCase { $view->unlink( $newFolder ); } + function testChangePassphrase() { + + $filename = 'tmp-'.time(); + + // Save long data as encrypted file using stream wrapper + $cryptedFile = file_put_contents( 'crypt://' . $filename, $this->dataLong ); + + // Test that data was successfully written + $this->assertTrue( is_int( $cryptedFile ) ); + + // Get file decrypted contents + $decrypt = file_get_contents( 'crypt://' . $filename ); + + $this->assertEquals( $this->dataLong, $decrypt ); + + // change password + \OC_User::setPassword('admin', 'test'); + + // relogin + $params['uid'] = $this->userId; + $params['password'] = 'test'; + OCA\Encryption\Hooks::login($params); + + // Get file decrypted contents + $newDecrypt = file_get_contents( 'crypt://' . $filename ); + + $this->assertEquals( $this->dataLong, $newDecrypt ); + + // tear down + // change password back + \OC_User::setPassword('admin', 'admin'); + $view = new \OC\Files\View('/' . $this->userId . '/files'); + $view->unlink( $filename ); + } // function testEncryption(){ // // $key=uniqid(); |