mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-05-02 16:59:56 -05:00
[test-only] Cors test for settings api (#8286)
* add cors tests for settings api * fix
This commit is contained in:
@@ -149,6 +149,7 @@ default:
|
||||
- OCSContext:
|
||||
- GraphContext:
|
||||
- OcisConfigContext:
|
||||
- SettingsContext:
|
||||
|
||||
apiDepthInfinity:
|
||||
paths:
|
||||
|
||||
@@ -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 |
|
||||
|
||||
@@ -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
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user