1+ # SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
2+ # SPDX-License-Identifier: AGPL-3.0-only
3+
4+ Feature : conversions
5+ Background :
6+ Given using api version "2"
7+ Given using new dav path
8+ Given user "user0" exists
9+
10+ Scenario : Converting a file works
11+ Given user "user0" uploads file "data/clouds.jpg" to "/image.jpg"
12+ Then as "user0" the file "/image.jpg" exists
13+ When user "user0" converts file "/image.jpg" to "image/png"
14+ Then the HTTP status code should be "201"
15+ Then the OCS status code should be "201"
16+ Then as "user0" the file "/image.png" exists
17+
18+ Scenario : Converting a file to a given path works
19+ Given user "user0" uploads file "data/clouds.jpg" to "/image.jpg"
20+ And User "user0" created a folder "/folder"
21+ Then as "user0" the file "/image.jpg" exists
22+ Then as "user0" the folder "/folder" exists
23+ When user "user0" converts file "/image.jpg" to "image/png" and saves it to "/folder/image.png"
24+ Then the HTTP status code should be "201"
25+ Then the OCS status code should be "201"
26+ Then as "user0" the file "/folder/image.png" exists
27+ Then as "user0" the file "/image.png" does not exist
28+
29+ Scenario : Converting a file path with overwrite
30+ Given user "user0" uploads file "data/clouds.jpg" to "/image.jpg"
31+ And user "user0" uploads file "data/green-square-256.png" to "/image.png"
32+ Then as "user0" the file "/image.jpg" exists
33+ Then as "user0" the file "/image.png" exists
34+ When user "user0" converts file "/image.jpg" to "image/png"
35+ Then the HTTP status code should be "201"
36+ Then the OCS status code should be "201"
37+ Then as "user0" the file "/image.jpg" exists
38+ Then as "user0" the file "/image.png" exists
39+ Then as "user0" the file "/image (2).png" exists
40+
41+ Scenario : Converting a file path with overwrite to a given path
42+ Given user "user0" uploads file "data/clouds.jpg" to "/image.jpg"
43+ And User "user0" created a folder "/folder"
44+ And user "user0" uploads file "data/green-square-256.png" to "/folder/image.png"
45+ Then as "user0" the file "/image.jpg" exists
46+ Then as "user0" the folder "/folder" exists
47+ Then as "user0" the file "/folder/image.png" exists
48+ When user "user0" converts file "/image.jpg" to "image/png" and saves it to "/folder/image.png"
49+ Then the HTTP status code should be "201"
50+ Then the OCS status code should be "201"
51+ Then as "user0" the file "/folder/image.png" exists
52+ Then as "user0" the file "/folder/image (2).png" exists
53+ Then as "user0" the file "/image.png" does not exist
54+ Then as "user0" the file "/image.jpg" exists
55+
56+ Scenario : Converting a file which does not exist fails
57+ When user "user0" converts file "/image.jpg" to "image/png"
58+ Then the HTTP status code should be "404"
59+ Then the OCS status code should be "404"
60+ Then as "user0" the file "/image.jpg" does not exist
61+ Then as "user0" the file "/image.png" does not exist
62+
63+ Scenario : Converting a file to an invalid destination path fails
64+ Given user "user0" uploads file "data/clouds.jpg" to "/image.jpg"
65+ When user "user0" converts file "/image.jpg" to "image/png" and saves it to "/folder/image.png"
66+ Then the HTTP status code should be "404"
67+ Then the OCS status code should be "404"
68+ Then as "user0" the file "/image.jpg" exists
69+ Then as "user0" the file "/folder/image.png" does not exist
70+
71+ Scenario : Converting a file to an invalid format fails
72+ Given user "user0" uploads file "data/clouds.jpg" to "/image.jpg"
73+ When user "user0" converts file "/image.jpg" to "image/invalid"
74+ Then the HTTP status code should be "500"
75+ Then the OCS status code should be "999"
76+ Then as "user0" the file "/image.jpg" exists
77+ Then as "user0" the file "/image.png" does not exist
78+
79+ Scenario : Forbid conversion to a destination without create permission
80+ Given user "user1" exists
81+ # Share the folder with user1
82+ Given User "user0" created a folder "/folder"
83+ Then As an "user0"
84+ When creating a share with
85+ | path | folder |
86+ | shareWith | user1 |
87+ | shareType | 0 |
88+ | permissions | 1 |
89+ Then the OCS status code should be "200"
90+ And the HTTP status code should be "200"
91+ # Create the folder, upload the image
92+ Then As an "user1"
93+ Given user "user1" accepts last share
94+ Given as "user1" the folder "/folder" exists
95+ Given user "user1" uploads file "data/clouds.jpg" to "/image.jpg"
96+ Then as "user1" the file "/image.jpg" exists
97+ # Try to convert the image to a folder where user1 has no create permission
98+ When user "user1" converts file "/image.jpg" to "image/png" and saves it to "/folder/folder.png"
99+ Then the OCS status code should be "403"
100+ And the HTTP status code should be "403"
101+ Then as "user1" the file "/folder/folder.png" does not exist
102+
0 commit comments