tests: update ocm setup and docs

docs: separate provider config

tests: substitution for local and remote server urls

tests: create local configs

tests: fix vscode debugger config

tests: separate federation share steps
This commit is contained in:
Saw-jan
2024-11-11 14:37:52 +05:45
parent 22d80256d6
commit c3b442491d
18 changed files with 576 additions and 420 deletions
@@ -237,6 +237,7 @@ class SharingNgContext implements Context {
* @param string $user
* @param array $shareInfo
* @param string|null $fileId
* @param bool $federatedShare
*
* @return ResponseInterface
*
@@ -244,7 +245,12 @@ class SharingNgContext implements Context {
* @throws GuzzleException
* @throws Exception
*/
public function sendShareInvitation(string $user, array $shareInfo, string $fileId = null): ResponseInterface {
public function sendShareInvitation(
string $user,
array $shareInfo,
string $fileId = null,
bool $federatedShare = false
): ResponseInterface {
if ($shareInfo['space'] === 'Personal' || $shareInfo['space'] === 'Shares') {
$space = $this->spacesContext->getSpaceByName($user, $shareInfo['space']);
} else {
@@ -280,7 +286,7 @@ class SharingNgContext implements Context {
$shareeId = "";
if ($shareType === "user") {
$shareeId = $this->featureContext->getAttributeOfCreatedUser($sharee, 'id');
if (isset($shareInfo['federatedServer'])) {
if ($federatedShare) {
$shareeId = ($this->featureContext->ocmContext->getAcceptedUserByName($user, $sharee))['user_id'];
}
} elseif ($shareType === "group") {
@@ -319,6 +325,7 @@ class SharingNgContext implements Context {
*
* @param string $user
* @param TableNode $table
* @param bool $federatedShare
*
* @return ResponseInterface
*
@@ -326,7 +333,7 @@ class SharingNgContext implements Context {
* @throws GuzzleException
* @throws Exception
*/
public function sendDriveShareInvitation(string $user, TableNode $table): ResponseInterface {
public function sendDriveShareInvitation(string $user, TableNode $table, bool $federatedShare = false): ResponseInterface {
$shareeIds = [];
$rows = $table->getRowsHash();
if ($rows['space'] === 'Personal' || $rows['space'] === 'Shares') {
@@ -349,7 +356,7 @@ class SharingNgContext implements Context {
$shareeId = "";
if ($shareType === "user") {
$shareeId = $this->featureContext->getAttributeOfCreatedUser($sharee, 'id');
if (isset($rows['federatedServer'])) {
if ($federatedShare) {
$shareeId = ($this->featureContext->ocmContext->getAcceptedUserByName($user, $sharee))['user_id'];
}
} elseif ($shareType === "group") {
@@ -379,7 +386,6 @@ class SharingNgContext implements Context {
/**
* @Given /^user "([^"]*)" has sent the following resource share invitation:$/
* @Given /^user "([^"]*)" has sent the following resource share invitation to federated user:$/
*
* @param string $user
* @param TableNode $table
@@ -395,6 +401,23 @@ class SharingNgContext implements Context {
$this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response);
}
/**
* @Given /^user "([^"]*)" has sent the following resource share invitation to federated user:$/
*
* @param string $user
* @param TableNode $table
*
* @return void
* @throws Exception
* @throws GuzzleException
*/
public function userHasSentTheFollowingResourceShareInvitationToFederatedUser(string $user, TableNode $table): void {
$rows = $table->getRowsHash();
Assert::assertArrayHasKey("resource", $rows, "'resource' should be provided in the data-table while sharing a resource");
$response = $this->sendShareInvitation($user, $rows, null, true);
$this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response);
}
/**
* @Given /^user "([^"]*)" has sent the following space share invitation:$/
*
@@ -415,7 +438,6 @@ class SharingNgContext implements Context {
/**
* @When /^user "([^"]*)" sends the following resource share invitation using the Graph API:$/
* @When /^user "([^"]*)" tries to send the following resource share invitation using the Graph API:$/
* @When /^user "([^"]*)" sends the following resource share invitation to federated user using the Graph API:$/
*
* @param string $user
* @param TableNode $table
@@ -432,9 +454,26 @@ class SharingNgContext implements Context {
);
}
/**
* @When /^user "([^"]*)" sends the following resource share invitation to federated user using the Graph API:$/
*
* @param string $user
* @param TableNode $table
*
* @return void
* @throws Exception
* @throws GuzzleException
*/
public function userSendsTheFollowingResourceShareInvitationToFederatedUserUsingTheGraphApi(string $user, TableNode $table): void {
$rows = $table->getRowsHash();
Assert::assertArrayHasKey("resource", $rows, "'resource' should be provided in the data-table while sharing a resource");
$this->featureContext->setResponse(
$this->sendShareInvitation($user, $rows, null, true)
);
}
/**
* @When /^user "([^"]*)" sends the following space share invitation using permissions endpoint of the Graph API:$/
* @When /^user "([^"]*)" tries to send the following space share invitation to federated user using permissions endpoint of the Graph API:$/
*
* @param string $user
* @param TableNode $table
@@ -451,6 +490,24 @@ class SharingNgContext implements Context {
);
}
/**
* @When /^user "([^"]*)" tries to send the following space share invitation to federated user using permissions endpoint of the Graph API:$/
*
* @param string $user
* @param TableNode $table
*
* @return void
* @throws Exception
* @throws GuzzleException
*/
public function userSendsTheFollowingSpaceShareInvitationToFederatedUserUsingPermissionsEndpointOfTheGraphApi(string $user, TableNode $table): void {
$rows = $table->getRowsHash();
Assert::assertArrayNotHasKey("resource", $rows, "'resource' should not be provided in the data-table while sharing a space");
$this->featureContext->setResponse(
$this->sendShareInvitation($user, $rows, null, true)
);
}
/**
* @When user :user updates the last resource share with the following using the Graph API:
*
@@ -1428,7 +1485,6 @@ class SharingNgContext implements Context {
/**
* @When /^user "([^"]*)" (?:tries to send|sends) the following space share invitation using root endpoint of the Graph API:$/
* @When /^user "([^"]*)" tries to send the following space share invitation to federated user using root endpoint of the Graph API:$/
*
* @param string $user
* @param TableNode $table
@@ -1441,6 +1497,20 @@ class SharingNgContext implements Context {
$this->featureContext->setResponse($response);
}
/**
* @When /^user "([^"]*)" tries to send the following space share invitation to federated user using root endpoint of the Graph API:$/
*
* @param string $user
* @param TableNode $table
*
* @return void
* @throws GuzzleException
*/
public function userSendsTheFollowingShareInvitationToFederatedUserUsingRootEndPointTheGraphApi(string $user, TableNode $table):void {
$response = $this->sendDriveShareInvitation($user, $table, true);
$this->featureContext->setResponse($response);
}
/**
* @When user :user updates the last drive share with the following using root endpoint of the Graph API:
*