You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.9 KiB

  1. <?php
  2. /**
  3. * ownCloud
  4. *
  5. * @author Michael Gapczynski
  6. * @author Christian Berendt
  7. * @copyright 2012 Michael Gapczynski mtgap@owncloud.com
  8. * @copyright 2013 Christian Berendt berendt@b1-systems.de
  9. *
  10. * This library is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
  12. * License as published by the Free Software Foundation; either
  13. * version 3 of the License, or any later version.
  14. *
  15. * This library is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public
  21. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  22. */
  23. namespace Test\Files\Storage;
  24. class AmazonS3 extends Storage {
  25. private $config;
  26. public function setUp() {
  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->instance = new \OC\Files\Storage\AmazonS3($this->config['amazons3']);
  32. }
  33. public function tearDown() {
  34. if ($this->instance) {
  35. $connection = $this->instance->getConnection();
  36. try {
  37. // NOTE(berendt): clearBucket() is not working with Ceph
  38. $iterator = $connection->getIterator('ListObjects', array(
  39. 'Bucket' => $this->config['amazons3']['bucket']
  40. ));
  41. foreach ($iterator as $object) {
  42. $connection->deleteObject(array(
  43. 'Bucket' => $this->config['amazons3']['bucket'],
  44. 'Key' => $object['Key']
  45. ));
  46. }
  47. } catch (S3Exception $e) {
  48. }
  49. $connection->deleteBucket(array(
  50. 'Bucket' => $this->config['amazons3']['bucket']
  51. ));
  52. //wait some seconds for completing the replication
  53. sleep(30);
  54. }
  55. }
  56. }