added checks: who is owner, who has be granted
This commit is contained in:
@@ -53,4 +53,19 @@ Feature: Restoring space
|
|||||||
Then for user "Brian" the space "create data in restored space" should contain these entries:
|
Then for user "Brian" the space "create data in restored space" should contain these entries:
|
||||||
| test.txt |
|
| test.txt |
|
||||||
| mainFolder |
|
| mainFolder |
|
||||||
|
|
||||||
|
|
||||||
|
Scenario: User with viewer permissions cannot restore space
|
||||||
|
Given user "Alice" has created a space "viewer restores space" of type "project" with quota "10"
|
||||||
|
And user "Alice" has shared a space "viewer restores space" to user "Brian" with role "viewer"
|
||||||
|
And user "Alice" has disabled a space "viewer restores space"
|
||||||
|
When user "Brian" restores a disabled space "viewer restores space" without manager rights
|
||||||
|
Then the HTTP status code should be "404"
|
||||||
|
|
||||||
|
|
||||||
|
Scenario: User with editor permissions cannot restore space
|
||||||
|
Given user "Alice" has created a space "editor restores space" of type "project" with quota "10"
|
||||||
|
And user "Alice" has shared a space "editor restores space" to user "Brian" with role "editor"
|
||||||
|
And user "Alice" has disabled a space "editor restores space"
|
||||||
|
When user "Brian" restores a disabled space "editor restores space" without manager rights
|
||||||
|
Then the HTTP status code should be "404"
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ Feature: Share spaces
|
|||||||
Background:
|
Background:
|
||||||
Given user "Alice" has been created with default attributes and without skeleton files
|
Given user "Alice" has been created with default attributes and without skeleton files
|
||||||
And user "Brian" has been created with default attributes and without skeleton files
|
And user "Brian" has been created with default attributes and without skeleton files
|
||||||
|
And user "Bob" has been created with default attributes and without skeleton files
|
||||||
And the administrator has given "Alice" the role "Admin" using the settings api
|
And the administrator has given "Alice" the role "Admin" using the settings api
|
||||||
|
|
||||||
|
|
||||||
@@ -32,13 +33,22 @@ Feature: Share spaces
|
|||||||
Given user "Alice" has created a space "Share space to Brian" of type "project" with quota "10"
|
Given user "Alice" has created a space "Share space to Brian" of type "project" with quota "10"
|
||||||
And user "Alice" has shared a space "Share space to Brian" to user "Brian" with role "viewer"
|
And user "Alice" has shared a space "Share space to Brian" to user "Brian" with role "viewer"
|
||||||
When user "Brian" lists all available spaces via the GraphApi
|
When user "Brian" lists all available spaces via the GraphApi
|
||||||
Then the json responded should contain a space "Share space to Brian" with these key and value pairs:
|
Then the json responded should contain a space "Share space to Brian" owned by "Alice" with these key and value pairs:
|
||||||
| key | value |
|
| key | value |
|
||||||
| driveType | project |
|
| driveType | project |
|
||||||
| id | %space_id% |
|
| id | %space_id% |
|
||||||
| name | Share space to Brian |
|
| name | Share space to Brian |
|
||||||
| quota@@@state | normal |
|
| owner@@@user@@@id | %user_id% |
|
||||||
| root@@@webDavUrl | %base_url%/dav/spaces/%space_id% |
|
|
||||||
|
|
||||||
|
Scenario: A user can see who has been granted access
|
||||||
|
Given user "Alice" has created a space "Share space to Brian" of type "project" with quota "10"
|
||||||
|
And user "Alice" has shared a space "Share space to Brian" to user "Brian" with role "viewer"
|
||||||
|
When user "Alice" lists all available spaces via the GraphApi
|
||||||
|
And the json responded should contain a space "Share space to Brian" granted to "Brian" with these key and value pairs:
|
||||||
|
| key | value |
|
||||||
|
| root@@@permissions@@@1@@@grantedTo@@@0@@@user@@@id | %user_id% |
|
||||||
|
| root@@@permissions@@@1@@@roles@@@0 | viewer |
|
||||||
|
|
||||||
|
|
||||||
Scenario: A user can see a file in a received shared space
|
Scenario: A user can see a file in a received shared space
|
||||||
|
|||||||
@@ -205,6 +205,40 @@ class SpacesContext implements Context {
|
|||||||
return $spaces[$spaceName];
|
return $spaces[$spaceName];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The method returns userId
|
||||||
|
*
|
||||||
|
* @param string $userName
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getUserIdByUserName(string $userName): string {
|
||||||
|
|
||||||
|
$fullUrl = $this->baseUrl . "/api/v0/accounts/accounts-list";
|
||||||
|
$this->featureContext->setResponse(
|
||||||
|
HttpRequestHelper::post(
|
||||||
|
$fullUrl,
|
||||||
|
"",
|
||||||
|
$this->featureContext->getAdminUsername(),
|
||||||
|
$this->featureContext->getAdminPassword(),
|
||||||
|
[],
|
||||||
|
"{}"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
if ($this->featureContext->getResponse()) {
|
||||||
|
$rawBody = $this->featureContext->getResponse()->getBody()->getContents();
|
||||||
|
if (isset(\json_decode($rawBody, true, 512, JSON_THROW_ON_ERROR)["accounts"])) {
|
||||||
|
$accounts = \json_decode($rawBody, true, 512, JSON_THROW_ON_ERROR)["accounts"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach ($accounts as $account) {
|
||||||
|
if ($account["preferredName"] === $userName) {
|
||||||
|
return $account["id"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new Exception(__METHOD__ . " user with name $userName not found");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @BeforeScenario
|
* @BeforeScenario
|
||||||
*
|
*
|
||||||
@@ -718,9 +752,10 @@ class SpacesContext implements Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Then /^the json responded should contain a space "([^"]*)" with these key and value pairs:$/
|
* @Then /^the json responded should contain a space "([^"]*)" (?:|(?:owned by|granted to) "([^"]*)" )with these key and value pairs:$/
|
||||||
*
|
*
|
||||||
* @param string $spaceName
|
* @param string $spaceName
|
||||||
|
* @param string $userName
|
||||||
* @param TableNode $table
|
* @param TableNode $table
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
@@ -728,6 +763,7 @@ class SpacesContext implements Context {
|
|||||||
*/
|
*/
|
||||||
public function jsonRespondedShouldContain(
|
public function jsonRespondedShouldContain(
|
||||||
string $spaceName,
|
string $spaceName,
|
||||||
|
string $userName = '',
|
||||||
TableNode $table
|
TableNode $table
|
||||||
): void {
|
): void {
|
||||||
$this->featureContext->verifyTableNodeColumns($table, ['key', 'value']);
|
$this->featureContext->verifyTableNodeColumns($table, ['key', 'value']);
|
||||||
@@ -745,7 +781,13 @@ class SpacesContext implements Context {
|
|||||||
"function" =>
|
"function" =>
|
||||||
[$this, "getSpaceIdByNameFromResponse"],
|
[$this, "getSpaceIdByNameFromResponse"],
|
||||||
"parameter" => [$spaceName]
|
"parameter" => [$spaceName]
|
||||||
]
|
],
|
||||||
|
[
|
||||||
|
"code" => "%user_id%",
|
||||||
|
"function" =>
|
||||||
|
[$this, "getUserIdByUserName"],
|
||||||
|
"parameter" => [$userName]
|
||||||
|
],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$segments = explode("@@@", $row["key"]);
|
$segments = explode("@@@", $row["key"]);
|
||||||
@@ -1488,19 +1530,24 @@ class SpacesContext implements Context {
|
|||||||
*
|
*
|
||||||
* @param string $user
|
* @param string $user
|
||||||
* @param string $spaceName
|
* @param string $spaceName
|
||||||
|
* @param string $userWithManagerRigths
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
* @throws GuzzleException
|
* @throws GuzzleException
|
||||||
*/
|
*/
|
||||||
public function sendRestoreSpaceRequest(
|
public function sendRestoreSpaceRequest(
|
||||||
string $user,
|
string $user,
|
||||||
string $spaceName
|
string $spaceName,
|
||||||
|
string $userWithManagerRigths = ''
|
||||||
): void {
|
): void {
|
||||||
|
if (!empty($userWithManagerRigths)) {
|
||||||
|
$space = $this->getSpaceByName($userWithManagerRigths, $spaceName);
|
||||||
|
} else {
|
||||||
|
$space = $this->getSpaceByName($user, $spaceName);
|
||||||
|
}
|
||||||
$header = ["restore" => true];
|
$header = ["restore" => true];
|
||||||
$body = '{}';
|
$body = '{}';
|
||||||
$space = $this->getSpaceByName($user, $spaceName);
|
|
||||||
$fullUrl = $this->baseUrl . "/graph/v1.0/drives/" . $space["id"];
|
$fullUrl = $this->baseUrl . "/graph/v1.0/drives/" . $space["id"];
|
||||||
|
|
||||||
$this->featureContext->setResponse(
|
$this->featureContext->setResponse(
|
||||||
HttpRequestHelper::sendRequest(
|
HttpRequestHelper::sendRequest(
|
||||||
$fullUrl,
|
$fullUrl,
|
||||||
@@ -1514,6 +1561,22 @@ class SpacesContext implements Context {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @When /^user "([^"]*)" restores a disabled space "([^"]*)" without manager rights$/
|
||||||
|
*
|
||||||
|
* @param string $user
|
||||||
|
* @param string $spaceName
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @throws GuzzleException
|
||||||
|
*/
|
||||||
|
public function sendRestoreSpaceWithoutRightsRequest(
|
||||||
|
string $user,
|
||||||
|
string $spaceName
|
||||||
|
): void {
|
||||||
|
$this->sendRestoreSpaceRequest($user, $spaceName, $this->featureContext->getAdminUsername());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @When /^user "([^"]*)" has restored a disabled space "([^"]*)"$/
|
* @When /^user "([^"]*)" has restored a disabled space "([^"]*)"$/
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user