externalstorage.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. /**
  3. * ownCloud
  4. *
  5. * @author Vincent Petry
  6. * @copyright 2014 Vincent Petry <pvince81@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. */
  22. /**
  23. * Tests for the external Storage class for remote shares.
  24. */
  25. class Test_Files_Sharing_External_Storage extends \Test\TestCase {
  26. function optionsProvider() {
  27. return array(
  28. array(
  29. 'http://remoteserver:8080/owncloud',
  30. 'http://remoteserver:8080/owncloud/public.php/webdav/',
  31. ),
  32. // extra slash
  33. array(
  34. 'http://remoteserver:8080/owncloud/',
  35. 'http://remoteserver:8080/owncloud/public.php/webdav/',
  36. ),
  37. // extra path
  38. array(
  39. 'http://remoteserver:8080/myservices/owncloud/',
  40. 'http://remoteserver:8080/myservices/owncloud/public.php/webdav/',
  41. ),
  42. // root path
  43. array(
  44. 'http://remoteserver:8080/',
  45. 'http://remoteserver:8080/public.php/webdav/',
  46. ),
  47. // without port
  48. array(
  49. 'http://remoteserver/oc.test',
  50. 'http://remoteserver/oc.test/public.php/webdav/',
  51. ),
  52. // https
  53. array(
  54. 'https://remoteserver/',
  55. 'https://remoteserver/public.php/webdav/',
  56. ),
  57. );
  58. }
  59. /**
  60. * @dataProvider optionsProvider
  61. */
  62. public function testStorageMountOptions($inputUri, $baseUri) {
  63. $certificateManager = \OC::$server->getCertificateManager();
  64. $storage = new TestSharingExternalStorage(
  65. array(
  66. 'remote' => $inputUri,
  67. 'owner' => 'testOwner',
  68. 'mountpoint' => 'remoteshare',
  69. 'token' => 'abcdef',
  70. 'password' => '',
  71. 'manager' => null,
  72. 'certificateManager' => $certificateManager
  73. )
  74. );
  75. $this->assertEquals($baseUri, $storage->getBaseUri());
  76. }
  77. }
  78. /**
  79. * Dummy subclass to make it possible to access private members
  80. */
  81. class TestSharingExternalStorage extends \OCA\Files_Sharing\External\Storage {
  82. public function getBaseUri() {
  83. return $this->createBaseUri();
  84. }
  85. }