Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tests-Only] Add acceptance test for translated response messages #37069

Merged
merged 1 commit into from
Mar 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ config = {
'apiShareUpdate',
'apiTags',
'apiTrashbin',
'apiTranslation',
'apiVersions',
'apiWebdavLocks',
'apiWebdavLocks2',
Expand Down
7 changes: 7 additions & 0 deletions tests/acceptance/config/behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
30 changes: 30 additions & 0 deletions tests/acceptance/features/apiTranslation/translation.feature
Original file line number Diff line number Diff line change
@@ -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_version> 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 |
5 changes: 3 additions & 2 deletions tests/acceptance/features/bootstrap/OCSContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);
}
Expand Down
15 changes: 11 additions & 4 deletions tests/acceptance/features/bootstrap/Sharing.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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
);
}

Expand Down