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

#2994248 Make sure on install SM + CM also need to consent #1526

Merged
merged 5 commits into from Oct 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 4 additions & 7 deletions modules/custom/social_gdpr/social_gdpr.install
Expand Up @@ -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']);
}

/**
Expand All @@ -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'], []);
Expand All @@ -67,10 +68,6 @@ function _social_gdpr_get_permissions($role) {
'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];
}
Expand Down
22 changes: 22 additions & 0 deletions tests/behat/features/bootstrap/SocialDrupalContext.php
Expand Up @@ -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);
}

}
Expand Up @@ -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
Expand Down
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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"
Expand Down
@@ -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
Expand Down
10 changes: 5 additions & 5 deletions tests/behat/features/capabilities/gdpr/user-consent.feature
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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

Expand All @@ -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

Expand All @@ -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"
Expand Down