Skip to content

Commit

Permalink
Added conditional Role assign to Dashboard role (#99)
Browse files Browse the repository at this point in the history
* Added conditional Role assign

* Regenerated baseline
  • Loading branch information
mnocon authored Nov 23, 2023
1 parent 77c8a5d commit fd1fc8c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
5 changes: 4 additions & 1 deletion features/personas/change_password.feature
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@setup @changePassword
Feature: User that is allowed to change password

@admin @setup @changePassword
Scenario: Create a Role and assign policies allowing to change password
Given I create a user group "ChangePasswordGroup"
And I create a user "UserPassword" with last name "Change" in group "ChangePasswordGroup"
Expand All @@ -9,3 +9,6 @@ Feature: User that is allowed to change password
| user | login |
| user | password |
And I assign user group "ChangePasswordGroup" to role "ChangePassword"

Scenario: Create a Role and assign policies allowing to change password
Given I assign user group "ChangePasswordGroup" to role "Dashboard" if possible
5 changes: 4 additions & 1 deletion features/personas/subtree_editor.feature
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@setup @subtreeEditor
Feature: Editor that has access only to a Subtree of Content Structure

@admin @setup @subtreeEditor
Scenario: Create a Role and assign policies with limitations to it
Given I create a "DedicatedFolder" Content Type in "Content" with "dedicatedFolder" identifier
| Field Type | Name | Identifier | Required | Searchable | Translatable |
Expand Down Expand Up @@ -54,3 +54,6 @@ Feature: Editor that has access only to a Subtree of Content Structure
And I assign user group "SubtreeEditorsGroup" to role "SubtreeEditorsRole" with limitations:
| limitationType | limitationValue |
| Subtree | /FolderGrandParent/FolderParent |

Scenario: Allow Subtree Editors to preview the Dashbord
Given I assign user group "SubtreeEditorsGroup" to role "Dashboard" if possible
2 changes: 1 addition & 1 deletion phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2701,7 +2701,7 @@ parameters:
path: src/lib/Core/Debug/Shell/Shell.php

-
message: "#^Parameter \\#2 \\$callback of function array_filter expects callable\\(int\\|string\\)\\: mixed, Closure\\(string\\)\\: bool given\\.$#"
message: "#^Parameter \\#2 \\$callback of function array_filter expects \\(callable\\(int\\|string\\)\\: mixed\\)\\|null, Closure\\(string\\)\\: bool given\\.$#"
count: 1
path: src/lib/Core/Debug/Shell/Shell.php

Expand Down
23 changes: 23 additions & 0 deletions src/lib/API/Context/UserContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Behat\Gherkin\Node\TableNode;
use Ibexa\Behat\API\Facade\UserFacade;
use Ibexa\Behat\Core\Behat\ArgumentParser;
use Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException;

class UserContext implements Context
{
Expand Down Expand Up @@ -54,6 +55,28 @@ public function assignUserToRole(string $userName, string $roleName): void
$this->userFacade->assignUserToRole($userName, $roleName);
}

/**
* @Given I assign user :userName to role :roleIdentifier if possible
*/
public function assignUserToRoleIfPossible(string $userName, string $roleIdentifier): void
{
try {
$this->assignUserToRole($userName, $roleIdentifier);
} catch (NotFoundException $e) {
}
}

/**
* @Given I assign user group :userGroupName to role :roleIdentifier if possible
*/
public function assignUserGroupToRoleIfPossible(string $userGroupName, string $roleIdentifier): void
{
try {
$this->assignUserGroupToRole($userGroupName, $roleIdentifier);
} catch (NotFoundException $e) {
}
}

/**
* @Given I assign user group :groupName to role :roleName
* @Given I assign user group :groupName to role :roleName with limitations:
Expand Down

0 comments on commit fd1fc8c

Please sign in to comment.