Skip to content

Commit 496521e

Browse files
skjnldsvbackportbot[bot]
authored andcommitted
test: enable rate limiting for ratelimiting.feature
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
1 parent 7a6fd82 commit 496521e

3 files changed

Lines changed: 42 additions & 0 deletions

File tree

build/integration/config/behat.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,3 +243,14 @@ default:
243243
regular_user_password: 123456
244244
- RemoteContext:
245245
remote: http://localhost:8080
246+
247+
ratelimiting:
248+
paths:
249+
- "%paths.base%/../ratelimiting_features"
250+
contexts:
251+
- RateLimitingContext:
252+
baseUrl: http://localhost:8080
253+
admin:
254+
- admin
255+
- admin
256+
regular_user_password: 123456
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
/**
3+
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
4+
* SPDX-License-Identifier: AGPL-3.0-or-later
5+
*/
6+
use Behat\Behat\Context\Context;
7+
8+
class RateLimitingContext implements Context {
9+
use BasicStructure;
10+
use CommandLine;
11+
use Provisioning;
12+
13+
/**
14+
* @BeforeScenario @RateLimiting
15+
*/
16+
public function enableRateLimiting() {
17+
// Enable rate limiting for the tests.
18+
// Ratelimiting is disabled by default, so we need to enable it
19+
$this->runOcc(['config:system:set', 'ratelimit.protection.enabled', '--value', 'true', '--type', 'bool']);
20+
}
21+
22+
/**
23+
* @AfterScenario @RateLimiting
24+
*/
25+
public function disableRateLimiting() {
26+
// Restore the default rate limiting configuration.
27+
// Ratelimiting is disabled by default, so we need to disable it
28+
$this->runOcc(['config:system:set', 'ratelimit.protection.enabled', '--value', 'false', '--type', 'bool']);
29+
}
30+
}

build/integration/features/ratelimiting.feature renamed to build/integration/ratelimiting_features/ratelimiting.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
22
# SPDX-License-Identifier: AGPL-3.0-or-later
3+
@RateLimiting
34
Feature: ratelimiting
45

56
Background:

0 commit comments

Comments
 (0)