proxy.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * Copyright (c) 2012 Robin Appelman <icewind@owncloud.com>
  4. * This file is licensed under the Affero General Public License version 3 or
  5. * later.
  6. * See the COPYING-README file.
  7. */
  8. class Test_CryptProxy extends UnitTestCase {
  9. public function setUp(){
  10. //set testing key
  11. $_SESSION['enckey']=md5(time());
  12. //clear all proxies and hooks so we can do clean testing
  13. OC_FileProxy::clearProxies();
  14. OC_Hook::clear('OC_Filesystem');
  15. //enable only the encryption hook
  16. OC_FileProxy::register(new OC_FileProxy_Encryption());
  17. //set up temporary storage
  18. OC_Filesystem::clearMounts();
  19. OC_Filesystem::mount('OC_Filestorage_Temporary',array(),'/');
  20. //set up the users home folder in the temp storage
  21. $rootView=new OC_FilesystemView('');
  22. $rootView->mkdir('/'.OC_User::getUser());
  23. $rootView->mkdir('/'.OC_User::getUser().'/files');
  24. }
  25. public function testSimple(){
  26. $file=OC::$SERVERROOT.'/3rdparty/MDB2.php';
  27. $original=file_get_contents($file);
  28. OC_Filesystem::file_put_contents('/file',$original);
  29. OC_FileProxy::$enabled=false;
  30. $stored=OC_Filesystem::file_get_contents('/file');
  31. OC_FileProxy::$enabled=true;
  32. $fromFile=OC_Filesystem::file_get_contents('/file');
  33. $this->assertNotEqual($original,$stored);
  34. $this->assertEqual($original,$fromFile);
  35. }
  36. }