aboutsummaryrefslogtreecommitdiffstats
path: root/build/integration/file_conversions/file_conversions.feature
blob: 92dc11a647a335036b4b928a56abf4d9d6dbe2dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: AGPL-3.0-only

Feature: conversions
	Background:
		Given using api version "2"
    Given using new dav path
    Given user "user0" exists

  Scenario: Converting a file works
    Given user "user0" uploads file "data/clouds.jpg" to "/image.jpg"
    Then as "user0" the file "/image.jpg" exists
    When user "user0" converts file "/image.jpg" to "image/png"
    Then the HTTP status code should be "201"
    Then the OCS status code should be "201"
    Then as "user0" the file "/image.png" exists

  Scenario: Converting a file to a given path works
    Given user "user0" uploads file "data/clouds.jpg" to "/image.jpg"
    And User "user0" created a folder "/folder"
    Then as "user0" the file "/image.jpg" exists
    Then as "user0" the folder "/folder" exists
    When user "user0" converts file "/image.jpg" to "image/png" and saves it to "/folder/image.png"
    Then the HTTP status code should be "201"
    Then the OCS status code should be "201"
    Then as "user0" the file "/folder/image.png" exists
    Then as "user0" the file "/image.png" does not exist

  Scenario: Converting a file path with overwrite
    Given user "user0" uploads file "data/clouds.jpg" to "/image.jpg"
    And user "user0" uploads file "data/green-square-256.png" to "/image.png"
    Then as "user0" the file "/image.jpg" exists
    Then as "user0" the file "/image.png" exists
    When user "user0" converts file "/image.jpg" to "image/png"
    Then the HTTP status code should be "201"
    Then the OCS status code should be "201"
    Then as "user0" the file "/image.jpg" exists
    Then as "user0" the file "/image.png" exists
    Then as "user0" the file "/image (2).png" exists

  Scenario: Converting a file path with overwrite to a given path
    Given user "user0" uploads file "data/clouds.jpg" to "/image.jpg"
    And User "user0" created a folder "/folder"
    And user "user0" uploads file "data/green-square-256.png" to "/folder/image.png"
    Then as "user0" the file "/image.jpg" exists
    Then as "user0" the folder "/folder" exists
    Then as "user0" the file "/folder/image.png" exists
    When user "user0" converts file "/image.jpg" to "image/png" and saves it to "/folder/image.png"
    Then the HTTP status code should be "201"
    Then the OCS status code should be "201"
    Then as "user0" the file "/folder/image.png" exists
    Then as "user0" the file "/folder/image (2).png" exists
    Then as "user0" the file "/image.png" does not exist
    Then as "user0" the file "/image.jpg" exists

  Scenario: Converting a file which does not exist fails
    When user "user0" converts file "/image.jpg" to "image/png"
    Then the HTTP status code should be "404"
    Then the OCS status code should be "404"
    Then as "user0" the file "/image.jpg" does not exist
    Then as "user0" the file "/image.png" does not exist

  Scenario: Converting a file to an invalid destination path fails
    Given user "user0" uploads file "data/clouds.jpg" to "/image.jpg"
    When user "user0" converts file "/image.jpg" to "image/png" and saves it to "/folder/image.png"
    Then the HTTP status code should be "404"
    Then the OCS status code should be "404"
    Then as "user0" the file "/image.jpg" exists
    Then as "user0" the file "/folder/image.png" does not exist

  Scenario: Converting a file to an invalid format fails
    Given user "user0" uploads file "data/clouds.jpg" to "/image.jpg"
    When user "user0" converts file "/image.jpg" to "image/invalid"
    Then the HTTP status code should be "500"
    Then the OCS status code should be "999"
    Then as "user0" the file "/image.jpg" exists
    Then as "user0" the file "/image.png" does not exist

Scenario: Converting a file to a given path without extension fails
    Given user "user0" uploads file "data/clouds.jpg" to "/image.jpg"
    And User "user0" created a folder "/folder"
    Then as "user0" the file "/image.jpg" exists
    Then as "user0" the folder "/folder" exists
    When user "user0" converts file "/image.jpg" to "image/png" and saves it to "/folder/image"
    Then the HTTP status code should be "400"
    Then the OCS status code should be "400"
    Then as "user0" the file "/folder/image.png" does not exist
    Then as "user0" the file "/image.png" does not exist

  @local_storage
  Scenario: Converting a file bigger than 100 MiB fails
    Given file "/image.jpg" of size 108003328 is created in local storage
    Then as "user0" the folder "/local_storage" exists
    Then as "user0" the file "/local_storage/image.jpg" exists
    When user "user0" converts file "/local_storage/image.jpg" to "image/png" and saves it to "/image.png"
    Then the HTTP status code should be "400"
    Then the OCS status code should be "400"
    Then as "user0" the file "/image.png" does not exist

  Scenario: Forbid conversion to a destination without create permission
    Given user "user1" exists
    # Share the folder with user1
    Given User "user0" created a folder "/folder"
    Then As an "user0"
    When creating a share with
      | path | folder |
      | shareWith | user1 |
      | shareType | 0 |
      | permissions | 1 |
    Then the OCS status code should be "200"
    And the HTTP status code should be "200"
    # Create the folder, upload the image
    Then As an "user1"
    Given user "user1" accepts last share
    Given as "user1" the folder "/folder" exists
    Given user "user1" uploads file "data/clouds.jpg" to "/image.jpg"
    Then as "user1" the file "/image.jpg" exists
    # Try to convert the image to a folder where user1 has no create permission
    When user "user1" converts file "/image.jpg" to "image/png" and saves it to "/folder/folder.png"
    Then the OCS status code should be "403" 
    And the HTTP status code should be "403"
    Then as "user1" the file "/folder/folder.png" does not exist