[tests-only][full-ci] removing the setresponse in given/then step in AppConfigurationContext and AuthContext (#7186)
* removing setting response in the given steps * use response interface * use the returned response * check success response * changed to inline variable * changed variable response_xml to responseXml
This commit is contained in:
@@ -24,6 +24,7 @@ use TestHelpers\HttpRequestHelper;
|
||||
use Behat\Gherkin\Node\TableNode;
|
||||
use Behat\Behat\Context\Context;
|
||||
use TestHelpers\SetupHelper;
|
||||
use \Psr\Http\Message\ResponseInterface;
|
||||
|
||||
/**
|
||||
* Authentication functions
|
||||
@@ -98,7 +99,7 @@ class AuthContext implements Context {
|
||||
* @return void
|
||||
*/
|
||||
public function userRequestsURLWith(string $url, string $method):void {
|
||||
$this->sendRequest($url, $method);
|
||||
$this->featureContext->setResponse($this->sendRequest($url, $method));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,7 +115,7 @@ class AuthContext implements Context {
|
||||
public function userRequestsURLWithNoAuth(string $user, string $url, string $method):void {
|
||||
$userRenamed = $this->featureContext->getActualUsername($user);
|
||||
$url = $this->featureContext->substituteInLineCodes($url, $userRenamed);
|
||||
$this->sendRequest($url, $method);
|
||||
$this->featureContext->setResponse($this->sendRequest($url, $method));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,8 +127,7 @@ class AuthContext implements Context {
|
||||
* @return void
|
||||
*/
|
||||
public function userHasRequestedURLWith(string $url, string $method):void {
|
||||
$this->sendRequest($url, $method);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBeSuccess();
|
||||
$this->featureContext->theHTTPStatusCodeShouldBeBetween(200, 299, $this->sendRequest($url, $method));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -174,7 +174,7 @@ class AuthContext implements Context {
|
||||
$row['endpoint'],
|
||||
$ofUser
|
||||
);
|
||||
$this->sendRequest($row['endpoint'], $method, null, false, $body);
|
||||
$this->featureContext->setResponse($this->sendRequest($row['endpoint'], $method, null, false, $body));
|
||||
$this->featureContext->pushToLastStatusCodesArrays();
|
||||
}
|
||||
}
|
||||
@@ -212,7 +212,7 @@ class AuthContext implements Context {
|
||||
$this->featureContext->emptyLastOCSStatusCodesArray();
|
||||
$this->featureContext->emptyLastHTTPStatusCodesArray();
|
||||
foreach ($table->getHash() as $row) {
|
||||
$this->sendRequest($row['endpoint'], $method);
|
||||
$this->featureContext->setResponse($this->sendRequest($row['endpoint'], $method));
|
||||
$this->featureContext->pushToLastStatusCodesArrays();
|
||||
}
|
||||
}
|
||||
@@ -578,7 +578,7 @@ class AuthContext implements Context {
|
||||
* @param string|null $body
|
||||
* @param array|null $headers
|
||||
*
|
||||
* @return void
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function sendRequest(
|
||||
string $url,
|
||||
@@ -587,7 +587,7 @@ class AuthContext implements Context {
|
||||
bool $useCookies = false,
|
||||
?string $body = null,
|
||||
?array $headers = []
|
||||
):void {
|
||||
):ResponseInterface {
|
||||
// reset responseXml
|
||||
$this->featureContext->setResponseXml([]);
|
||||
|
||||
@@ -605,18 +605,16 @@ class AuthContext implements Context {
|
||||
if (isset($this->requestToken)) {
|
||||
$headers['requesttoken'] = $this->featureContext->getRequestToken();
|
||||
}
|
||||
$this->featureContext->setResponse(
|
||||
HttpRequestHelper::sendRequest(
|
||||
$fullUrl,
|
||||
$this->featureContext->getStepLineRef(),
|
||||
$method,
|
||||
null,
|
||||
null,
|
||||
$headers,
|
||||
$body,
|
||||
null,
|
||||
$cookies
|
||||
)
|
||||
return HttpRequestHelper::sendRequest(
|
||||
$fullUrl,
|
||||
$this->featureContext->getStepLineRef(),
|
||||
$method,
|
||||
null,
|
||||
null,
|
||||
$headers,
|
||||
$body,
|
||||
null,
|
||||
$cookies
|
||||
);
|
||||
}
|
||||
|
||||
@@ -781,13 +779,15 @@ class AuthContext implements Context {
|
||||
} else {
|
||||
$authString = $userRenamed . ":" . $this->featureContext->getActualPassword($password);
|
||||
}
|
||||
$this->sendRequest(
|
||||
$url,
|
||||
$method,
|
||||
'basic ' . \base64_encode($authString),
|
||||
false,
|
||||
$body,
|
||||
$header
|
||||
$this->featureContext->setResponse(
|
||||
$this->sendRequest(
|
||||
$url,
|
||||
$method,
|
||||
'basic ' . \base64_encode($authString),
|
||||
false,
|
||||
$body,
|
||||
$header
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -817,13 +817,15 @@ class AuthContext implements Context {
|
||||
foreach ($headersTable as $row) {
|
||||
$headers[$row['header']] = $row ['value'];
|
||||
}
|
||||
$this->sendRequest(
|
||||
$url,
|
||||
$method,
|
||||
'basic ' . \base64_encode($authString),
|
||||
false,
|
||||
null,
|
||||
$headers
|
||||
$this->featureContext->setResponse(
|
||||
$this->sendRequest(
|
||||
$url,
|
||||
$method,
|
||||
'basic ' . \base64_encode($authString),
|
||||
false,
|
||||
null,
|
||||
$headers
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -884,10 +886,12 @@ class AuthContext implements Context {
|
||||
*/
|
||||
public function userRequestsURLWithUsingBasicTokenAuth(string $user, string $url, string $method):void {
|
||||
$user = $this->featureContext->getActualUsername($user);
|
||||
$this->sendRequest(
|
||||
$url,
|
||||
$method,
|
||||
'basic ' . \base64_encode("$user:" . $this->clientToken)
|
||||
$this->featureContext->setResponse(
|
||||
$this->sendRequest(
|
||||
$url,
|
||||
$method,
|
||||
'basic ' . \base64_encode("$user:" . $this->clientToken)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -914,7 +918,7 @@ class AuthContext implements Context {
|
||||
* @return void
|
||||
*/
|
||||
public function userRequestsURLWithUsingAClientToken(string $url, string $method):void {
|
||||
$this->sendRequest($url, $method, 'token ' . $this->clientToken);
|
||||
$this->featureContext->setResponse($this->sendRequest($url, $method, 'token ' . $this->clientToken));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -939,7 +943,7 @@ class AuthContext implements Context {
|
||||
* @return void
|
||||
*/
|
||||
public function userRequestsURLWithUsingAppPassword(string $url, string $method):void {
|
||||
$this->sendRequest($url, $method, 'token ' . $this->appToken);
|
||||
$this->featureContext->setResponse($this->sendRequest($url, $method, 'token ' . $this->appToken));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -952,7 +956,7 @@ class AuthContext implements Context {
|
||||
* @return void
|
||||
*/
|
||||
public function theUserRequestsWithUsingAppPasswordNamed(string $url, string $method, string $tokenName):void {
|
||||
$this->sendRequest($url, $method, 'token ' . $this->appTokens[$tokenName]['token']);
|
||||
$this->featureContext->setResponse($this->sendRequest($url, $method, 'token ' . $this->appTokens[$tokenName]['token']));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -977,7 +981,7 @@ class AuthContext implements Context {
|
||||
* @return void
|
||||
*/
|
||||
public function userRequestsURLWithBrowserSession(string $url, string $method):void {
|
||||
$this->sendRequest($url, $method, null, true);
|
||||
$this->featureContext->setResponse($this->sendRequest($url, $method, null, true));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user