Skip to content

Commit fb6cd74

Browse files
committed
test: Add an integration test with richdocuments
Signed-off-by: Joas Schilling <coding@schilljs.com>
1 parent 0e9b163 commit fb6cd74

11 files changed

Lines changed: 177 additions & 14 deletions

File tree

.github/workflows/integration.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
php-versions: ['8.1']
2727
databases: ['sqlite', 'mysql', 'pgsql']
2828
server-versions: ['stable31']
29+
richdocuments-versions: ['stable31']
2930
primary-storage: ['local', 'minio']
3031

3132
name: php${{ matrix.php-versions }}-${{ matrix.databases }}-${{ matrix.server-versions }}-${{ matrix.primary-storage}}
@@ -74,6 +75,14 @@ jobs:
7475
persist-credentials: false
7576
path: apps/${{ env.APP_NAME }}
7677

78+
- name: Checkout app (richdocuments)
79+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
80+
with:
81+
persist-credentials: false
82+
path: apps/richdocuments
83+
repository: nextcloud/richdocuments
84+
ref: ${{ matrix.richdocuments-versions }}
85+
7786
- name: Set up php ${{ matrix.php-versions }}
7887
uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # v2.31.1
7988
with:
@@ -91,6 +100,14 @@ jobs:
91100
working-directory: apps/${{ env.APP_NAME }}
92101
run: composer i --no-dev
93102

103+
- name: Set up behat dependencies
104+
working-directory: apps/${{ env.APP_NAME }}/tests/Integration
105+
run: composer i
106+
107+
- name: Set up dependencies (richdocuments)
108+
working-directory: apps/richdocuments
109+
run: composer i --no-dev
110+
94111
- name: Set up Nextcloud for S3 primary storage
95112
if: matrix.primary-storage == 'minio'
96113
run: |

.github/workflows/phpunit-mariadb.yml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,21 +70,23 @@ jobs:
7070
matrix:
7171
php-versions: ${{ fromJson(needs.matrix.outputs.php-version) }}
7272
server-versions: ${{ fromJson(needs.matrix.outputs.server-max) }}
73-
mariadb-versions: ['10.6', '10.11']
73+
mariadb-versions: ['10.6', '11.4']
74+
richdocuments-versions: ['main']
7475

7576
name: MariaDB ${{ matrix.mariadb-versions }} PHP ${{ matrix.php-versions }} Nextcloud ${{ matrix.server-versions }}
7677

7778
services:
7879
mariadb:
79-
image: ghcr.io/nextcloud/continuous-integration-mariadb-${{ matrix.mariadb-versions }}:latest
80+
image: ghcr.io/nextcloud/continuous-integration-mariadb-${{ matrix.mariadb-versions }}:latest # zizmor: ignore[unpinned-images]
8081
ports:
8182
- 4444:3306/tcp
8283
env:
83-
MYSQL_ROOT_PASSWORD: rootpassword
84-
options: --health-cmd="mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 5
84+
MARIADB_ROOT_PASSWORD: rootpassword
85+
options: --health-cmd="mariadb-admin ping" --health-interval 5s --health-timeout 2s --health-retries 5
8586

8687
steps:
8788
- name: Set app env
89+
if: ${{ env.APP_NAME == '' }}
8890
run: |
8991
# Split and keep last
9092
echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV
@@ -103,8 +105,16 @@ jobs:
103105
persist-credentials: false
104106
path: apps/${{ env.APP_NAME }}
105107

108+
- name: Checkout app (richdocuments)
109+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
110+
with:
111+
persist-credentials: false
112+
path: apps/richdocuments
113+
repository: nextcloud/richdocuments
114+
ref: ${{ matrix.richdocuments-versions }}
115+
106116
- name: Set up php ${{ matrix.php-versions }}
107-
uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # v2.31.1
117+
uses: shivammathur/setup-php@0f7f1d08e3e32076e51cae65eb0b0c871405b16e # v2.34.1
108118
with:
109119
php-version: ${{ matrix.php-versions }}
110120
# https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation
@@ -132,9 +142,13 @@ jobs:
132142
if: steps.check_composer.outputs.files_exists == 'true'
133143
working-directory: apps/${{ env.APP_NAME }}
134144
run: |
135-
composer remove nextcloud/ocp --dev
145+
composer remove nextcloud/ocp --dev --no-scripts
136146
composer i
137147
148+
- name: Set up dependencies (richdocuments)
149+
working-directory: apps/richdocuments
150+
run: composer i --no-dev
151+
138152
- name: Set up Nextcloud
139153
env:
140154
DB_PORT: 4444

.github/workflows/phpunit-mysql.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
id: versions
3333
uses: icewind1991/nextcloud-version-matrix@58becf3b4bb6dc6cef677b15e2fd8e7d48c0908f # v1.3.1
3434
with:
35-
matrix: '{"mysql-versions": ["8.4"]}'
35+
matrix: '{"mysql-versions": ["8.4"], "richdocuments-versions": ["stable31"]}'
3636

3737
changes:
3838
runs-on: ubuntu-latest-low
@@ -101,6 +101,14 @@ jobs:
101101
persist-credentials: false
102102
path: apps/${{ env.APP_NAME }}
103103

104+
- name: Checkout app (richdocuments)
105+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
106+
with:
107+
persist-credentials: false
108+
path: apps/richdocuments
109+
repository: nextcloud/richdocuments
110+
ref: ${{ matrix.richdocuments-versions }}
111+
104112
- name: Set up php ${{ matrix.php-versions }}
105113
uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # v2.31.1
106114
with:
@@ -133,6 +141,10 @@ jobs:
133141
composer remove nextcloud/ocp --dev
134142
composer i
135143
144+
- name: Set up dependencies (richdocuments)
145+
working-directory: apps/richdocuments
146+
run: composer i --no-dev
147+
136148
- name: Set up Nextcloud
137149
env:
138150
DB_PORT: 4444

.github/workflows/phpunit-oci.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ jobs:
7070
matrix:
7171
php-versions: ${{ fromJson(needs.matrix.outputs.php-version) }}
7272
server-versions: ${{ fromJson(needs.matrix.outputs.server-max) }}
73+
richdocuments-versions: ['stable31']
7374

7475
name: OCI PHP ${{ matrix.php-versions }} Nextcloud ${{ matrix.server-versions }}
7576

@@ -114,6 +115,14 @@ jobs:
114115
persist-credentials: false
115116
path: apps/${{ env.APP_NAME }}
116117

118+
- name: Checkout app (richdocuments)
119+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
120+
with:
121+
persist-credentials: false
122+
path: apps/richdocuments
123+
repository: nextcloud/richdocuments
124+
ref: ${{ matrix.richdocuments-versions }}
125+
117126
- name: Set up php ${{ matrix.php-versions }}
118127
uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # v2.31.1
119128
with:
@@ -141,6 +150,10 @@ jobs:
141150
composer remove nextcloud/ocp --dev
142151
composer i
143152
153+
- name: Set up dependencies (richdocuments)
154+
working-directory: apps/richdocuments
155+
run: composer i --no-dev
156+
144157
- name: Set up Nextcloud
145158
env:
146159
DB_PORT: 1521

.github/workflows/phpunit-pgsql.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ jobs:
7070
matrix:
7171
php-versions: ${{ fromJson(needs.matrix.outputs.php-version) }}
7272
server-versions: ${{ fromJson(needs.matrix.outputs.server-max) }}
73+
richdocuments-versions: ['stable31']
7374

7475
name: PostgreSQL PHP ${{ matrix.php-versions }} Nextcloud ${{ matrix.server-versions }}
7576

@@ -104,6 +105,14 @@ jobs:
104105
persist-credentials: false
105106
path: apps/${{ env.APP_NAME }}
106107

108+
- name: Checkout app (richdocuments)
109+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
110+
with:
111+
persist-credentials: false
112+
path: apps/richdocuments
113+
repository: nextcloud/richdocuments
114+
ref: ${{ matrix.richdocuments-versions }}
115+
107116
- name: Set up php ${{ matrix.php-versions }}
108117
uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # v2.31.1
109118
with:
@@ -131,6 +140,10 @@ jobs:
131140
composer remove nextcloud/ocp --dev
132141
composer i
133142
143+
- name: Set up dependencies (richdocuments)
144+
working-directory: apps/richdocuments
145+
run: composer i --no-dev
146+
134147
- name: Set up Nextcloud
135148
env:
136149
DB_PORT: 4444

.github/workflows/phpunit-sqlite.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ jobs:
7070
matrix:
7171
php-versions: ${{ fromJson(needs.matrix.outputs.php-version) }}
7272
server-versions: ${{ fromJson(needs.matrix.outputs.server-max) }}
73+
richdocuments-versions: ['stable31']
7374

7475
name: SQLite PHP ${{ matrix.php-versions }} Nextcloud ${{ matrix.server-versions }}
7576

@@ -93,6 +94,14 @@ jobs:
9394
persist-credentials: false
9495
path: apps/${{ env.APP_NAME }}
9596

97+
- name: Checkout app (richdocuments)
98+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
99+
with:
100+
persist-credentials: false
101+
path: apps/richdocuments
102+
repository: nextcloud/richdocuments
103+
ref: ${{ matrix.richdocuments-versions }}
104+
96105
- name: Set up php ${{ matrix.php-versions }}
97106
uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # v2.31.1
98107
with:
@@ -120,6 +129,10 @@ jobs:
120129
composer remove nextcloud/ocp --dev
121130
composer i
122131
132+
- name: Set up dependencies (richdocuments)
133+
working-directory: apps/richdocuments
134+
run: composer i --no-dev
135+
123136
- name: Set up Nextcloud
124137
env:
125138
DB_PORT: 4444

tests/Integration/features/bootstrap/FeatureContext.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ class FeatureContext implements Context {
4545
protected string $tagId = '';
4646
protected array $createdUsers = [];
4747

48+
protected array $changedConfigs = [];
49+
4850
/**
4951
* FeatureContext constructor.
5052
*/
@@ -61,6 +63,12 @@ public function cleanUpBetweenTests() {
6163
$this->setCurrentUser('admin');
6264
$this->sendingTo('DELETE', '/apps/files_accesscontrol_testing');
6365
$this->assertStatusCode($this->response, 200);
66+
67+
foreach ($this->changedConfigs as $appId => $configs) {
68+
foreach ($configs as $config) {
69+
$this->sendingTo('DELETE', '/apps/provisioning_api/api/v1/config/apps/' . $appId . '/' . $config);
70+
}
71+
}
6472
}
6573

6674
/**
@@ -133,6 +141,20 @@ public function userSharesFile(string $sharer, string $file, string $sharee): vo
133141
]);
134142
}
135143

144+
/**
145+
* @Given /^user "([^"]*)" shares file "([^"]*)" publicly$/
146+
*/
147+
public function userSharesFilePublicly(string $sharer, string $file): void {
148+
$this->setCurrentUser($sharer);
149+
$this->sendingToWith('POST', '/apps/files_sharing/api/v1/shares', [
150+
'path' => $file,
151+
'permissions' => 19,
152+
'shareType' => 3,
153+
]);
154+
$responseBody = json_decode($this->response->getBody()->getContents(), true, flags: JSON_THROW_ON_ERROR);
155+
$this->lastShareData = $responseBody['ocs']['data'];
156+
}
157+
136158
// ChecksumsContext
137159
/**
138160
* @Then The webdav response should have a status code :statusCode
@@ -150,6 +172,18 @@ public function theWebdavResponseShouldHaveAStatusCode($statusCode) {
150172
}
151173
}
152174

175+
176+
#[\Behat\Step\Given('the following :appId app config is set')]
177+
public function setAppConfig(string $appId, TableNode $formData): void {
178+
$this->setCurrentUser('admin');
179+
foreach ($formData->getRows() as $row) {
180+
$this->sendingToWith('POST', '/apps/provisioning_api/api/v1/config/apps/' . $appId . '/' . $row[0], [
181+
'value' => $row[1],
182+
]);
183+
$this->changedConfigs[$appId][] = $row[0];
184+
}
185+
}
186+
153187
/**
154188
* User management
155189
*/

tests/Integration/features/bootstrap/WebDav.php

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ trait WebDav {
1919
/** @var int */
2020
private $storedFileID = null;
2121
private array $trashedFiles = [];
22+
protected array $lastShareData = [];
2223

2324
/**
2425
* @Given /^using dav path "([^"]*)"$/
@@ -140,7 +141,7 @@ public function downloadFileWithRange($fileSource, $range) {
140141
* @param string $range
141142
*/
142143
public function downloadPublicFileWithRange($range) {
143-
$token = $this->lastShareData->data->token;
144+
$token = $this->lastShareData['token'];
144145
$fullUrl = $this->baseUrl . 'public.php/webdav';
145146

146147
$client = new GClient();
@@ -150,15 +151,19 @@ public function downloadPublicFileWithRange($range) {
150151
'Range' => $range
151152
];
152153

153-
$this->response = $client->request('GET', $fullUrl, $options);
154+
try {
155+
$this->response = $client->request('GET', $fullUrl, $options);
156+
} catch (\GuzzleHttp\Exception\ClientException $e) {
157+
$this->response = $e->getResponse();
158+
}
154159
}
155160

156161
/**
157162
* @When /^Downloading last public shared file inside a folder "([^"]*)" with range "([^"]*)"$/
158163
* @param string $range
159164
*/
160165
public function downloadPublicFileInsideAFolderWithRange($path, $range) {
161-
$token = $this->lastShareData->data->token;
166+
$token = $this->lastShareData['token'];
162167
$fullUrl = $this->baseUrl . 'public.php/webdav' . "$path";
163168

164169
$client = new GClient();
@@ -169,7 +174,11 @@ public function downloadPublicFileInsideAFolderWithRange($path, $range) {
169174
];
170175
$options['auth'] = [$token, ''];
171176

172-
$this->response = $client->request('GET', $fullUrl, $options);
177+
try {
178+
$this->response = $client->request('GET', $fullUrl, $options);
179+
} catch (\GuzzleHttp\Exception\ClientException $e) {
180+
$this->response = $e->getResponse();
181+
}
173182
}
174183

175184
/**
@@ -189,8 +198,13 @@ public function downloadedContentShouldBe($content) {
189198
*/
190199
public function checkPropForFile($file, $prefix, $prop, $value) {
191200
$elementList = $this->propfindFile($this->currentUser, $file, "<$prefix:$prop/>");
192-
$property = $elementList['/' . $this->getDavFilesPath($this->currentUser) . $file][200]["{DAV:}$prop"];
193-
Assert::assertEquals($property, $value);
201+
if ($prefix === 'oc') {
202+
$prefix = '{http://owncloud.org/ns}';
203+
} else {
204+
$prefix = '{DAV:}';
205+
}
206+
$property = $elementList['/' . $this->getDavFilesPath($this->currentUser) . $file][200]["$prefix$prop"];
207+
Assert::assertEquals($value, $property);
194208
}
195209

196210
/**

tests/Integration/features/mimetypes.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Given as user "test1"
66
And using new dav path
77

8-
Scenario: Can properly block path detected mimetypes for application/javscript
8+
Scenario: Can properly block path detected mimetypes for application/javascript
99
And user "admin" creates global flow with 200
1010
| name | Admin flow |
1111
| class | OCA\FilesAccessControl\Operation |

0 commit comments

Comments
 (0)