|
213 | 213 | end
|
214 | 214 | end
|
215 | 215 |
|
216 |
| - describe "#set_permissions_command" do |
217 |
| - let(:path) { "OpenProject/JediProject" } |
218 |
| - let(:permissions) do |
219 |
| - { |
220 |
| - users: { |
221 |
| - OpenProject: 31, |
222 |
| - "Obi-Wan": 31, |
223 |
| - "Qui-Gon": 31 |
224 |
| - }, |
225 |
| - groups: { |
226 |
| - OpenProject: 0 |
227 |
| - } |
228 |
| - } |
229 |
| - end |
230 |
| - |
231 |
| - let(:expected_request_body) do |
232 |
| - <<~XML |
233 |
| - <?xml version="1.0"?> |
234 |
| - <d:propertyupdate xmlns:d="DAV:" xmlns:nc="http://nextcloud.org/ns"> |
235 |
| - <d:set> |
236 |
| - <d:prop> |
237 |
| - <nc:acl-list> |
238 |
| - <nc:acl> |
239 |
| - <nc:acl-mapping-type>group</nc:acl-mapping-type> |
240 |
| - <nc:acl-mapping-id>OpenProject</nc:acl-mapping-id> |
241 |
| - <nc:acl-mask>31</nc:acl-mask> |
242 |
| - <nc:acl-permissions>0</nc:acl-permissions> |
243 |
| - </nc:acl> |
244 |
| - <nc:acl> |
245 |
| - <nc:acl-mapping-type>user</nc:acl-mapping-type> |
246 |
| - <nc:acl-mapping-id>OpenProject</nc:acl-mapping-id> |
247 |
| - <nc:acl-mask>31</nc:acl-mask> |
248 |
| - <nc:acl-permissions>31</nc:acl-permissions> |
249 |
| - </nc:acl> |
250 |
| - <nc:acl> |
251 |
| - <nc:acl-mapping-type>user</nc:acl-mapping-type> |
252 |
| - <nc:acl-mapping-id>Obi-Wan</nc:acl-mapping-id> |
253 |
| - <nc:acl-mask>31</nc:acl-mask> |
254 |
| - <nc:acl-permissions>31</nc:acl-permissions> |
255 |
| - </nc:acl> |
256 |
| - <nc:acl> |
257 |
| - <nc:acl-mapping-type>user</nc:acl-mapping-type> |
258 |
| - <nc:acl-mapping-id>Qui-Gon</nc:acl-mapping-id> |
259 |
| - <nc:acl-mask>31</nc:acl-mask> |
260 |
| - <nc:acl-permissions>31</nc:acl-permissions> |
261 |
| - </nc:acl> |
262 |
| - </nc:acl-list> |
263 |
| - </d:prop> |
264 |
| - </d:set> |
265 |
| - </d:propertyupdate> |
266 |
| - XML |
267 |
| - end |
268 |
| - |
269 |
| - context "with Nextcloud storage type selected" do |
270 |
| - context "with outbound request" do |
271 |
| - before do |
272 |
| - stub_request(:proppatch, "#{url}/remote.php/dav/files/OpenProject/OpenProject/JediProject") |
273 |
| - .with( |
274 |
| - body: expected_request_body, |
275 |
| - headers: { |
276 |
| - "Authorization" => "Basic T3BlblByb2plY3Q6T3BlblByb2plY3RTZWN1cmVQYXNzd29yZA==" |
277 |
| - } |
278 |
| - ) |
279 |
| - .to_return(expected_response) |
280 |
| - end |
281 |
| - |
282 |
| - context "when permissions can be set" do |
283 |
| - let(:expected_response_body) do |
284 |
| - <<~XML |
285 |
| - <?xml version="1.0"?> |
286 |
| - <d:multistatus |
287 |
| - xmlns:d="DAV:" |
288 |
| - xmlns:s="http://sabredav.org/ns" |
289 |
| - xmlns:oc="http://owncloud.org/ns" |
290 |
| - xmlns:nc="http://nextcloud.org/ns"> |
291 |
| - <d:response> |
292 |
| - <d:href>/remote.php/dav/files/OpenProject/OpenProject/Project%231</d:href> |
293 |
| - <d:propstat> |
294 |
| - <d:prop> |
295 |
| - <nc:acl-list/> |
296 |
| - </d:prop> |
297 |
| - <d:status>HTTP/1.1 200 OK</d:status> |
298 |
| - </d:propstat> |
299 |
| - </d:response> |
300 |
| - </d:multistatus> |
301 |
| - XML |
302 |
| - end |
303 |
| - let(:expected_response) do |
304 |
| - { |
305 |
| - status: 207, |
306 |
| - body: expected_response_body, |
307 |
| - headers: {} |
308 |
| - } |
309 |
| - end |
310 |
| - |
311 |
| - it "returns success when permissions can be set" do |
312 |
| - result = registry.resolve("nextcloud.commands.set_permissions").call(storage:, path:, permissions:) |
313 |
| - expect(result).to be_success |
314 |
| - end |
315 |
| - end |
316 |
| - |
317 |
| - context "when the password is wrong" do |
318 |
| - let(:expected_response_body) do |
319 |
| - <<~XML |
320 |
| - <?xml version="1.0" encoding="utf-8"?> |
321 |
| - <d:error |
322 |
| - xmlns:d="DAV:" |
323 |
| - xmlns:s="http://sabredav.org/ns"> |
324 |
| - <s:exception>Sabre\DAV\Exception\NotAuthenticated</s:exception> |
325 |
| - <s:message>No public access to this resource., No 'Authorization: Basic' header found. Either the client didn't send one, or the server is misconfigured, No 'Authorization: Bearer' header found. Either the client didn't send one, or the server is mis-configured, No 'Authorization: Basic' header found. Either the client didn't send one, or the server is misconfigured</s:message> |
326 |
| - </d:error> |
327 |
| - XML |
328 |
| - end |
329 |
| - let(:expected_response) do |
330 |
| - { |
331 |
| - status: 401, |
332 |
| - body: expected_response_body, |
333 |
| - headers: {} |
334 |
| - } |
335 |
| - end |
336 |
| - |
337 |
| - it "returns failure" do |
338 |
| - result = registry.resolve("nextcloud.commands.set_permissions").call(storage:, path:, permissions:) |
339 |
| - expect(result).to be_failure |
340 |
| - end |
341 |
| - end |
342 |
| - |
343 |
| - context "when the NC control user cannot read(see) the project folder" do |
344 |
| - let(:expected_response_body) do |
345 |
| - <<~XML |
346 |
| - <?xml version="1.0" encoding="utf-8"?> |
347 |
| - <d:error |
348 |
| - xmlns:d="DAV:" |
349 |
| - xmlns:s="http://sabredav.org/ns"> |
350 |
| - <s:exception>Sabre\DAV\Exception\NotFound</s:exception> |
351 |
| - <s:message>File with name /OpenProject/JediProject could not be located</s:message> |
352 |
| - </d:error> |
353 |
| - XML |
354 |
| - end |
355 |
| - let(:expected_response) do |
356 |
| - { |
357 |
| - status: 404, |
358 |
| - body: expected_response_body, |
359 |
| - headers: {} |
360 |
| - } |
361 |
| - end |
362 |
| - |
363 |
| - it "returns failure" do |
364 |
| - result = registry.resolve("nextcloud.commands.set_permissions").call(storage:, path:, permissions:) |
365 |
| - expect(result).to be_failure |
366 |
| - end |
367 |
| - end |
368 |
| - end |
369 |
| - |
370 |
| - context "when forbidden values are given as folder" do |
371 |
| - it "raises an ArgumentError on nil" do |
372 |
| - result = registry.resolve("nextcloud.commands.set_permissions").call(storage:, path: nil, permissions:) |
373 |
| - |
374 |
| - expect(result).to be_failure |
375 |
| - expect(result.errors.code).to eq(:invalid_path) |
376 |
| - end |
377 |
| - |
378 |
| - it "returns a :invalid_path Failure on empty string" do |
379 |
| - result = registry.resolve("nextcloud.commands.set_permissions").call(storage:, path: "", permissions:) |
380 |
| - |
381 |
| - expect(result).to be_failure |
382 |
| - expect(result.errors.code).to eq(:invalid_path) |
383 |
| - end |
384 |
| - end |
385 |
| - end |
386 |
| - end |
387 |
| - |
388 | 216 | describe "#file_ids_query" do
|
389 | 217 | let(:nextcloud_subpath) { "" }
|
390 | 218 | let(:url) { "https://example.com#{nextcloud_subpath}" }
|
|
0 commit comments