diff --git a/tests/acceptance/bootstrap/SettingsContext.php b/tests/acceptance/bootstrap/SettingsContext.php index ab5838526aa..79f3dcecf20 100644 --- a/tests/acceptance/bootstrap/SettingsContext.php +++ b/tests/acceptance/bootstrap/SettingsContext.php @@ -26,6 +26,7 @@ */ class SettingsContext implements Context { private FeatureContext $featureContext; + private GraphContext $graphContext; private string $settingsUrl = '/api/v0/settings/'; /** @@ -139,6 +140,26 @@ public function theAdministratorHasGivenUserTheRole(string $user, string $role): ); } + /** + * @When /^the administrator assigns the role "([^"]*)" to user "([^"]*)" using the settings api$/ + * + * @param string $role + * @param string $user + * + * @return void + * + * @throws Exception + */ + public function theAdministratorAssignsUserTheRole(string $role, string $user): void { + $admin = $this->featureContext->getAdminUserName(); + $response = $this->assignRoleToUser( + $admin, + $this->featureContext->getAttributeOfCreatedUser($user, 'id'), + $this->getRoleIdByRoleName($admin, $role) + ); + $this->featureContext->setResponse($response); + } + /** * @param string $user * @param string $role @@ -444,6 +465,21 @@ public function theUserHasSwitchedSystemLanguage(string $user, string $language) ); } + /** + * @When /^user "([^"]*)" switches the system language to "([^"]*)" using the settings API$/ + * + * @param string $user + * @param string $language + * + * @return void + * + * @throws Exception + * @throws GuzzleException + */ + public function userSwitchesTheSystemLanguageUsingTheSettingsApi(string $user, string $language): void { + $this->featureContext->setResponse($this->sendRequestToSwitchSystemLanguage($user, $language)); + } + /** * @param string $user * @@ -497,4 +533,20 @@ public function theUserHasDisabledAutoAccepting(string $user): void { ); $this->featureContext->rememberUserAutoSyncSetting($user, false); } + + /** + * @When user :user disables the auto-sync share + * + * @param string $user + * + * @return void + * + * @throws Exception + * @throws GuzzleException + */ + public function theUserDisabledAutoAccepting(string $user): void { + $response = $this->sendRequestToDisableAutoAccepting($user); + $this->featureContext->setResponse($response); + $this->featureContext->rememberUserAutoSyncSetting($user, false); + } } diff --git a/tests/acceptance/config/behat.yml b/tests/acceptance/config/behat.yml index 57948c74c69..4d3aab5c848 100644 --- a/tests/acceptance/config/behat.yml +++ b/tests/acceptance/config/behat.yml @@ -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" diff --git a/tests/acceptance/features/apiSettings/settings.feature b/tests/acceptance/features/apiSettings/settings.feature new file mode 100644 index 00000000000..9ab9f243abd --- /dev/null +++ b/tests/acceptance/features/apiSettings/settings.feature @@ -0,0 +1,424 @@ +Feature: check settings api response + As a user, + I want to use settings api + + Background: + Given these users have been created with default attributes: + | username | + | Alice | + | Brian | + And using spaces DAV path + + + Scenario: disable auto-sync share + When user "Brian" disables the auto-sync share + Then the HTTP status code should be "201" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "value" + ], + "properties": { + "value" : { + "type": "object", + "required": [ + "identifier", + "value" + ], + "properties": { + "identifier": { + "type": "object", + "required": [ + "extension", + "bundle", + "setting" + ], + "properties": { + "extension": { + "const": "ocis-accounts" + }, + "bundle": { + "const": "profile" + }, + "setting": { + "const": "auto-accept-shares" + } + } + }, + "value": { + "type": "object", + "required": [ + "id", + "bundleId", + "settingId", + "accountUuid", + "resource", + "boolValue" + ], + "properties": { + "id": { + "pattern": "^%user_id_pattern%$" + }, + "bundleId": { + "pattern": "^%user_id_pattern%$" + }, + "settingId": { + "pattern": "^%user_id_pattern%$" + }, + "accountUuid": { + "pattern": "^%user_id_pattern%$" + }, + "resource": { + "type": "object", + "required": ["type"], + "properties": { + "type": { + "const": "TYPE_USER" + } + } + }, + "boolValue": { + "const": false + } + } + } + } + } + } + } + """ + + + Scenario: assign role to user + When the administrator assigns the role "Admin" to user "Alice" using the settings api + Then the HTTP status code should be "201" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "assignment" + ], + "properties": { + "assignment" : { + "type": "object", + "required": [ + "id", + "accountUuid", + "roleId" + ], + "properties": { + "id": { + "type": "string", + "pattern": "^%user_id_pattern%$" + }, + "accountUuid": { + "type": "string", + "pattern": "^%user_id_pattern%$" + }, + "roleId": { + "type": "string", + "pattern": "^%user_id_pattern%$" + } + } + } + } + } + """ + + + Scenario: user lists assignments + Given the administrator has given "Alice" the role "Admin" using the settings api + When user "Alice" tries to get list of assignment + Then the HTTP status code should be "201" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "assignments" + ], + "properties": { + "assignments" : { + "type": "array", + "minItems": 1, + "maxItems": 1, + "uniqueItems": true, + "items": { + "type": "object", + "required": ["id","accountUuid","roleId"], + "properties": { + "id": { + "type": "string", + "pattern": "^%user_id_pattern%$" + }, + "accountUuid": { + "type": "string", + "pattern": "^%user_id_pattern%$" + }, + "roleId": { + "type": "string", + "pattern": "^%user_id_pattern%$" + } + } + } + } + } + } + """ + + + Scenario: switch language + When user "Alice" switches the system language to "de" using the settings API + Then the HTTP status code should be "201" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "value" + ], + "properties": { + "value" : { + "type": "object", + "required": [ + "identifier", + "value" + ], + "properties": { + "identifier": { + "type": "object", + "required": [ + "extension", + "bundle", + "setting" + ], + "properties": { + "extension": { + "const": "ocis-accounts" + }, + "bundle": { + "const": "profile" + }, + "setting": { + "const": "language" + } + } + }, + "value": { + "type": "object", + "required": [ + "id", + "bundleId", + "settingId", + "accountUuid", + "resource", + "listValue" + ], + "properties": { + "id": { + "type": "string", + "pattern": "^%user_id_pattern%$" + }, + "bundleId": { + "type": "string", + "pattern": "^%user_id_pattern%$" + }, + "settingId": { + "type": "string", + "pattern": "^%user_id_pattern%$" + }, + "accountUuid": { + "type": "string", + "pattern": "^%user_id_pattern%$" + }, + "resource": { + "type": "object", + "required": ["type"], + "properties": { + "type": { + "const": "TYPE_USER" + } + } + }, + "listValue": { + "type": "object", + "required": ["values"], + "properties": { + "values": { + "type": "array", + "minItems": 1, + "maxItems": 1, + "items": { + "type": "object", + "required": ["stringValue"], + "properties": { + "stringValue": { + "type": "string", + "const": "de" + } + } + } + } + } + } + } + } + } + } + } + } + """ + + + Scenario: user lists existing roles + Given the administrator has given "Alice" the role "Admin" using the settings api + When user "Alice" tries to get all existing roles + Then the HTTP status code should be "201" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "bundles" + ], + "properties": { + "bundles" : { + "type": "array", + "minItems": 4, + "maxItems": 4, + "uniqueItems": true, + "items": { + "oneOf": [ + { + "type": "object", + "required": ["id", "name", "type", "extension", "displayName", "settings", "resource"], + "properties": { + "id": { + "type": "string", + "pattern": "%user_id_pattern%" + }, + "name": { + "const": "spaceadmin" + }, + "type": { + "const": "TYPE_ROLE" + }, + "extension": { + "const": "ocis-roles" + }, + "displayName": { + "const": "Space Admin" + }, + "resource": { + "type": "object", + "required": ["type"], + "properties": { + "type": { + "const": "TYPE_SYSTEM" + } + } + } + } + }, + { + "type": "object", + "required": ["id", "name", "type", "extension", "displayName", "settings", "resource"], + "properties": { + "id": { + "type": "string", + "pattern": "%user_id_pattern%" + }, + "name": { + "const": "admin" + }, + "type": { + "const": "TYPE_ROLE" + }, + "extension": { + "const": "ocis-roles" + }, + "displayName": { + "const": "Admin" + }, + "resource": { + "type": "object", + "required": ["type"], + "properties": { + "type": { + "const": "TYPE_SYSTEM" + } + } + } + } + }, + { + "type": "object", + "required": ["id", "name", "type", "extension", "displayName", "settings", "resource"], + "properties": { + "id": { + "type": "string", + "pattern": "%user_id_pattern%" + }, + "name": { + "const": "user-light" + }, + "type": { + "const": "TYPE_ROLE" + }, + "extension": { + "const": "ocis-roles" + }, + "displayName": { + "const": "User Light" + }, + "resource": { + "type": "object", + "required": ["type"], + "properties": { + "type": { + "const": "TYPE_SYSTEM" + } + } + } + } + }, + { + "type": "object", + "required": ["id", "name", "type", "extension", "displayName", "settings", "resource"], + "properties": { + "id": { + "type": "string", + "pattern": "%user_id_pattern%" + }, + "name": { + "const": "user" + }, + "type": { + "const": "TYPE_ROLE" + }, + "extension": { + "const": "ocis-roles" + }, + "displayName": { + "const": "User" + }, + "resource": { + "type": "object", + "required": ["type"], + "properties": { + "type": { + "const": "TYPE_SYSTEM" + } + } + } + } + } + ] + } + } + } + } + """