|
8 | 8 |
|
9 | 9 | use OCA\Files_Sharing\Controller\ExternalSharesController; |
10 | 10 | use OCA\Files_Sharing\External\Manager; |
11 | | -use OCP\AppFramework\Http\DataResponse; |
12 | 11 | use OCP\AppFramework\Http\JSONResponse; |
13 | | -use OCP\Http\Client\IClient; |
14 | 12 | use OCP\Http\Client\IClientService; |
15 | | -use OCP\Http\Client\IResponse; |
16 | 13 | use OCP\IConfig; |
17 | 14 | use OCP\IRequest; |
18 | 15 | use PHPUnit\Framework\MockObject\MockObject; |
@@ -79,90 +76,4 @@ public function testDestroy(): void { |
79 | 76 |
|
80 | 77 | $this->assertEquals(new JSONResponse(), $this->getExternalShareController()->destroy(4)); |
81 | 78 | } |
82 | | - |
83 | | - public function testRemoteWithValidHttps(): void { |
84 | | - $client = $this->createMock(IClient::class); |
85 | | - $response = $this->createMock(IResponse::class); |
86 | | - $response |
87 | | - ->expects($this->exactly(2)) |
88 | | - ->method('getBody') |
89 | | - ->willReturnOnConsecutiveCalls( |
90 | | - 'Certainly not a JSON string', |
91 | | - '{"installed":true,"maintenance":false,"version":"8.1.0.8","versionstring":"8.1.0","edition":""}' |
92 | | - ); |
93 | | - $client |
94 | | - ->expects($this->any()) |
95 | | - ->method('get') |
96 | | - ->willReturn($response); |
97 | | - |
98 | | - $this->clientService |
99 | | - ->expects($this->exactly(2)) |
100 | | - ->method('newClient') |
101 | | - ->willReturn($client); |
102 | | - |
103 | | - $this->assertEquals(new DataResponse('https'), $this->getExternalShareController()->testRemote('nextcloud.com')); |
104 | | - } |
105 | | - |
106 | | - public function testRemoteWithWorkingHttp(): void { |
107 | | - $client = $this->createMock(IClient::class); |
108 | | - $response = $this->createMock(IResponse::class); |
109 | | - $client |
110 | | - ->method('get') |
111 | | - ->willReturn($response); |
112 | | - $response |
113 | | - ->expects($this->exactly(5)) |
114 | | - ->method('getBody') |
115 | | - ->willReturnOnConsecutiveCalls( |
116 | | - 'Certainly not a JSON string', |
117 | | - 'Certainly not a JSON string', |
118 | | - 'Certainly not a JSON string', |
119 | | - 'Certainly not a JSON string', |
120 | | - '{"installed":true,"maintenance":false,"version":"8.1.0.8","versionstring":"8.1.0","edition":""}' |
121 | | - ); |
122 | | - $this->clientService |
123 | | - ->expects($this->exactly(5)) |
124 | | - ->method('newClient') |
125 | | - ->willReturn($client); |
126 | | - |
127 | | - $this->assertEquals(new DataResponse('http'), $this->getExternalShareController()->testRemote('nextcloud.com')); |
128 | | - } |
129 | | - |
130 | | - public function testRemoteWithInvalidRemote(): void { |
131 | | - $client = $this->createMock(IClient::class); |
132 | | - $response = $this->createMock(IResponse::class); |
133 | | - $client |
134 | | - ->expects($this->exactly(6)) |
135 | | - ->method('get') |
136 | | - ->willReturn($response); |
137 | | - $response |
138 | | - ->expects($this->exactly(6)) |
139 | | - ->method('getBody') |
140 | | - ->willReturn('Certainly not a JSON string'); |
141 | | - $this->clientService |
142 | | - ->expects($this->exactly(6)) |
143 | | - ->method('newClient') |
144 | | - ->willReturn($client); |
145 | | - |
146 | | - $this->assertEquals(new DataResponse(false), $this->getExternalShareController()->testRemote('nextcloud.com')); |
147 | | - } |
148 | | - |
149 | | - public function dataRemoteWithInvalidRemoteURLs(): array { |
150 | | - return [ |
151 | | - ['nextcloud.com?query'], |
152 | | - ['nextcloud.com/#anchor'], |
153 | | - ['nextcloud.com/;tomcat'], |
154 | | - ]; |
155 | | - } |
156 | | - |
157 | | - /** |
158 | | - * @dataProvider dataRemoteWithInvalidRemoteURLs |
159 | | - * @param string $remote |
160 | | - */ |
161 | | - public function testRemoteWithInvalidRemoteURLs(string $remote): void { |
162 | | - $this->clientService |
163 | | - ->expects($this->never()) |
164 | | - ->method('newClient'); |
165 | | - |
166 | | - $this->assertEquals(new DataResponse(false), $this->getExternalShareController()->testRemote($remote)); |
167 | | - } |
168 | 79 | } |
0 commit comments