Skip to content

Commit

Permalink
Merge pull request #10827 from owncloud/tests-setting-api
Browse files Browse the repository at this point in the history
[tests-only][full-ci] add tests to check settings api response
  • Loading branch information
saw-jan authored Jan 9, 2025
2 parents cd98194 + 11b5e8c commit cccd0e9
Show file tree
Hide file tree
Showing 6 changed files with 348 additions and 5 deletions.
1 change: 1 addition & 0 deletions .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ config = {
"apiDepthInfinity",
"apiLocks",
"apiActivities",
"apiSettings",
],
"skip": False,
},
Expand Down
60 changes: 58 additions & 2 deletions tests/acceptance/bootstrap/SettingsContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function getRoles(string $user): ResponseInterface {
}

/**
* @When /^user "([^"]*)" tries to get all existing roles$/
* @When /^user "([^"]*)" tries to get all existing roles using the settings API$/
*
* @param string $user
*
Expand Down Expand Up @@ -139,6 +139,30 @@ public function theAdministratorHasGivenUserTheRole(string $user, string $role):
);
}

/**
* @When user :assigner assigns the role :role to user :assignee using the settings API
*
* @param string $assigner
* @param string $role
* @param string $assignee
*
* @return void
*
* @throws Exception
*/
public function userAssignsTheRoleToUserUsingTheSettingsApi(
string $assigner,
string $role,
string $assignee
): void {
$response = $this->assignRoleToUser(
$assigner,
$this->featureContext->getAttributeOfCreatedUser($assignee, 'id'),
$this->getRoleIdByRoleName($assigner, $role)
);
$this->featureContext->setResponse($response);
}

/**
* @param string $user
* @param string $role
Expand Down Expand Up @@ -232,7 +256,7 @@ public function userChangeRoleAnotherUser(string $user, string $role, string $as
}

/**
* @When /^user "([^"]*)" tries to get list of assignment$/
* @When /^user "([^"]*)" tries to get list of assignment using the settings API$/
*
* @param string $user
*
Expand Down Expand Up @@ -444,6 +468,22 @@ public function theUserHasSwitchedSystemLanguage(string $user, string $language)
);
}

/**
* @When user :user switches the system language to :language using the settings API
*
* @param string $user
* @param string $language
*
* @return void
*
* @throws Exception
* @throws GuzzleException
*/
public function userSwitchesTheSystemLanguageUsingTheSettingsApi(string $user, string $language): void {
$response = $this->sendRequestToSwitchSystemLanguage($user, $language);
$this->featureContext->setResponse($response);
}

/**
* @param string $user
*
Expand Down Expand Up @@ -497,4 +537,20 @@ public function theUserHasDisabledAutoAccepting(string $user): void {
);
$this->featureContext->rememberUserAutoSyncSetting($user, false);
}

/**
* @When user :user disables the auto-sync share using the settings API
*
* @param string $user
*
* @return void
*
* @throws Exception
* @throws GuzzleException
*/
public function userDisablesAutoAcceptingUsingSettingsApi(string $user): void {
$response = $this->sendRequestToDisableAutoAccepting($user);
$this->featureContext->setResponse($response);
$this->featureContext->rememberUserAutoSyncSetting($user, false);
}
}
9 changes: 9 additions & 0 deletions tests/acceptance/config/behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,15 @@ default:
- OcisConfigContext:
- SettingsContext:

apiSettings:
paths:
- "%paths.base%/../features/apiSettings"
context: *common_ldap_suite_context
contexts:
- FeatureContext: *common_feature_context_params
- GraphContext:
- SettingsContext:

apiSharingNgShareInvitation:
paths:
- "%paths.base%/../features/apiSharingNgShareInvitation"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Feature: assign role
Scenario Outline: only admin user can see all existing roles
Given user "Alice" has been created with default attributes
And the administrator has given "Alice" the role "<user-role>" using the settings api
When user "Alice" tries to get all existing roles
When user "Alice" tries to get all existing roles using the settings API
Then the HTTP status code should be "<http-status-code>"
Examples:
| user-role | http-status-code |
Expand All @@ -19,7 +19,7 @@ Feature: assign role
Scenario Outline: only admin user can see assignments list
Given user "Alice" has been created with default attributes
And the administrator has given "Alice" the role "<user-role>" using the settings api
When user "Alice" tries to get list of assignment
When user "Alice" tries to get list of assignment using the settings API
Then the HTTP status code should be "<http-status-code>"
Examples:
| user-role | http-status-code |
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/features/apiGraph/getAssignedRole.feature
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Feature: assign role
@issue-5032
Scenario Outline: get assigned role of a user via setting api
Given the administrator has assigned the role "<user-role>" to user "Alice" using the Graph API
When user "Alice" tries to get list of assignment
When user "Alice" tries to get list of assignment using the settings API
Then the HTTP status code should be "<http-status-code>"
And the setting API response should have the role "<user-role>"
Examples:
Expand Down
Loading

0 comments on commit cccd0e9

Please sign in to comment.