Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[full-ci][tests-only] Improve then steps for suite 'apiFederationToShares2' #40007

Merged
merged 2 commits into from
Apr 26, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
242 changes: 169 additions & 73 deletions tests/acceptance/features/apiFederationToShares2/federated.feature

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Feature: write directly into the folder for received shares
And user "Brian" creates folder "/Shares/aFolder" using the WebDAV API
And user "Alice" shares folder "/shared" with user "Brian" using the sharing API
And user "Brian" accepts share "/shared" offered by user "Alice" using the sharing API
#OCS status code is checked only for Sharing API request
# OCS status code is available only for the Sharing API request
Then the OCS status code of responses on all endpoints should be "100"
And the HTTP status code of responses on each endpoint should be "201, 201, 200, 200" respectively
And as "Brian" folder "/Shares" should exist
Expand Down
20 changes: 20 additions & 0 deletions tests/acceptance/features/bootstrap/AppConfigurationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/

use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use GuzzleHttp\Exception\GuzzleException;
use PHPUnit\Framework\Assert;
use TestHelpers\AppConfigHelper;
use TestHelpers\OcsApiHelper;
Expand All @@ -47,6 +48,7 @@ class AppConfigurationContext implements Context {
* @param string $value
*
* @return void
* @throws Exception
*/
public function adminSetsServerParameterToUsingAPI(
string $parameter,
Expand All @@ -68,6 +70,7 @@ public function adminSetsServerParameterToUsingAPI(
* @param string $value
*
* @return void
* @throws Exception
*/
public function serverParameterHasBeenSetTo(string $parameter, string $app, string $value):void {
// The capturing group of the regex always includes the quotes at each
Expand All @@ -77,6 +80,7 @@ public function serverParameterHasBeenSetTo(string $parameter, string $app, stri
}
$value = \trim($value, $value[0]);
$this->modifyAppConfig($app, $parameter, $value);
$this->featureContext->clearStatusCodeArrays();
}

/**
Expand Down Expand Up @@ -111,6 +115,7 @@ public function theCapabilitiesSettingOfAppParameterShouldBe(
* @param string $capabilitiesPath the path to the element
*
* @return string
* @throws Exception
*/
public function getAppParameter(string $capabilitiesApp, string $capabilitiesPath):string {
return $this->getParameterValueFromXml(
Expand All @@ -126,6 +131,8 @@ public function getAppParameter(string $capabilitiesApp, string $capabilitiesPat
* @param string $username
*
* @return void
* @throws GuzzleException
* @throws JsonException
*/
public function userGetsCapabilities(string $username):void {
$user = $this->featureContext->getActualUsername($username);
Expand Down Expand Up @@ -184,6 +191,7 @@ public function theUserGetsCapabilitiesCheckResponse():void {

/**
* @return string
* @throws Exception
*/
public function getAdminUsernameForCapabilitiesCheck():string {
if (\TestHelpers\OcisHelper::isTestingOnReva()) {
Expand Down Expand Up @@ -225,6 +233,7 @@ public function theAdministratorGetsCapabilitiesCheckResponse():void {
* @param string $exceptionText text to put at the front of exception messages
*
* @return SimpleXMLElement latest retrieved capabilities in XML format
* @throws Exception
*/
public function getCapabilitiesXml(string $exceptionText = ''): SimpleXMLElement {
if ($exceptionText === '') {
Expand All @@ -237,6 +246,7 @@ public function getCapabilitiesXml(string $exceptionText = ''): SimpleXMLElement
* @param string $exceptionText text to put at the front of exception messages
*
* @return SimpleXMLElement latest retrieved version data in XML format
* @throws Exception
*/
public function getVersionXml(string $exceptionText = ''): SimpleXMLElement {
if ($exceptionText === '') {
Expand Down Expand Up @@ -326,6 +336,7 @@ public function parameterValueExistsInXml(
* @param string $value
*
* @return void
* @throws Exception
*/
public function modifyAppConfig(string $app, string $parameter, string $value):void {
AppConfigHelper::modifyAppConfig(
Expand All @@ -344,6 +355,7 @@ public function modifyAppConfig(string $app, string $parameter, string $value):v
* @param array $appParameterValues
*
* @return void
* @throws Exception
*/
public function modifyAppConfigs(array $appParameterValues):void {
AppConfigHelper::modifyAppConfigs(
Expand All @@ -362,6 +374,7 @@ public function modifyAppConfigs(array $appParameterValues):void {
* @param string $url
*
* @return void
* @throws GuzzleException
*/
public function theAdministratorAddsUrlAsTrustedServerUsingTheTestingApi(string $url):void {
$adminUser = $this->featureContext->getAdminUsername();
Expand All @@ -375,6 +388,7 @@ public function theAdministratorAddsUrlAsTrustedServerUsingTheTestingApi(string
['url' => $this->featureContext->substituteInLineCodes($url)]
);
$this->featureContext->setResponse($response);
$this->featureContext->pushToLastStatusCodesArrays();
}

/**
Expand Down Expand Up @@ -456,6 +470,7 @@ public function theTrustedServerListShouldIncludeTheseUrls(TableNode $table):voi
*
* @return void
* @throws Exception
* @throws GuzzleException
*/
public function theAdministratorHasAddedUrlAsTrustedServer(string $url):void {
$this->theAdministratorAddsUrlAsTrustedServerUsingTheTestingApi($url);
Expand All @@ -475,6 +490,7 @@ public function theAdministratorHasAddedUrlAsTrustedServer(string $url):void {
* @param string $url
*
* @return void
* @throws GuzzleException
*/
public function theAdministratorDeletesUrlFromTrustedServersUsingTheTestingApi(string $url):void {
$adminUser = $this->featureContext->getAdminUsername();
Expand Down Expand Up @@ -514,6 +530,7 @@ public function urlShouldNotBeATrustedServer(string $url):void {
* @When the administrator deletes all trusted servers using the testing API
*
* @return void
* @throws GuzzleException
*/
public function theAdministratorDeletesAllTrustedServersUsingTheTestingApi():void {
$adminUser = $this->featureContext->getAdminUsername();
Expand Down Expand Up @@ -564,6 +581,7 @@ public function theTrustedServerListShouldBeEmpty():void {
* Expires last created share using the testing API
*
* @return void
* @throws GuzzleException
*/
public function expireLastCreatedUserShare():void {
$adminUser = $this->featureContext->getAdminUsername();
Expand All @@ -585,6 +603,7 @@ public function expireLastCreatedUserShare():void {
* @Given the administrator has expired the last created share using the testing API
*
* @return void
* @throws GuzzleException
*/
public function theAdministratorHasExpiredTheLastCreatedShare():void {
$this->expireLastCreatedUserShare();
Expand All @@ -599,6 +618,7 @@ public function theAdministratorHasExpiredTheLastCreatedShare():void {
* @When the administrator expires the last created share using the testing API
*
* @return void
* @throws GuzzleException
*/
public function theAdministratorExpiresTheLastCreatedShare():void {
$this->expireLastCreatedUserShare();
Expand Down
20 changes: 17 additions & 3 deletions tests/acceptance/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,12 +372,16 @@ public function getOCSelector(): string {
}

/**
* @param string $httpStatusCode
* @param string|null $httpStatusCode
*
* @return void
*/
public function pushToLastHttpStatusCodesArray(string $httpStatusCode):void {
\array_push($this->lastHttpStatusCodesArray, $httpStatusCode);
public function pushToLastHttpStatusCodesArray(?string $httpStatusCode=null):void {
if ($httpStatusCode !== null) {
$this->lastHttpStatusCodesArray[] = $httpStatusCode;
} elseif ($this->getResponse()->getStatusCode() !== null) {
$this->lastHttpStatusCodesArray[] = (string)$this->getResponse()->getStatusCode();
}
}

/**
Expand All @@ -393,6 +397,15 @@ public function emptyLastHTTPStatusCodesArray():void {
public function emptyLastOCSStatusCodesArray():void {
$this->lastOCSStatusCodesArray = [];
}

/**
* @return void
*/
public function clearStatusCodeArrays():void {
$this->emptyLastHTTPStatusCodesArray();
$this->emptyLastOCSStatusCodesArray();
}

/**
* @param string $ocsStatusCode
*
Expand Down Expand Up @@ -1580,6 +1593,7 @@ public function theHTTPStatusCodeShouldBe($expectedStatusCode, ?string $message
$message
);
}
$this->emptyLastHTTPStatusCodesArray();
}

/**
Expand Down
9 changes: 8 additions & 1 deletion tests/acceptance/features/bootstrap/FederationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class FederationContext implements Context {
* @param string|null $expireDate
*
* @return void
* @throws JsonException
*/
public function userFromServerSharesWithUserFromServerUsingTheSharingAPI(
string $sharerUser,
Expand All @@ -75,7 +76,6 @@ public function userFromServerSharesWithUserFromServerUsingTheSharingAPI(
null,
$expireDate
);
$this->featureContext->pushToLastStatusCodesArrays();
}

/**
Expand All @@ -90,6 +90,7 @@ public function userFromServerSharesWithUserFromServerUsingTheSharingAPI(
* @param string|null $expireDate
*
* @return void
* @throws JsonException
*/
public function userFromServerSharesWithUserFromServerUsingTheSharingAPIWithPermissions(
string $sharerUser,
Expand Down Expand Up @@ -121,6 +122,7 @@ public function userFromServerSharesWithUserFromServerUsingTheSharingAPIWithPerm
null,
$expireDate
);
$this->featureContext->pushToLastStatusCodesArrays();
$this->featureContext->usingServer($previous);
}

Expand Down Expand Up @@ -156,6 +158,7 @@ public function userFromServerHasSharedWithUserFromServer(
$this->featureContext->getResponse()
) . '"'
);
$this->featureContext->emptyLastHTTPStatusCodesArray();
}

/**
Expand Down Expand Up @@ -255,6 +258,7 @@ public function userFromServerAcceptsLastPendingShareUsingTheSharingAPI(string $
"/apps/files_sharing/api/v1/remote_shares/pending/{$share_id}",
null
);
$this->featureContext->pushToLastStatusCodesArrays();
$this->featureContext->usingServer($previous);
}

Expand All @@ -273,6 +277,7 @@ public function userFromServerHasAcceptedLastPendingShare(string $user, string $
$server
);
$this->ocsContext->assertOCSResponseIndicatesSuccess();
$this->featureContext->emptyLastHTTPStatusCodesArray();
}

/**
Expand Down Expand Up @@ -303,6 +308,7 @@ public function userRetrievesInformationOfLastFederatedShare(string $user):void
* @param string $user
*
* @return void
* @throws Exception
*/
public function userShouldHaveNoLastPendingFederatedCloudShare(string $user):void {
$this->userGetsTheListOfPendingFederatedCloudShares($user);
Expand All @@ -313,6 +319,7 @@ public function userShouldHaveNoLastPendingFederatedCloudShare(string $user):voi
__METHOD__
. " No pending federated cloud shares were expected, but got unexpectedly."
);
$this->featureContext->emptyLastHTTPStatusCodesArray();
}

/**
Expand Down
1 change: 1 addition & 0 deletions tests/acceptance/features/bootstrap/OCSContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,7 @@ public function theOCSStatusCodeShouldBe(string $statusCode, $message = ""):void
$statusCodes,
$message
);
$this->featureContext->emptyLastOCSStatusCodesArray();
} else {
if ($message === "") {
$message = "OCS status code is not the expected value " . $statusCodes . " got " . $responseStatusCode;
Expand Down
2 changes: 2 additions & 0 deletions tests/acceptance/features/bootstrap/Sharing.php
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,8 @@ public function addToListOfCreatedPublicLinks(string $name, string $url):void {
* @param string $sharingApp
*
* @return void
* @throws JsonException
* @throws Exception
*/
public function createShare(
string $user,
Expand Down
Loading