From 714a95a66c510ecf7e4fcae4c9d74efceef41634 Mon Sep 17 00:00:00 2001 From: ronaldtebrake Date: Tue, 1 Oct 2019 09:48:56 +0200 Subject: [PATCH 1/5] #2994248 by ronaldtebrake: Make sure on install SM + CM also need to consent --- modules/custom/social_gdpr/social_gdpr.install | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/custom/social_gdpr/social_gdpr.install b/modules/custom/social_gdpr/social_gdpr.install index 70024a25fca..1abce5c9a46 100644 --- a/modules/custom/social_gdpr/social_gdpr.install +++ b/modules/custom/social_gdpr/social_gdpr.install @@ -30,6 +30,9 @@ function _social_gdpr_set_permissions() { user_role_grant_permissions($role->id(), $permissions); } } + + // Only for AN. + user_role_grant_permissions('anonymous', ['without consent']); } /** @@ -43,9 +46,7 @@ function _social_gdpr_set_permissions() { */ function _social_gdpr_get_permissions($role) { // Anonymous. - $permissions['anonymous'] = [ - 'without consent', - ]; + $permissions['anonymous'] = []; // Authenticated. $permissions['authenticated'] = array_merge($permissions['anonymous'], []); From f2100cfc2247a1dd7ece51004481bb157b73bad9 Mon Sep 17 00:00:00 2001 From: ronaldtebrake Date: Tue, 1 Oct 2019 09:52:16 +0200 Subject: [PATCH 2/5] #2994248 by ronaldtebrake: Make sure on install SM + CM also need to consent --- modules/custom/social_gdpr/social_gdpr.install | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/modules/custom/social_gdpr/social_gdpr.install b/modules/custom/social_gdpr/social_gdpr.install index 1abce5c9a46..6ee8722f603 100644 --- a/modules/custom/social_gdpr/social_gdpr.install +++ b/modules/custom/social_gdpr/social_gdpr.install @@ -67,11 +67,7 @@ function _social_gdpr_get_permissions($role) { 'administer inform and consent settings', 'change inform and consent setting status', ]); - - // An authenticated user should give consent when it necessary. - $id = array_search('without consent', $permissions['authenticated']); - unset($permissions['authenticated'][$id]); - + if (isset($permissions[$role])) { return $permissions[$role]; } From 1cefb1f1106b8a88d59d05c357d01eb11f58e5ab Mon Sep 17 00:00:00 2001 From: ronaldtebrake Date: Tue, 1 Oct 2019 11:04:55 +0200 Subject: [PATCH 3/5] #2994248 by ronaldtebrake: whitespace --- modules/custom/social_gdpr/social_gdpr.install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/custom/social_gdpr/social_gdpr.install b/modules/custom/social_gdpr/social_gdpr.install index 6ee8722f603..feb96d60bc9 100644 --- a/modules/custom/social_gdpr/social_gdpr.install +++ b/modules/custom/social_gdpr/social_gdpr.install @@ -73,4 +73,4 @@ function _social_gdpr_get_permissions($role) { } return []; -} +} \ No newline at end of file From 6815fd35f55e4fa7c54958f1e4d3048e626ecb0a Mon Sep 17 00:00:00 2001 From: ronaldtebrake Date: Tue, 1 Oct 2019 11:24:57 +0200 Subject: [PATCH 4/5] #2994248 by ronaldtebrake: whitespace booboo --- modules/custom/social_gdpr/social_gdpr.install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/custom/social_gdpr/social_gdpr.install b/modules/custom/social_gdpr/social_gdpr.install index feb96d60bc9..9a69616b2c3 100644 --- a/modules/custom/social_gdpr/social_gdpr.install +++ b/modules/custom/social_gdpr/social_gdpr.install @@ -67,10 +67,10 @@ function _social_gdpr_get_permissions($role) { 'administer inform and consent settings', 'change inform and consent setting status', ]); - + if (isset($permissions[$role])) { return $permissions[$role]; } return []; -} \ No newline at end of file +} From c37f1860c8a1373b48d9d5bb65fbf3d9f5943ee7 Mon Sep 17 00:00:00 2001 From: ronaldtebrake Date: Wed, 2 Oct 2019 11:47:53 +0200 Subject: [PATCH 5/5] #2994248 by ronaldtebrake: new custom step definition for SM with extra permission plus test update for GDPR --- .../bootstrap/SocialDrupalContext.php | 22 +++++++++++++++++++ .../gdpr/create-data-policy.feature | 2 +- .../gdpr/data-policy-revisions.feature | 12 ++++++---- .../capabilities/gdpr/inform-block.feature | 2 +- .../capabilities/gdpr/user-consent.feature | 10 ++++----- 5 files changed, 37 insertions(+), 11 deletions(-) diff --git a/tests/behat/features/bootstrap/SocialDrupalContext.php b/tests/behat/features/bootstrap/SocialDrupalContext.php index ca0c169fb2c..fdad03ff425 100644 --- a/tests/behat/features/bootstrap/SocialDrupalContext.php +++ b/tests/behat/features/bootstrap/SocialDrupalContext.php @@ -306,4 +306,26 @@ public function iFillInCustomFieldsForThis($type) { // needed to fill in custom required fields for the used type. } + /** + * @Given I am logged in as :name with the :permissions permission(s) + */ + public function assertLoggedInWithPermissionsByName($name, $permissions) { + // Create a temporary role with given permissions. + $permissions = array_map('trim', explode(',', $permissions)); + $role = $this->getDriver()->roleCreate($permissions); + + $manager = $this->getUserManager(); + + // Change internal current user. + $manager->setCurrentUser($manager->getUser($name)); + $user = $manager->getUser($name); + + // Assign the temporary role with given permissions. + $this->getDriver()->userAddRole($user, $role); + $this->roles[] = $role; + + // Login. + $this->login($user); + } + } diff --git a/tests/behat/features/capabilities/gdpr/create-data-policy.feature b/tests/behat/features/capabilities/gdpr/create-data-policy.feature index b4dd3574b00..f95dc8f4c40 100644 --- a/tests/behat/features/capabilities/gdpr/create-data-policy.feature +++ b/tests/behat/features/capabilities/gdpr/create-data-policy.feature @@ -16,7 +16,7 @@ Feature: Create data policy and view new policy Given I am logged in as "behatuser" Then I should be on the homepage - Given I am logged in as "behatsitemanager" + Given I am logged in as "behatsitemanager" with the "without consent" permission And I am on "admin/config/people/data-policy" Then I should be on "data-policy/revisions" And I should see the heading "Revisions" in the "Hero block" region diff --git a/tests/behat/features/capabilities/gdpr/data-policy-revisions.feature b/tests/behat/features/capabilities/gdpr/data-policy-revisions.feature index 5e0dfbfe2ea..e6e45641123 100644 --- a/tests/behat/features/capabilities/gdpr/data-policy-revisions.feature +++ b/tests/behat/features/capabilities/gdpr/data-policy-revisions.feature @@ -8,8 +8,12 @@ Feature: Manage data policy revisions Given I enable the module "social_gdpr" - Given I am logged in as a user with the "sitemanager" role and I have the following fields: - | name | behatsitemanager | + Given users: + | name | mail | status | roles | + | behatsitemanager | behatsitemanager@example.com | 1 | sitemanager | + + + Given I am logged in as "behatsitemanager" with the "without consent" permission When I am on "data-policy/revisions/add" Then I should see "Active" in the ".form-item-active-revision:not(.form-disabled) .control-label" element And I should see "Create new revision" in the ".form-item-new-revision.form-disabled .control-label" element @@ -29,7 +33,7 @@ Feature: Manage data policy revisions And I wait for AJAX to finish Then I should see the text "First version of the data policy." - When I am logged in as "behatsitemanager" + When I am logged in as "behatsitemanager" with the "without consent" permission And I am on "data-policy/revisions" And I click the xth "0" element with the css ".revision-2 .dropdown-toggle" # Press "Edit" button in operations drop-down menu @@ -45,7 +49,7 @@ Feature: Manage data policy revisions And I wait for AJAX to finish Then I should see the text "Second version of the data policy." - When I am logged in as "behatsitemanager" + When I am logged in as "behatsitemanager" with the "without consent" permission And I am on "data-policy/revisions/add" And I fill in the "Description" WYSIWYG editor with "Third version of the data policy." And I check the box "Active" diff --git a/tests/behat/features/capabilities/gdpr/inform-block.feature b/tests/behat/features/capabilities/gdpr/inform-block.feature index ea647c6a8df..4f3a3c2ef66 100644 --- a/tests/behat/features/capabilities/gdpr/inform-block.feature +++ b/tests/behat/features/capabilities/gdpr/inform-block.feature @@ -1,5 +1,5 @@ @api @gdpr @inform-block @DS-5586 @stability @stability-4 -Feature: Inform about personal data colleciton +Feature: Inform about personal data collection Benefit: So I can make an informed decision. Role: As a LU Goal/desire: I want to understand what data the site collects about me diff --git a/tests/behat/features/capabilities/gdpr/user-consent.feature b/tests/behat/features/capabilities/gdpr/user-consent.feature index 343511f73c0..abf09de1d88 100644 --- a/tests/behat/features/capabilities/gdpr/user-consent.feature +++ b/tests/behat/features/capabilities/gdpr/user-consent.feature @@ -15,7 +15,7 @@ Feature: Give user consent Given I enable the module "social_gdpr" - Given I am logged in as "behatsitemanager" + Given I am logged in as "behatsitemanager" with the "without consent" permission When I am on "admin/config/people/data-policy/settings" Then I should see the heading "Data policy settings" in the "Admin page title block" region And I should see checked the box "Enforce consent" @@ -40,7 +40,7 @@ Feature: Give user consent When I click "here" Then I should be on "data-policy-agreement" - When I am logged in as "behatsitemanager" + When I am logged in as "behatsitemanager" with the "without consent" permission And I am on "admin/reports/data-policy-agreements" Then I should not see the text "User consents not found." And I should see "Undecided" in the "td.views-field-state" element @@ -52,7 +52,7 @@ Feature: Give user consent And I press "Save" Then I should be on the homepage - When I am logged in as "behatsitemanager" + When I am logged in as "behatsitemanager" with the "without consent" permission And I am on "admin/reports/data-policy-agreements" Then I should see "Not agree" in the "td.views-field-state" element @@ -62,7 +62,7 @@ Feature: Give user consent And I press "Save" Then I should be on the homepage - When I am logged in as "behatsitemanager" + When I am logged in as "behatsitemanager" with the "without consent" permission And I am on "admin/reports/data-policy-agreements" Then I should see "Agree" in the "td.views-field-state" element @@ -71,7 +71,7 @@ Feature: Give user consent And I am logged in as "behatuser3" And I click "here" And I press "Save" - And I am logged in as "behatsitemanager" + And I am logged in as "behatsitemanager" with the "without consent" permission And I am on "admin/reports/data-policy-agreements" Then I should see the link "behatuser1" And I should see the link "behatuser2"