ExternalStorageTest.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Joas Schilling <coding@schilljs.com>
  6. * @author Morris Jobke <hey@morrisjobke.de>
  7. * @author Robin Appelman <robin@icewind.nl>
  8. * @author Thomas Müller <thomas.mueller@tmit.eu>
  9. * @author Vincent Petry <pvince81@owncloud.com>
  10. *
  11. * @license AGPL-3.0
  12. *
  13. * This code is free software: you can redistribute it and/or modify
  14. * it under the terms of the GNU Affero General Public License, version 3,
  15. * as published by the Free Software Foundation.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License, version 3,
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>
  24. *
  25. */
  26. namespace OCA\Files_Sharing\Tests;
  27. /**
  28. * Tests for the external Storage class for remote shares.
  29. *
  30. * @group DB
  31. */
  32. class ExternalStorageTest extends \Test\TestCase {
  33. function optionsProvider() {
  34. return array(
  35. array(
  36. 'http://remoteserver:8080/owncloud',
  37. 'http://remoteserver:8080/owncloud/public.php/webdav/',
  38. ),
  39. // extra slash
  40. array(
  41. 'http://remoteserver:8080/owncloud/',
  42. 'http://remoteserver:8080/owncloud/public.php/webdav/',
  43. ),
  44. // extra path
  45. array(
  46. 'http://remoteserver:8080/myservices/owncloud/',
  47. 'http://remoteserver:8080/myservices/owncloud/public.php/webdav/',
  48. ),
  49. // root path
  50. array(
  51. 'http://remoteserver:8080/',
  52. 'http://remoteserver:8080/public.php/webdav/',
  53. ),
  54. // without port
  55. array(
  56. 'http://remoteserver/oc.test',
  57. 'http://remoteserver/oc.test/public.php/webdav/',
  58. ),
  59. // https
  60. array(
  61. 'https://remoteserver/',
  62. 'https://remoteserver/public.php/webdav/',
  63. ),
  64. );
  65. }
  66. /**
  67. * @dataProvider optionsProvider
  68. */
  69. public function testStorageMountOptions($inputUri, $baseUri) {
  70. $certificateManager = \OC::$server->getCertificateManager();
  71. $storage = new TestSharingExternalStorage(
  72. array(
  73. 'remote' => $inputUri,
  74. 'owner' => 'testOwner',
  75. 'mountpoint' => 'remoteshare',
  76. 'token' => 'abcdef',
  77. 'password' => '',
  78. 'manager' => null,
  79. 'certificateManager' => $certificateManager
  80. )
  81. );
  82. $this->assertEquals($baseUri, $storage->getBaseUri());
  83. }
  84. }
  85. /**
  86. * Dummy subclass to make it possible to access private members
  87. */
  88. class TestSharingExternalStorage extends \OCA\Files_Sharing\External\Storage {
  89. public function getBaseUri() {
  90. return $this->createBaseUri();
  91. }
  92. }