diff --git a/tests/acceptance/config/behat.yml b/tests/acceptance/config/behat.yml index 00369a9cb5..0420c0ff50 100644 --- a/tests/acceptance/config/behat.yml +++ b/tests/acceptance/config/behat.yml @@ -149,6 +149,7 @@ default: - OCSContext: - GraphContext: - OcisConfigContext: + - SettingsContext: apiDepthInfinity: paths: diff --git a/tests/acceptance/features/apiCors/cors.feature b/tests/acceptance/features/apiCors/cors.feature index 6b59cd45f7..777aa99190 100644 --- a/tests/acceptance/features/apiCors/cors.feature +++ b/tests/acceptance/features/apiCors/cors.feature @@ -90,3 +90,13 @@ Feature: CORS headers And the following headers should be set | header | value | | Access-Control-Allow-Origin | https://aphno.badal | + + + Scenario: CORS headers should be returned when setting CORS domain sending origin header in the settings api + When user "Alice" lists values-list with headers using the Settings API + | header | value | + | Origin | https://aphno.badal | + Then the HTTP status code should be "201" + And the following headers should be set + | header | value | + | Access-Control-Allow-Origin | https://aphno.badal | diff --git a/tests/acceptance/features/bootstrap/SettingsContext.php b/tests/acceptance/features/bootstrap/SettingsContext.php index 56a73aa003..90d31ef4fe 100644 --- a/tests/acceptance/features/bootstrap/SettingsContext.php +++ b/tests/acceptance/features/bootstrap/SettingsContext.php @@ -15,6 +15,7 @@ use Behat\Behat\Hook\Scope\BeforeScenarioScope; use PHPUnit\Framework\Assert; use Psr\Http\Message\ResponseInterface; use TestHelpers\HttpRequestHelper; +use Behat\Gherkin\Node\TableNode; require_once 'bootstrap.php'; @@ -339,13 +340,14 @@ class SettingsContext implements Context { /** * @param string $user + * @param array $headers * * @return ResponseInterface * * @throws GuzzleException * @throws Exception */ - public function sendRequestGetSettingsValuesList(string $user): ResponseInterface { + public function sendRequestGetSettingsValuesList(string $user, array $headers = null): ResponseInterface { $fullUrl = $this->baseUrl . $this->settingsUrl . "values-list"; $body = json_encode(["account_uuid" => "me"], JSON_THROW_ON_ERROR); return HttpRequestHelper::post( @@ -353,11 +355,33 @@ class SettingsContext implements Context { $this->featureContext->getStepLineRef(), $user, $this->featureContext->getPasswordForUser($user), - null, + $headers, $body ); } + /** + * @When /^user "([^"]*)" lists values-list with headers using the Settings API$/ + * + * @param string $user + * @param TableNode $headersTable + * + * @return void + * + * @throws GuzzleException + * @throws Exception + */ + public function theUserListsAllValuesListWithHeadersUsingSettingsApi(string $user, TableNode $headersTable): void { + $this->featureContext->verifyTableNodeColumns( + $headersTable, + ['header', 'value'] + ); + foreach ($headersTable as $row) { + $headers[$row['header']] = $row ['value']; + } + $this->featureContext->setResponse($this->sendRequestGetSettingsValuesList($user, $headers)); + } + /** * @param string $user *