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

[tests-only][full-ci] added test to update share role to existing role after the assigned share role is disabled #10760

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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
72 changes: 72 additions & 0 deletions tests/acceptance/bootstrap/OcisConfigContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,24 @@
* steps needed to re-configure oCIS server
*/
class OcisConfigContext implements Context {
private array $enabledPermissionsRoles = [];

/**
* @return array
*/
public function getEnabledPermissionsRoles(): array {
return $this->enabledPermissionsRoles;
}

/**
* @param array $enabledPermissionsRoles
*
* @return void
*/
public function setEnabledPermissionsRoles(array $enabledPermissionsRoles): void {
$this->enabledPermissionsRoles = $enabledPermissionsRoles;
}

/**
* @Given async upload has been enabled with post-processing delayed to :delayTime seconds
*
Expand Down Expand Up @@ -99,6 +117,60 @@ public function theAdministratorHasEnabledTheRole(string $role): void {
$response->getStatusCode(),
"Failed to enable role $role"
);
$this->setEnabledPermissionsRoles($defaultRoles);
}

/**
* @Given the administrator has enabled the following permissions roles:
*
* @param TableNode $table
*
* @return void
*/
public function theAdministratorHasEnabledTheFollowingPermissionsRoles(TableNode $table): void {
$defaultRoles = array_values(GraphHelper::DEFAULT_PERMISSIONS_ROLES);
foreach ($table->getRows() as $row) {
$roleId = GraphHelper::getPermissionsRoleIdByName($row[0]);
if (!\in_array($row[0], $defaultRoles)) {
$defaultRoles[] = $roleId;
}
}
$envs = [
"GRAPH_AVAILABLE_ROLES" => implode(',', $defaultRoles)
];
$response = OcisConfigHelper::reConfigureOcis($envs);
Assert::assertEquals(
200,
$response->getStatusCode(),
"Failed to enable role"
);
$this->setEnabledPermissionsRoles($defaultRoles);
}

/**
* @Given the administrator has disabled the permissions role :role
*
* @param string $role
*
* @return void
*/
public function theAdministratorHasDisabledThePermissionsRole(string $role): void {
$roleId = GraphHelper::getPermissionsRoleIdByName($role);
$availableRoles = $this->getEnabledPermissionsRoles();

if ($key = array_search($roleId, $availableRoles)) {
unset($availableRoles[$key]);
}
$envs = [
"GRAPH_AVAILABLE_ROLES" => implode(',', $availableRoles),
];
$response = OcisConfigHelper::reConfigureOcis($envs);
Assert::assertEquals(
200,
$response->getStatusCode(),
"Failed to disable role $role"
);
$this->setEnabledPermissionsRoles($availableRoles);
}

/**
Expand Down
1 change: 1 addition & 0 deletions tests/acceptance/config/behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ default:
- FeatureContext: *common_feature_context_params
- SpacesContext:
- SharingNgContext:
- OcisConfigContext:

apiSharingNgLinkSharePermission:
paths:
Expand Down
214 changes: 214 additions & 0 deletions tests/acceptance/features/apiSharingNg1/sharedByMe.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3863,3 +3863,217 @@ Feature: resources shared by user
}
}
"""

@env-config
Scenario Outline: sharer lists the shares shared with Secure Viewer after the role is disabled (Personal Space)
Given the administrator has enabled the permissions role "Secure Viewer"
And user "Alice" has uploaded file with content "some content" to "textfile.txt"
And user "Alice" has created folder "folderToShare"
And user "Alice" has sent the following resource share invitation:
| resource | <resource> |
| space | Personal |
| sharee | Brian |
| shareType | user |
| permissionsRole | Secure Viewer |
And user "Brian" has a share "<resource>" synced
And the administrator has disabled the permissions role "Secure Viewer"
When user "Alice" lists the shares shared by her using the Graph API
Then the HTTP status code should be "200"
And the JSON data of the response should contain resource "<resource>" with the following data:
"""
{
"type": "object",
"required": [
"parentReference",
"permissions",
"name"
],
"properties": {
"permissions": {
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"type": "object",
"required": [
"@libre.graph.permissions.actions",
"grantedToV2",
"id",
"invitation"
],
"properties": {
"@libre.graph.permissions.actions": {
"const": [
"libre.graph/driveItem/path/read",
"libre.graph/driveItem/children/read",
"libre.graph/driveItem/basic/read"
]
},
"roles": { "const": null }
}
}
}
}
}
"""
Examples:
| resource |
| textfile.txt |
| folderToShare |

@env-config
Scenario: sharer lists the shares shared with Denied after the role is disabled (Personal Space)
Given the administrator has enabled the permissions role "Denied"
And user "Alice" has created folder "folderToShare"
And user "Alice" has sent the following resource share invitation:
| resource | folderToShare |
| space | Personal |
| sharee | Brian |
| shareType | user |
| permissionsRole | Denied |
And the administrator has disabled the permissions role "Denied"
When user "Alice" lists the shares shared by her using the Graph API
Then the HTTP status code should be "200"
And the JSON data of the response should contain resource "folderToShare" with the following data:
"""
{
"type": "object",
"required": [
"parentReference",
"permissions",
"name"
],
"properties": {
"permissions": {
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"type": "object",
"required": [
"@libre.graph.permissions.actions",
"grantedToV2",
"id",
"invitation"
],
"properties": {
"@libre.graph.permissions.actions": {
"const": ["none"]
},
"roles": { "const": null }
}
}
}
}
}
"""

@env-config
Scenario Outline: sharer lists the shares shared with Secure Viewer after the role is disabled (Project Space)
Given using spaces DAV path
And the administrator has enabled the permissions role "Secure Viewer"
And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
And user "Alice" has created a space "new-space" with the default quota using the Graph API
And user "Alice" has uploaded a file inside space "new-space" with content "some content" to "textfile.txt"
And user "Alice" has created a folder "folderToShare" in space "new-space"
And user "Alice" has sent the following resource share invitation:
| resource | <resource> |
| space | new-space |
| sharee | Brian |
| shareType | user |
| permissionsRole | Secure Viewer |
And user "Brian" has a share "<resource>" synced
And the administrator has disabled the permissions role "Secure Viewer"
When user "Alice" lists the shares shared by her using the Graph API
Then the HTTP status code should be "200"
And the JSON data of the response should contain resource "<resource>" with the following data:
"""
{
"type": "object",
"required": [
"parentReference",
"permissions",
"name"
],
"properties": {
"permissions": {
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"type": "object",
"required": [
"@libre.graph.permissions.actions",
"grantedToV2",
"id",
"invitation"
],
"properties": {
"@libre.graph.permissions.actions": {
"const": [
"libre.graph/driveItem/path/read",
"libre.graph/driveItem/children/read",
"libre.graph/driveItem/basic/read"
]
},
"roles": { "const": null }
}
}
}
}
}
"""
Examples:
| resource |
| textfile.txt |
| folderToShare |

@env-config
Scenario: sharer lists the shares shared with Denied after the role is disabled (Project Space)
Given using spaces DAV path
And the administrator has enabled the permissions role "Denied"
And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
And user "Alice" has created a space "new-space" with the default quota using the Graph API
And user "Alice" has created a folder "folderToShare" in space "new-space"
And user "Alice" has sent the following resource share invitation:
| resource | folderToShare |
| space | new-space |
| sharee | Brian |
| shareType | user |
| permissionsRole | Denied |
And the administrator has disabled the permissions role "Denied"
When user "Alice" lists the shares shared by her using the Graph API
Then the HTTP status code should be "200"
And the JSON data of the response should contain resource "folderToShare" with the following data:
"""
{
"type": "object",
"required": [
"parentReference",
"permissions",
"name"
],
"properties": {
"permissions": {
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"type": "object",
"required": [
"@libre.graph.permissions.actions",
"grantedToV2",
"id",
"invitation"
],
"properties": {
"@libre.graph.permissions.actions": {
"const": ["none"]
},
"roles": { "const": null }
}
}
}
}
}
"""
Loading