update the scenarios for service availability check

This commit is contained in:
Prajwol Amatya
2024-11-28 16:01:30 +05:45
parent 15420a3d7b
commit 34dc52d426
9 changed files with 174 additions and 187 deletions
+7 -2
View File
@@ -205,9 +205,14 @@ class AuthContext implements Context {
* @throws Exception
*/
public function userRequestsEndpointsWithNoAuthentication(string $method, TableNode $table):void {
$this->featureContext->verifyTableNodeColumns($table, ['endpoint']);
$this->featureContext->verifyTableNodeColumns($table, ['endpoint'], ['service']);
foreach ($table->getHash() as $row) {
$this->featureContext->setResponse($this->sendRequest($row['endpoint'], $method));
$this->featureContext->setResponse(
$this->sendRequest(
$this->featureContext->substituteInLineCodes($row['endpoint']),
$method
)
);
$this->featureContext->pushToLastStatusCodesArrays();
}
}
+24 -35
View File
@@ -735,15 +735,9 @@ class FeatureContext extends BehatVariablesContext {
*
* @return string
*/
public function removePortFromUrl(string $url): string {
return \str_replace(':9200', '', $url);
}
/**
* @return string
*/
public function getOcPath(): string {
return $this->ocPath;
public function removeSchemeAndPortFromUrl(string $url): string {
$parsedUrl = parse_url($url);
return $parsedUrl["host"];
}
/**
@@ -806,8 +800,17 @@ class FeatureContext extends BehatVariablesContext {
*
* @return string
*/
public function getBaseUrlWithoutSchemeAndPort(): string {
return $this->removePortFromUrl($this->removeSchemeFromUrl($this->getBaseUrl()));
public function getBaseUrlHostName(): string {
return $this->removeSchemeAndPortFromUrl($this->getBaseUrl());
}
/**
* returns the base URL but without "http(s)://" and port
*
* @return string
*/
public function getCollaborationHostName(): string {
return $this->removeSchemeAndPortFromUrl(OcisHelper::getCollaborationServiceUrl());
}
/**
@@ -2206,10 +2209,18 @@ class FeatureContext extends BehatVariablesContext {
"parameter" => []
],
[
"code" => "%base_url_without_scheme_and_port%",
"code" => "%base_url_hostname%",
"function" => [
$this,
"getBaseUrlWithoutSchemeAndPort"
"getBaseUrlHostName"
],
"parameter" => []
],
[
"code" => "%collaboration_hostname%",
"function" => [
$this,
"getCollaborationHostName"
],
"parameter" => []
],
@@ -2995,26 +3006,4 @@ class FeatureContext extends BehatVariablesContext {
}
return false;
}
/**
* @When a user requests these endpoints:
*
* @param TableNode $table
*
* @return void
* @throws Exception
*/
public function userRequestsEndpoints(TableNode $table): void {
$this->verifyTableNodeColumns($table, ['endpoint'], ['service', 'comment']);
foreach ($table->getHash() as $row) {
$this->setResponse(
HttpRequestHelper::sendRequest(
$this->substituteInLineCodes($row['endpoint']),
$this->getStepLineRef()
)
);
$this->pushToLastStatusCodesArrays();
}
}
}