externalstorage.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. /**
  3. * @author Joas Schilling <nickvergessen@owncloud.com>
  4. * @author Morris Jobke <hey@morrisjobke.de>
  5. * @author Robin Appelman <icewind@owncloud.com>
  6. * @author Vincent Petry <pvince81@owncloud.com>
  7. *
  8. * @copyright Copyright (c) 2015, ownCloud, Inc.
  9. * @license AGPL-3.0
  10. *
  11. * This code is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License, version 3,
  13. * as published by the Free Software Foundation.
  14. *
  15. * This program 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 License, version 3,
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>
  22. *
  23. */
  24. /**
  25. * Tests for the external Storage class for remote shares.
  26. */
  27. class Test_Files_Sharing_External_Storage extends \Test\TestCase {
  28. function optionsProvider() {
  29. return array(
  30. array(
  31. 'http://remoteserver:8080/owncloud',
  32. 'http://remoteserver:8080/owncloud/public.php/webdav/',
  33. ),
  34. // extra slash
  35. array(
  36. 'http://remoteserver:8080/owncloud/',
  37. 'http://remoteserver:8080/owncloud/public.php/webdav/',
  38. ),
  39. // extra path
  40. array(
  41. 'http://remoteserver:8080/myservices/owncloud/',
  42. 'http://remoteserver:8080/myservices/owncloud/public.php/webdav/',
  43. ),
  44. // root path
  45. array(
  46. 'http://remoteserver:8080/',
  47. 'http://remoteserver:8080/public.php/webdav/',
  48. ),
  49. // without port
  50. array(
  51. 'http://remoteserver/oc.test',
  52. 'http://remoteserver/oc.test/public.php/webdav/',
  53. ),
  54. // https
  55. array(
  56. 'https://remoteserver/',
  57. 'https://remoteserver/public.php/webdav/',
  58. ),
  59. );
  60. }
  61. /**
  62. * @dataProvider optionsProvider
  63. */
  64. public function testStorageMountOptions($inputUri, $baseUri) {
  65. $certificateManager = \OC::$server->getCertificateManager();
  66. $storage = new TestSharingExternalStorage(
  67. array(
  68. 'remote' => $inputUri,
  69. 'owner' => 'testOwner',
  70. 'mountpoint' => 'remoteshare',
  71. 'token' => 'abcdef',
  72. 'password' => '',
  73. 'manager' => null,
  74. 'certificateManager' => $certificateManager
  75. )
  76. );
  77. $this->assertEquals($baseUri, $storage->getBaseUri());
  78. }
  79. }
  80. /**
  81. * Dummy subclass to make it possible to access private members
  82. */
  83. class TestSharingExternalStorage extends \OCA\Files_Sharing\External\Storage {
  84. public function getBaseUri() {
  85. return $this->createBaseUri();
  86. }
  87. }