mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-04-22 11:09:02 -05:00
test: prepare cli test suite
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* ownCloud
|
||||
*
|
||||
* @author Sajan Gurung <sajan@jankaritech.com>
|
||||
* @copyright Copyright (c) 2024 Sajan Gurung sajan@jankaritech.com
|
||||
*
|
||||
* This code is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License,
|
||||
* as published by the Free Software Foundation;
|
||||
* either version 3 of the License, or any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
*/
|
||||
|
||||
namespace TestHelpers;
|
||||
|
||||
use GuzzleHttp\Exception\ConnectException;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use GuzzleHttp\Psr7\Request;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use TestHelpers\OcisConfigHelper;
|
||||
|
||||
/**
|
||||
* A helper class for running oCIS CLI commands
|
||||
*/
|
||||
class CliHelper {
|
||||
|
||||
/**
|
||||
* @param array $body
|
||||
*
|
||||
* @return ResponseInterface
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public static function runCommand(array $body): ResponseInterface {
|
||||
$url = OcisConfigHelper::getWrapperUrl() . "/command";
|
||||
return OcisConfigHelper::sendRequest($url, "POST", \json_encode($body));
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,7 @@ class OcisConfigHelper {
|
||||
* @return ResponseInterface
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
private static function sendRequest(
|
||||
public static function sendRequest(
|
||||
string $url,
|
||||
string $method,
|
||||
?string $body = ""
|
||||
@@ -54,10 +54,18 @@ class OcisConfigHelper {
|
||||
);
|
||||
|
||||
try {
|
||||
return $client->send($request);
|
||||
$response = $client->send($request);
|
||||
} catch (ConnectException $e) {
|
||||
throw new \Error("Cannot connect to the ociswrapper at the moment, make sure that ociswrapper is running before proceeding with the test run.\n" . $e->getMessage());
|
||||
} catch (GuzzleException $ex) {
|
||||
$response = $ex->getResponse();
|
||||
|
||||
if ($response === null) {
|
||||
throw $ex;
|
||||
}
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,4 +98,22 @@ class OcisConfigHelper {
|
||||
$url = self::getWrapperUrl() . "/rollback";
|
||||
return self::sendRequest($url, "DELETE");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ResponseInterface
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public static function stopOcis(): ResponseInterface {
|
||||
$url = self::getWrapperUrl() . "/stop";
|
||||
return self::sendRequest($url, "POST");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ResponseInterface
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public static function startOcis(): ResponseInterface {
|
||||
$url = self::getWrapperUrl() . "/start";
|
||||
return self::sendRequest($url, "POST");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -368,6 +368,14 @@ default:
|
||||
- SharingNgContext:
|
||||
- SpacesContext:
|
||||
|
||||
cliResetPassword:
|
||||
paths:
|
||||
- "%paths.base%/../features/cliResetPassword"
|
||||
context: *common_ldap_suite_context
|
||||
contexts:
|
||||
- FeatureContext: *common_feature_context_params
|
||||
- CliContext:
|
||||
|
||||
extensions:
|
||||
rdx\behatvars\BehatVariablesExtension: ~
|
||||
|
||||
|
||||
Reference in New Issue
Block a user