Skip to content

Commit

Permalink
add test to check settings api response
Browse files Browse the repository at this point in the history
Signed-off-by: prashant-gurung899 <[email protected]>
  • Loading branch information
prashant-gurung899 committed Jan 8, 2025
1 parent 6c95f19 commit 85f09b6
Show file tree
Hide file tree
Showing 6 changed files with 492 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
56 changes: 54 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,26 @@ public function theAdministratorHasGivenUserTheRole(string $user, string $role):
);
}

/**
* @When the administrator assigns the role :role to user :user using the settings API
*
* @param string $role
* @param string $user
*
* @return void
*
* @throws Exception
*/
public function theAdministratorAssignsTheRoleToUserUsingTheSettingsApi(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
Expand Down Expand Up @@ -232,7 +252,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 +464,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 +533,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 85f09b6

Please sign in to comment.