Removed method runOcc from FeatureContext, and refactored code

This commit is contained in:
Prarup Gurung
2023-03-15 17:16:54 +05:45
parent 6f7bd454b2
commit aac714be9a
7 changed files with 2 additions and 368 deletions
@@ -3592,75 +3592,6 @@ trait Sharing {
);
}
/**
* @When the administrator adds group :group to the exclude groups from receiving shares list using the occ command
*
* @param string $group
*
* @return int
* @throws Exception
*/
public function administratorAddsGroupToExcludeFromReceivingSharesList(string $group): int {
//get current groups
$occExitCode = $this->runOcc(
['config:app:get files_sharing blacklisted_receiver_groups']
);
$occStdOut = $this->getStdOutOfOccCommand();
$occStdErr = $this->getStdErrOfOccCommand();
if (($occExitCode !== 0) && ($occExitCode !== 1)) {
throw new Exception(
"occ config:app:get files_sharing blacklisted_receiver_groups failed with exit code " .
$occExitCode . ", output " .
$occStdOut . ", error output " .
$occStdErr
);
}
//if the setting was never set before stdOut will be empty and return code will be 1
if (\trim($occStdOut) === "") {
$occStdOut = "[]";
}
$currentGroups = \json_decode($occStdOut, true);
Assert::assertNotNull(
$currentGroups,
"could not json decode app setting 'blacklisted_receiver_groups' of 'files_sharing'\n" .
"stdOut: '" . $occStdOut . "'\n" .
"stdErr: '" . $occStdErr . "'"
);
$currentGroups[] = $group;
return $this->runOcc(
[
'config:app:set',
'files_sharing blacklisted_receiver_groups',
'--value=' . \json_encode($currentGroups)
]
);
}
/**
* @Given the administrator has added group :group to the exclude groups from receiving shares list
*
* @param string $group
*
* @return void
* @throws Exception
*/
public function administratorHasAddedGroupToExcludeFromReceivingSharesList(string $group):void {
$setSettingExitCode = $this->administratorAddsGroupToExcludeFromReceivingSharesList($group);
if ($setSettingExitCode !== 0) {
throw new Exception(
__METHOD__ . " could not set files_sharing blacklisted_receiver_groups " .
$setSettingExitCode . " " .
$this->getStdOutOfOccCommand() . " " .
$this->getStdErrOfOccCommand()
);
}
}
/**
* @When user :user gets share with id :share using the sharing API
*