@@ -50,74 +50,65 @@ public function testCalculateExpireDate($defaultExpireSettings, $creationTime, $
5050 $ this ->assertSame ($ expected , $ result );
5151 }
5252
53- public function fixRemoteURLInShareWithData () {
54- $ userPrefix = ['test@ ' , 'na/me@ ' ];
53+ public function dataTestSplitUserRemote () {
54+ $ userPrefix = ['user@name ' , 'username ' ];
5555 $ protocols = ['' , 'http:// ' , 'https:// ' ];
5656 $ remotes = [
5757 'localhost ' ,
58- 'test:foobar@localhost ' ,
5958 'local.host ' ,
6059 'dev.local.host ' ,
6160 'dev.local.host/path ' ,
61+ 'dev.local.host/at@inpath ' ,
6262 '127.0.0.1 ' ,
6363 '::1 ' ,
6464 '::192.0.2.128 ' ,
65+ '::192.0.2.128/at@inpath ' ,
6566 ];
6667
67- $ testCases = [
68- ['test ' , 'test ' ],
69- ['na/me ' , 'na/me ' ],
70- ['na/me/ ' , 'na/me ' ],
71- ['na/index.php ' , 'na/index.php ' ],
72- ['http://localhost ' , 'http://localhost ' ],
73- ['http://localhost/ ' , 'http://localhost ' ],
74- ['http://localhost/index.php ' , 'http://localhost/index.php ' ],
75- ['http://localhost/index.php/s/token ' , 'http://localhost/index.php/s/token ' ],
76- ['http://test:foobar@localhost ' , 'http://test:foobar@localhost ' ],
77- ['http://test:foobar@localhost/ ' , 'http://test:foobar@localhost ' ],
78- ['http://test:foobar@localhost/index.php ' , 'http://test:foobar@localhost ' ],
79- ['http://test:foobar@localhost/index.php/s/token ' , 'http://test:foobar@localhost ' ],
80- ];
81-
68+ $ testCases = [];
8269 foreach ($ userPrefix as $ user ) {
8370 foreach ($ remotes as $ remote ) {
8471 foreach ($ protocols as $ protocol ) {
85- $ baseUrl = $ user . $ protocol . $ remote ;
72+ $ baseUrl = $ user . ' @ ' . $ protocol . $ remote ;
8673
87- $ testCases [] = [$ baseUrl , $ baseUrl ];
88- $ testCases [] = [$ baseUrl . '/ ' , $ baseUrl ];
89- $ testCases [] = [$ baseUrl . '/index.php ' , $ baseUrl ];
90- $ testCases [] = [$ baseUrl . '/index.php/s/token ' , $ baseUrl ];
74+ $ testCases [] = [$ baseUrl , $ user , $ protocol . $ remote ];
75+ $ testCases [] = [$ baseUrl . '/ ' , $ user , $ protocol . $ remote ];
76+ $ testCases [] = [$ baseUrl . '/index.php ' , $ user , $ protocol . $ remote ];
77+ $ testCases [] = [$ baseUrl . '/index.php/s/token ' , $ user , $ protocol . $ remote ];
9178 }
9279 }
9380 }
9481 return $ testCases ;
9582 }
9683
9784 /**
98- * @dataProvider fixRemoteURLInShareWithData
99- */
100- public function testFixRemoteURLInShareWith ($ remote , $ expected ) {
101- $ this ->assertSame ($ expected , \OC \Share \Helper::fixRemoteURLInShareWith ($ remote ));
102- }
103-
104- /**
105- * @dataProvider dataTestSplitUserRemoteSuccess
85+ * @dataProvider dataTestSplitUserRemote
10686 *
107- * @param string $id
87+ * @param string $remote
10888 * @param string $expectedUser
109- * @param string $expectedRemote
89+ * @param string $expectedUrl
11090 */
111- public function testSplitUserRemoteSuccess ( $ id , $ expectedUser , $ expectedRemote ) {
112- list ($ user , $ remote ) = \OC \Share \Helper::splitUserRemote ($ id );
113- $ this ->assertSame ($ expectedUser , $ user );
114- $ this ->assertSame ($ expectedRemote , $ remote );
91+ public function testSplitUserRemote ( $ remote , $ expectedUser , $ expectedUrl ) {
92+ list ($ remoteUser , $ remoteUrl ) = \OC \Share \Helper::splitUserRemote ($ remote );
93+ $ this ->assertSame ($ expectedUser , $ remoteUser );
94+ $ this ->assertSame ($ expectedUrl , $ remoteUrl );
11595 }
11696
117- public function dataTestSplitUserRemoteSuccess () {
97+ public function dataTestSplitUserRemoteError () {
11898 return array (
119- array ('user@server ' , 'user ' , 'server ' ),
120- array ('user@name@server ' , 'user@name ' , 'server ' )
99+ // Invalid path
100+ array ('user@ ' ),
101+
102+ // Invalid user
103+ array ('@server ' ),
104+ array ('us/er@server ' ),
105+ array ('us:er@server ' ),
106+
107+ // Invalid splitting
108+ array ('user ' ),
109+ array ('' ),
110+ array ('us/erserver ' ),
111+ array ('us:erserver ' ),
121112 );
122113 }
123114
@@ -130,13 +121,4 @@ public function dataTestSplitUserRemoteSuccess() {
130121 public function testSplitUserRemoteError ($ id ) {
131122 \OC \Share \Helper::splitUserRemote ($ id );
132123 }
133-
134- public function dataTestSplitUserRemoteError () {
135- return array (
136- array ('user@ ' ),
137- array ('@server ' ),
138- array ('user ' ),
139- array ('' ),
140- );
141- }
142124}
0 commit comments