mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-03 19:00:05 -06:00
* run api tests * run ocis via wrapper * add context, helpers and steps change ocis config * remove separate pipelines for special test cases * add context to behat config * fix suite name * set wrapper url while running tests * fix cors allow env name * address review * add ociswrapper codebase * add ci pipeline to build and cache wrapper * add step to check ociswrapper cache * invalidate wrapper cache and build new * build on pipeline step * undo unnecessary changes * undo unnecessary changes * fix php code * fix ocis run command * use tag for teardown * exclude wrapper vendor in codacy check * fix typos
88 lines
2.1 KiB
PHP
88 lines
2.1 KiB
PHP
<?php declare(strict_types=1);
|
|
/**
|
|
* ownCloud
|
|
*
|
|
* @author Sajan Gurung <sajan@jankaritech.com>
|
|
* @copyright Copyright (c) 2023 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 TestHelpers\HttpRequestHelper;
|
|
use GuzzleHttp\Exception\GuzzleException;
|
|
use GuzzleHttp\Psr7\Request;
|
|
use Psr\Http\Message\ResponseInterface;
|
|
|
|
/**
|
|
* A helper class for configuring oCIS server
|
|
*/
|
|
class OcisConfigHelper {
|
|
/**
|
|
* @param string $url
|
|
* @param string $method
|
|
* @param ?string $body
|
|
*
|
|
* @return ResponseInterface
|
|
* @throws GuzzleException
|
|
*/
|
|
private static function sendRequest(
|
|
string $url,
|
|
string $method,
|
|
?string $body = ""
|
|
): ResponseInterface {
|
|
$client = HttpRequestHelper::createClient();
|
|
$request = new Request(
|
|
$method,
|
|
$url,
|
|
[],
|
|
$body
|
|
);
|
|
return $client->send($request);
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public static function getWrapperUrl(): string {
|
|
$url = \getenv("OCIS_WRAPPER_URL");
|
|
if ($url === false) {
|
|
$url = "http://localhost:5000";
|
|
}
|
|
return $url;
|
|
}
|
|
|
|
/**
|
|
* @param array $envs
|
|
*
|
|
* @return ResponseInterface
|
|
* @throws GuzzleException
|
|
*/
|
|
public static function reConfigureOcis(array $envs): ResponseInterface {
|
|
$url = self::getWrapperUrl() . "/config";
|
|
return self::sendRequest($url, "PUT", \json_encode($envs));
|
|
}
|
|
|
|
/**
|
|
* @return ResponseInterface
|
|
* @throws GuzzleException
|
|
*/
|
|
public static function rollbackOcis(): ResponseInterface {
|
|
$url = self::getWrapperUrl() . "/rollback";
|
|
return self::sendRequest($url, "DELETE");
|
|
}
|
|
}
|