PageRenderTime 40ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/apps/files_external/tests/amazons3.php

https://github.com/sezuan/core
PHP | 49 lines | 24 code | 6 blank | 19 comment | 3 complexity | 158af4ba1835701f61fe0f38700c4924 MD5 | raw file
Possible License(s): AGPL-3.0, AGPL-1.0, MPL-2.0-no-copyleft-exception
  1. <?php
  2. /**
  3. * ownCloud
  4. *
  5. * @author Michael Gapczynski
  6. * @copyright 2012 Michael Gapczynski mtgap@owncloud.com
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
  10. * License as published by the Free Software Foundation; either
  11. * version 3 of the License, or any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public
  19. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. namespace Test\Files\Storage;
  22. class AmazonS3 extends Storage {
  23. private $config;
  24. private $id;
  25. public function setUp() {
  26. $id = uniqid();
  27. $this->config = include('files_external/tests/config.php');
  28. if ( ! is_array($this->config) or ! isset($this->config['amazons3']) or ! $this->config['amazons3']['run']) {
  29. $this->markTestSkipped('AmazonS3 backend not configured');
  30. }
  31. $this->config['amazons3']['bucket'] = $id; // Make sure we have a new empty bucket to work in
  32. $this->instance = new \OC\Files\Storage\AmazonS3($this->config['amazons3']);
  33. }
  34. public function tearDown() {
  35. if ($this->instance) {
  36. $s3 = new \AmazonS3(array('key' => $this->config['amazons3']['key'],
  37. 'secret' => $this->config['amazons3']['secret']));
  38. if ($s3->delete_all_objects($this->id)) {
  39. $s3->delete_bucket($this->id);
  40. }
  41. }
  42. }
  43. }