aboutsummaryrefslogtreecommitdiffstats
path: root/apps/federation/tests/BackgroundJob
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2024-04-10 21:45:33 +0200
committerArthur Schiwon <blizzz@arthur-schiwon.de>2024-04-11 10:49:46 +0200
commitfaf6a65e07ed5be648f265dfde71d44e0fe3e767 (patch)
tree8541e7507d34c02eb955f16ebd97df989b222029 /apps/federation/tests/BackgroundJob
parente70cf9c14b2fd53ad47452f1b95ad46fce90155b (diff)
downloadnextcloud-server-faf6a65e07ed5be648f265dfde71d44e0fe3e767.tar.gz
nextcloud-server-faf6a65e07ed5be648f265dfde71d44e0fe3e767.zip
fix(federation): give some time to prepare both servers
- when this background job runs, while the current server was not being added as trusted_server in the other instance, yet, the secret sharing would not be attempted again, without visual feedback. - the change allows 5 attempts, which gives more than 20minutes to complete. More do not really help as the endpoint is brute force protected. Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/federation/tests/BackgroundJob')
-rw-r--r--apps/federation/tests/BackgroundJob/RequestSharedSecretTest.php8
1 files changed, 5 insertions, 3 deletions
diff --git a/apps/federation/tests/BackgroundJob/RequestSharedSecretTest.php b/apps/federation/tests/BackgroundJob/RequestSharedSecretTest.php
index 5aca6005f94..059348aa8ab 100644
--- a/apps/federation/tests/BackgroundJob/RequestSharedSecretTest.php
+++ b/apps/federation/tests/BackgroundJob/RequestSharedSecretTest.php
@@ -142,6 +142,7 @@ class RequestSharedSecretTest extends TestCase {
'url' => 'url',
'token' => 'token',
'created' => 42,
+ 'attempt' => 1,
]
);
} else {
@@ -164,12 +165,12 @@ class RequestSharedSecretTest extends TestCase {
*
* @param int $statusCode
*/
- public function testRun($statusCode) {
+ public function testRun(int $statusCode, int $attempt = 0): void {
$target = 'targetURL';
$source = 'sourceURL';
$token = 'token';
- $argument = ['url' => $target, 'token' => $token];
+ $argument = ['url' => $target, 'token' => $token, 'attempt' => $attempt];
$this->timeFactory->method('getTime')->willReturn(42);
@@ -196,7 +197,7 @@ class RequestSharedSecretTest extends TestCase {
$this->invokePrivate($this->requestSharedSecret, 'run', [$argument]);
if (
$statusCode !== Http::STATUS_OK
- && $statusCode !== Http::STATUS_FORBIDDEN
+ && ($statusCode !== Http::STATUS_FORBIDDEN || $attempt < 5)
) {
$this->assertTrue($this->invokePrivate($this->requestSharedSecret, 'retainJob'));
} else {
@@ -207,6 +208,7 @@ class RequestSharedSecretTest extends TestCase {
public function dataTestRun() {
return [
[Http::STATUS_OK],
+ [Http::STATUS_FORBIDDEN, 5],
[Http::STATUS_FORBIDDEN],
[Http::STATUS_CONFLICT],
];