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 7, 2025
1 parent b13a3a3 commit 0d2c48f
Show file tree
Hide file tree
Showing 3 changed files with 485 additions and 0 deletions.
52 changes: 52 additions & 0 deletions tests/acceptance/bootstrap/SettingsContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
*/
class SettingsContext implements Context {
private FeatureContext $featureContext;
private GraphContext $graphContext;
private string $settingsUrl = '/api/v0/settings/';

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

0 comments on commit 0d2c48f

Please sign in to comment.