Skip to content

Commit

Permalink
Removed occ related codes
Browse files Browse the repository at this point in the history
  • Loading branch information
grgprarup committed Mar 16, 2023
1 parent 47cddcd commit 174ebd0
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 376 deletions.
29 changes: 1 addition & 28 deletions tests/TestHelpers/SetupHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -464,16 +464,7 @@ public static function readSkeletonFile(
"readSkeletonFile"
);

//find the absolute path of the currently set skeletondirectory
$occResponse = ['code' => '', 'stdOut' => '', 'stdErr' => '' ];
if ((int) $occResponse['code'] !== 0) {
throw new \Exception(
"could not get current skeletondirectory. " . $occResponse['stdErr']
);
}
$skeletonRoot = \trim($occResponse['stdOut']);

$fileInSkeletonFolder = \rawurlencode("$skeletonRoot/$fileInSkeletonFolder");
$fileInSkeletonFolder = \rawurlencode("/$fileInSkeletonFolder");
$response = OcsApiHelper::sendRequest(
$baseUrl,
$adminUsername,
Expand All @@ -492,22 +483,4 @@ public static function readSkeletonFile(
$localContent = \urldecode($localContent);
return $localContent;
}

/**
* Finds all lines containing the given text
*
* @param string|null $input stdout or stderr output
* @param string|null $text text to search for
*
* @return array array of lines that matched
*/
public static function findLines(?string $input, ?string $text):array {
$results = [];
foreach (\explode("\n", $input) as $line) {
if (\strpos($line, $text) !== false) {
$results[] = $line;
}
}
return $results;
}
}
59 changes: 0 additions & 59 deletions tests/acceptance/features/bootstrap/AuthContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,11 @@ class AuthContext implements Context {
*/
private $appTokens;

/**
* @var boolean
*/
private $tokenAuthHasBeenSet = false;

/**
* @var FeatureContext
*/
private $featureContext;

/**
* @var string 'true' or 'false' or ''
*/
private $tokenAuthHasBeenSetTo = '';

/**
* @return string
*/
public function getTokenAuthHasBeenSetTo():string {
return $this->tokenAuthHasBeenSetTo;
}

/**
* get the client token that was last generated
* app acceptance tests that have their own step code may need to use this
Expand Down Expand Up @@ -1083,32 +1066,6 @@ public function aNewBrowserSessionForTheAdministratorHasBeenStarted():void {
$this->aNewBrowserSessionForHasBeenStarted($admin);
}

/**
* @When /^the administrator (enforces|does not enforce)\s?token auth$/
* @Given /^token auth has (not|)\s?been enforced$/
*
* @param string $hasOrNot
*
* @return void
* @throws Exception
*/
public function tokenAuthHasBeenEnforced(string $hasOrNot):void {
$enforce = (($hasOrNot !== "not") && ($hasOrNot !== "does not enforce"));
if ($enforce) {
$value = 'true';
} else {
$value = 'false';
}
$occStatus = ['code' => '', 'stdOut' => '', 'stdErr' => '' ];
if ($occStatus['code'] !== "0") {
throw new \Exception("setSystemConfig token_auth_enforced returned error code " . $occStatus['code']);
}

// Remember that we set this value, so it can be removed after the scenario
$this->tokenAuthHasBeenSet = true;
$this->tokenAuthHasBeenSetTo = $value;
}

/**
*
* @return string
Expand All @@ -1119,22 +1076,6 @@ public function generateAuthTokenForAdmin():string {
return $this->appToken;
}

/**
* delete token_auth_enforced if it was set in the scenario
*
* @AfterScenario
*
* @return void
* @throws Exception
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function deleteTokenAuthEnforcedAfterScenario():void {
if ($this->tokenAuthHasBeenSet) {
$this->tokenAuthHasBeenSet = false;
$this->tokenAuthHasBeenSetTo = '';
}
}

/**
* @When user :user requests :endpoint with :method without retrying
*
Expand Down
134 changes: 0 additions & 134 deletions tests/acceptance/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,29 +301,11 @@ class FeatureContext extends BehatVariablesContext {
*/
public $appConfigurationContext;

/**
* @var array saved configuration of the system before test runs as reported
* by occ config:list
*/
private $savedConfigList = [];

/**
* @var array
*/
private $initialTrustedServer;

/**
* @var int return code of last command
*/
private $occLastCode;
/**
* @var string stdout of last command
*/
private $lastStdOut;
/**
* @var string stderr of last command
*/
private $lastStdErr;
/**
* The codes are stored as strings, even though they are numbers
*
Expand Down Expand Up @@ -379,22 +361,6 @@ public function getOCSelector(): string {
return $this->oCSelector;
}

/**
* @return void
*/
public function resetOccLastCode(): void {
$this->occLastCode = null;
}

/**
* @param int $statusCode
*
* @return void
*/
public function setOccLastCode(?int $statusCode = null): void {
$this->occLastCode = $statusCode;
}

/**
* @param string|null $httpStatusCode
*
Expand Down Expand Up @@ -1057,47 +1023,6 @@ public function getStepLineRef(): string {
return $this->stepLineRef;
}

/**
* get the exit status of the last occ command
* app acceptance tests that have their own step code may need to process this
*
* @return int exit status code of the last occ command
*/
public function getExitStatusCodeOfOccCommand(): ?int {
return $this->occLastCode;
}

/**
* get the normal output of the last occ command
* app acceptance tests that have their own step code may need to process this
*
* @return string normal output of the last occ command
*/
public function getStdOutOfOccCommand(): string {
return $this->lastStdOut;
}

/**
* set the normal output of the last occ command
*
* @param string $stdOut
*
* @return void
*/
public function setStdOutOfOccCommand(string $stdOut): void {
$this->lastStdOut = $stdOut;
}

/**
* get the error output of the last occ command
* app acceptance tests that have their own step code may need to process this
*
* @return string error output of the last occ command
*/
public function getStdErrOfOccCommand(): string {
return $this->lastStdErr;
}

/**
* returns the base URL without any sub-path e.g. http://localhost:8080
* of the base URL http://localhost:8080/owncloud
Expand Down Expand Up @@ -2498,25 +2423,6 @@ public function theAdministratorCreatesFileWithContentInLocalStorageUsingTheTest
$this->setResponse($response);
}

/**
* @Given the administrator has created a file :path in temporary storage with the last exported content using the testing API
*
* @param string $path
*
* @return void
* @throws Exception
*/
public function theAdministratorHasCreatedAFileInTemporaryStorageWithLastExportedContent(
string $path
): void {
$commandOutput = $this->getStdOutOfOccCommand();
$this->copyContentToFileInTemporaryStorageOnSystemUnderTest($path, $commandOutput);
$this->theFileWithContentShouldExistInTheServerRoot(
TEMPORARY_STORAGE_DIR_ON_REMOTE_SERVER . "/$path",
$commandOutput
);
}

/**
* @Given the administrator has created file :path with content :content in local storage :mountPoint
*
Expand Down Expand Up @@ -3944,46 +3850,6 @@ public function restoreTrustedServersAfterScenario(): void {
}
}

/**
* Find exception texts in stderr
*
* @return array of exception texts
*/
public function findExceptions(): array {
$exceptions = [];
$captureNext = false;
// the exception text usually appears after an "[Exception]" row
foreach (\explode("\n", $this->lastStdErr) as $line) {
if (\preg_match('/\[Exception\]/', $line)) {
$captureNext = true;
continue;
}
if ($captureNext) {
$exceptions[] = \trim($line);
$captureNext = false;
}
}

return $exceptions;
}

/**
* remember the result of the last occ command
*
* @param string[] $result associated array with "code", "stdOut", "stdErr"
*
* @return void
*/
public function setResultOfOccCommand(array $result): void {
Assert::assertIsArray($result);
Assert::assertArrayHasKey('code', $result);
Assert::assertArrayHasKey('stdOut', $result);
Assert::assertArrayHasKey('stdErr', $result);
$this->occLastCode = (int)$result['code'];
$this->lastStdOut = $result['stdOut'];
$this->lastStdErr = $result['stdErr'];
}

/**
* @param string $sourceUser
* @param string $targetUser
Expand Down
57 changes: 0 additions & 57 deletions tests/acceptance/features/bootstrap/Provisioning.php
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,6 @@ public function userHasBeenCreatedWithDefaultAttributes(
*/
public function userHasBeenCreatedWithDefaultAttributesAndWithoutSkeletonFiles(string $user):void {
$this->userHasBeenCreatedWithDefaultAttributes($user);
$this->resetOccLastCode();
}

/**
Expand Down Expand Up @@ -757,59 +756,6 @@ public function createLdapGroup(string $group):void {
$this->ldapCreatedGroups[] = $group;
}

/**
*
* @param string $configId
* @param string $configKey
* @param string $configValue
*
* @return void
* @throws Exception
*/
public function setLdapSetting(string $configId, string $configKey, string $configValue):void {
if ($configValue === "") {
$configValue = "''";
}
$substitutions = [
[
"code" => "%ldap_host_without_scheme%",
"function" => [
$this,
"getLdapHostWithoutScheme"
],
"parameter" => []
],
[
"code" => "%ldap_host%",
"function" => [
$this,
"getLdapHost"
],
"parameter" => []
],
[
"code" => "%ldap_port%",
"function" => [
$this,
"getLdapPort"
],
"parameter" => []
]
];
$configValue = $this->substituteInLineCodes(
$configValue,
null,
[],
$substitutions
);
$occResult = ['code' => '', 'stdOut' => '', 'stdErr' => '' ];
if ($occResult['code'] !== "0") {
throw new Exception(
__METHOD__ . " could not set LDAP setting " . $occResult['stdErr']
);
}
}

/**
* deletes LDAP users|groups created during test
*
Expand Down Expand Up @@ -5545,7 +5491,6 @@ public function theListOfGroupsReturnedByTheApiShouldBeEmpty():void {
* @throws Exception
*/
public function afterScenario():void {
$this->waitForDavRequestsToFinish();

if ($this->someUsersHaveBeenCreated()) {
foreach ($this->getCreatedUsers() as $user) {
Expand Down Expand Up @@ -5586,7 +5531,6 @@ public function resetAdminUserAttributes():void {
* @throws Exception
*/
public function cleanupDatabaseUsers():void {
$this->authContext->deleteTokenAuthEnforcedAfterScenario();
$previousServer = $this->currentServer;
$this->usingServer('LOCAL');
foreach ($this->createdUsers as $user => $userData) {
Expand All @@ -5605,7 +5549,6 @@ public function cleanupDatabaseUsers():void {
* @throws Exception
*/
public function cleanupDatabaseGroups():void {
$this->authContext->deleteTokenAuthEnforcedAfterScenario();
$previousServer = $this->currentServer;
$this->usingServer('LOCAL');
foreach ($this->createdGroups as $group => $groupData) {
Expand Down
Loading

0 comments on commit 174ebd0

Please sign in to comment.