diff --git a/tests/acceptance/features/bootstrap/FeatureContext.php b/tests/acceptance/features/bootstrap/FeatureContext.php index e3a0f0e55a..a173f5dce3 100644 --- a/tests/acceptance/features/bootstrap/FeatureContext.php +++ b/tests/acceptance/features/bootstrap/FeatureContext.php @@ -181,8 +181,10 @@ class FeatureContext extends BehatVariablesContext { if (\array_key_exists($user, $this->autoSyncSettings)) { return $this->autoSyncSettings[$user]; } - // auto-sync is enabled by default - return true; + $autoSyncSetting = $this->settingsContext->getAutoAcceptSharesSettingValue($user); + $this->autoSyncSettings[$user] = $autoSyncSetting; + + return $autoSyncSetting; } /** @@ -1465,15 +1467,12 @@ class FeatureContext extends BehatVariablesContext { * * @param ResponseInterface|null $response * - * @return object + * @return mixed */ - public function getJsonDecodedResponseBodyContent(ResponseInterface $response = null):?object { + public function getJsonDecodedResponseBodyContent(ResponseInterface $response = null): mixed { $response = $response ?? $this->response; - if ($response !== null) { - $response->getBody()->rewind(); - return json_decode($response->getBody()->getContents()); - } - return null; + $response->getBody()->rewind(); + return json_decode($response->getBody()->getContents(), null, 512, JSON_THROW_ON_ERROR); } /** @@ -2440,12 +2439,14 @@ class FeatureContext extends BehatVariablesContext { $this->ocsContext = new OCSContext(); $this->authContext = new AuthContext(); $this->tusContext = new TUSContext(); + $this->settingsContext = new SettingsContext(); $this->ocsContext->before($scope); $this->authContext->setUpScenario($scope); $this->tusContext->setUpScenario($scope); $environment->registerContext($this->ocsContext); $environment->registerContext($this->authContext); $environment->registerContext($this->tusContext); + $environment->registerContext($this->settingsContext); $scenarioLine = $scope->getScenario()->getLine(); $featureFile = $scope->getFeature()->getFile(); $suiteName = $scope->getSuite()->getName(); diff --git a/tests/acceptance/features/bootstrap/SettingsContext.php b/tests/acceptance/features/bootstrap/SettingsContext.php index b5739178dd..1e1c69194d 100644 --- a/tests/acceptance/features/bootstrap/SettingsContext.php +++ b/tests/acceptance/features/bootstrap/SettingsContext.php @@ -359,6 +359,37 @@ class SettingsContext implements Context { ); } + /** + * @param string $user + * + * @return bool + * + * @throws GuzzleException + * @throws Exception + */ + public function getAutoAcceptSharesSettingValue(string $user): bool { + $response = $this->sendRequestGetSettingsValuesList($user); + $this->featureContext->theHTTPStatusCodeShouldBe( + 201, + "Expected response status code should be 201", + $response + ); + + $body = $this->featureContext->getJsonDecodedResponseBodyContent($response); + + if (empty($body)) { + return true; + } + + foreach ($body->values as $value) { + if ($value->identifier->setting === "auto-accept-shares") { + return $value->value->boolValue; + } + } + + return true; + } + /** * @When /^user "([^"]*)" lists values-list with headers using the Settings API$/ * diff --git a/tests/acceptance/features/bootstrap/SharingNgContext.php b/tests/acceptance/features/bootstrap/SharingNgContext.php index 35ca8439df..8ca8b0e972 100644 --- a/tests/acceptance/features/bootstrap/SharingNgContext.php +++ b/tests/acceptance/features/bootstrap/SharingNgContext.php @@ -1132,6 +1132,8 @@ class SharingNgContext implements Context { ); $this->featureContext->setResponse($response); $this->featureContext->pushToLastStatusCodesArrays(); + // disable check for client.synchronize + $this->featureContext->rememberUserAutoSyncSetting($user, false); } /**