diff --git a/.drone.star b/.drone.star index b7f7d357978a..905e60054608 100644 --- a/.drone.star +++ b/.drone.star @@ -101,6 +101,7 @@ config = { 'apiShareUpdate', 'apiTags', 'apiTrashbin', + 'apiTranslation', 'apiVersions', 'apiWebdavLocks', 'apiWebdavLocks2', diff --git a/tests/acceptance/config/behat.yml b/tests/acceptance/config/behat.yml index 3adeaa317bf4..6510e9d441a2 100644 --- a/tests/acceptance/config/behat.yml +++ b/tests/acceptance/config/behat.yml @@ -388,6 +388,13 @@ default: - OccContext: - PublicWebDavContext: + apiTranslation: + paths: + - '%paths.base%/../features/apiTranslation' + context: *common_ldap_suite_context + contexts: + - FeatureContext: *common_feature_context_params + cliAppManagement: paths: - '%paths.base%/../features/cliAppManagement' diff --git a/tests/acceptance/features/apiTranslation/translation.feature b/tests/acceptance/features/apiTranslation/translation.feature new file mode 100644 index 000000000000..5360a84da88a --- /dev/null +++ b/tests/acceptance/features/apiTranslation/translation.feature @@ -0,0 +1,30 @@ +@api +Feature: translate messages in api response to preferred language + As a user + I want response messages to be translated in preferred language + So that I can see and understand the response messages in my language + + Scenario Outline: user tries to get non existing share and uses some preferred language + Given user "user0" has been created with default attributes and without skeleton files + And these users have been created with default attributes and skeleton files: + | username | + | user1 | + | user2 | + And using DAV path + And user "user1" has shared file "textfile0.txt" with user "user2" + When user "user0" gets the info of the last share in language "de-DE" using the sharing API + Then the OCS status code should be "404" + And the OCS status message should be "Fehlerhafte Freigabe-ID, Freigabe existiert nicht" + When user "user0" gets the info of the last share in language "zh-CN" using the sharing API + Then the OCS status code should be "404" + And the OCS status message should be "错误的共享 ID,共享不存在" + When user "user0" gets the info of the last share in language "fr-FR" using the sharing API + Then the OCS status code should be "404" + And the OCS status message should be "Mauvais ID de partage, le partage n'existe pas" + When user "user0" gets the info of the last share in language "es-ES" using the sharing API + Then the OCS status code should be "404" + And the OCS status message should be "El ID del recurso compartido no es correcto, el recurso compartido no existe" + Examples: + | dav_version | + | old | + | new | \ No newline at end of file diff --git a/tests/acceptance/features/bootstrap/OCSContext.php b/tests/acceptance/features/bootstrap/OCSContext.php index 5ed741893c4d..ed36c1d67305 100644 --- a/tests/acceptance/features/bootstrap/OCSContext.php +++ b/tests/acceptance/features/bootstrap/OCSContext.php @@ -114,11 +114,12 @@ public function userHasSentToOcsApiEndpoint($user, $verb, $url, $password = null * @param string $url * @param TableNode|null $body * @param string|null $password + * @param array $headers * * @return void */ public function userSendsHTTPMethodToOcsApiEndpointWithBody( - $user, $verb, $url, $body = null, $password = null + $user, $verb, $url, $body = null, $password = null, $headers = null ) { /** * array of the data to be sent in the body. @@ -143,7 +144,7 @@ public function userSendsHTTPMethodToOcsApiEndpointWithBody( $response = OcsApiHelper::sendRequest( $this->featureContext->getBaseUrl(), $user, $password, $verb, - $url, $bodyArray, $this->featureContext->getOcsApiVersion() + $url, $bodyArray, $this->featureContext->getOcsApiVersion(), $headers ); $this->featureContext->setResponse($response); } diff --git a/tests/acceptance/features/bootstrap/Sharing.php b/tests/acceptance/features/bootstrap/Sharing.php index cd521389b694..aa125f28fc1b 100644 --- a/tests/acceptance/features/bootstrap/Sharing.php +++ b/tests/acceptance/features/bootstrap/Sharing.php @@ -1528,16 +1528,18 @@ public function theUserGetsInfoOfLastShareUsingTheSharingApi() { } /** + * @When /^user "([^"]*)" gets the info of the last share in language "([^"]*)" using the sharing API$/ * @When /^user "([^"]*)" gets the info of the last share using the sharing API$/ * * @param string $user + * @param string $language * * @return void * @throws Exception */ - public function userGetsInfoOfLastShareUsingTheSharingApi($user) { + public function userGetsInfoOfLastShareUsingTheSharingApi($user, $language=null) { $share_id = $this->getLastShareIdOf($user); - $this->getShareData($user, $share_id); + $this->getShareData($user, $share_id, $language); } /** @@ -1604,13 +1606,18 @@ public function extractLastSharedIdFromLastResponse() { * * @param string $user * @param int $share_id + * @param string $language * * @return void */ - public function getShareData($user, $share_id) { + public function getShareData($user, $share_id, $language=null) { $url = $this->getSharesEndpointPath("/$share_id"); + $headers = []; + if ($language !== null) { + $headers['Accept-Language'] = $language; + } $this->ocsContext->userSendsHTTPMethodToOcsApiEndpointWithBody( - $user, "GET", $url, null + $user, "GET", $url, null, null, $headers ); }