first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-09-30 18:11:26 -04:00
commit e592ca6823
27270 changed files with 5002257 additions and 0 deletions
@@ -0,0 +1,306 @@
@tool @tool_policy
Feature: Viewing acceptances reports and accepting on behalf of other users
In order to manage user acceptances
As a manager
I need to be able to view acceptances and accept on behalf of other users
Background:
Given the following config values are set as admin:
| sitepolicyhandler | tool_policy |
# This is required for now to prevent the overflow region affecting the action menus.
And I change window size to "large"
And the following policies exist:
| Name | Revision | Content | Summary | Status |
| This site policy | | full text2 | short text2 | active |
| This privacy policy | | full text3 | short text3 | draft |
And the following "users" exist:
| username | firstname | lastname | email |
| user1 | User | One | one@example.com |
| user2 | User | Two | two@example.com |
| manager | Max | Manager | man@example.com |
And the following "role assigns" exist:
| user | role | contextlevel | reference |
| manager | manager | System | |
And the following "courses" exist:
| fullname | shortname |
| Course1 | C1 |
And the following "course enrolments" exist:
| user | course | role |
| user1 | C1 | student |
| user2 | C1 | student |
Scenario: View acceptances made by users on their own, single policy
When I log in as "user1"
Then I should see "This site policy"
And I should not see "Course overview"
And I press "Next"
And I set the field "I agree to the This site policy" to "1"
And I press "Next"
And I should see "Calendar"
And I log out
And I log in as "manager"
And I press "Next"
And I set the field "I agree to the This site policy" to "1"
And I press "Next"
And I navigate to "Users > Privacy and policies > User agreements" in site administration
And "Accepted" "text" should exist in the "User One" "table_row"
And "Accepted" "text" should exist in the "Max Manager" "table_row"
And "Pending" "text" should exist in the "User Two" "table_row"
Scenario: Agree on behalf of another user as a manager, single policy, javascript off
Given the following "role capability" exists:
| role | manager |
| tool/policy:acceptbehalf | allow |
When I log in as "manager"
And I press "Next"
And I set the field "I agree to the This site policy" to "1"
And I press "Next"
And I navigate to "Users > Privacy and policies > Manage policies" in site administration
And I click on "1 of 4 (25%)" "link" in the "This site policy" "table_row"
And I click on "Accept This site policy" "link" in the "User One" "table_row"
Then I should see "Accepting policy"
And I should see "User One"
And I should see "This site policy"
And I should see "I acknowledge that I have received a request to give consent on behalf of the above user(s)."
And I set the field "Remarks" to "Consent received from a parent"
And I press "Give consent"
And "Accepted on user's behalf" "text" should exist in the "User One" "table_row"
And "Max Manager" "link" should exist in the "User One" "table_row"
And "Consent received from a parent" "text" should exist in the "User One" "table_row"
And "Pending" "text" should exist in the "User Two" "table_row"
@javascript
Scenario: Agree on behalf of another user as a manager, single policy, javascript on
Given the following "role capability" exists:
| role | manager |
| tool/policy:acceptbehalf | allow |
When I log in as "manager"
And I press "Next"
And I set the field "I agree to the This site policy" to "1"
And I press "Next"
And I should see "Calendar"
And I navigate to "Users > Privacy and policies > Manage policies" in site administration
And I click on "1 of 4 (25%)" "link" in the "This site policy" "table_row"
And I click on "Accept This site policy" "link" in the "User One" "table_row"
Then I should see "Give consent"
And I should see "User One"
And I should see "This site policy"
And I should see "I acknowledge that I have received a request to give consent on behalf of the above user(s)."
And I set the field "Remarks" to "Consent received from a parent"
And I press "Give consent"
And "Accepted on user's behalf" "text" should exist in the "User One" "table_row"
And "Max Manager" "link" should exist in the "User One" "table_row"
And "Consent received from a parent" "text" should exist in the "User One" "table_row"
And "Pending" "text" should exist in the "User Two" "table_row"
Scenario: View acceptances made by users on their own, multiple policies
Given I log in as "admin"
And I navigate to "Users > Privacy and policies > Manage policies" in site administration
And I click on "Set status to \"Active\"" "link" in the "This privacy policy" "table_row"
And I press "Continue"
And I log out
When I log in as "user1"
Then I should see "This site policy"
And I press "Next"
And I should see "This privacy policy"
And I press "Next"
And I set the field "I agree to the This site policy" to "1"
And I set the field "I agree to the This privacy policy" to "1"
And I press "Next"
And I should see "Calendar"
And I log out
And I log in as "manager"
And I press "Next"
And I press "Next"
And I set the field "I agree to the This site policy" to "1"
And I set the field "I agree to the This privacy policy" to "1"
And I press "Next"
And I navigate to "Users > Privacy and policies > User agreements" in site administration
And "Accepted" "text" should exist in the "User One" "table_row"
And "Pending" "text" should not exist in the "User One" "table_row"
And "Accepted" "text" should exist in the "Max Manager" "table_row"
And "Pending" "text" should exist in the "User Two" "table_row"
And "Accepted" "text" should not exist in the "User Two" "table_row"
And I click on "Details" "link" in the "User One" "table_row"
And "Accepted" "text" should exist in the "This site policy" "table_row"
And "Accepted" "text" should exist in the "This privacy policy" "table_row"
And I am on site homepage
And I navigate to "Users > Privacy and policies > User agreements" in site administration
And I click on "Details" "link" in the "User Two" "table_row"
And "Pending" "text" should exist in the "This site policy" "table_row"
And "Pending" "text" should exist in the "This privacy policy" "table_row"
Scenario: Agree on behalf of another user as a manager, multiple policies, javascript off
Given the following "role capability" exists:
| role | manager |
| tool/policy:acceptbehalf | allow |
And I log in as "admin"
And I navigate to "Users > Privacy and policies > Manage policies" in site administration
And I click on "Set status to \"Active\"" "link" in the "This privacy policy" "table_row"
And I press "Continue"
And I log out
When I log in as "manager"
And I press "Next"
And I press "Next"
And I set the field "I agree to the This site policy" to "1"
And I set the field "I agree to the This privacy policy" to "1"
And I press "Next"
And I navigate to "Users > Privacy and policies > User agreements" in site administration
And I click on "Accept This site policy" "link" in the "User One" "table_row"
Then I should see "Accepting policy"
And I should see "User One"
And I should see "This site policy"
And I should see "I acknowledge that I have received a request to give consent on behalf of the above user(s)."
And I set the field "Remarks" to "Consent received from a parent"
And I press "Give consent"
And "Accepted on user's behalf" "text" should exist in the "User One" "table_row"
And "Pending" "text" should exist in the "User One" "table_row"
And I click on "Details" "link" in the "User One" "table_row"
And "Accepted on user's behalf" "text" should exist in the "This site policy" "table_row"
And "Max Manager" "link" should exist in the "This site policy" "table_row"
And "Consent received from a parent" "text" should exist in the "This site policy" "table_row"
And "Pending" "text" should exist in the "This privacy policy" "table_row"
@javascript
Scenario: Agree on behalf of another user as a manager, multiple policies, javascript on
Given the following "role capability" exists:
| role | manager |
| tool/policy:acceptbehalf | allow |
And I log in as "admin"
And I navigate to "Users > Privacy and policies > Manage policies" in site administration
And I click on "Actions" "link_or_button" in the "This privacy policy" "table_row"
And I click on "Set status to \"Active\"" "link" in the "This privacy policy" "table_row"
And I wait until "Activate" "button" exists
And I press "Activate"
And I log out
When I log in as "manager"
And I press "Next"
And I press "Next"
And I set the field "I agree to the This site policy" to "1"
And I set the field "I agree to the This privacy policy" to "1"
And I press "Next"
And I navigate to "Users > Privacy and policies > User agreements" in site administration
And I click on "Accept This site policy" "link" in the "User One" "table_row"
Then I should see "Give consent"
And I should see "User One"
And I should see "This site policy"
And I should see "I acknowledge that I have received a request to give consent on behalf of the above user(s)."
And I set the field "Remarks" to "Consent received from a parent"
And I press "Give consent"
And "Accepted on user's behalf" "text" should exist in the "User One" "table_row"
And "Pending" "text" should exist in the "User One" "table_row"
And I click on "Details" "link" in the "User One" "table_row"
And "Accepted on user's behalf" "text" should exist in the "This site policy" "table_row"
And "Max Manager" "link" should exist in the "This site policy" "table_row"
And "Consent received from a parent" "text" should exist in the "This site policy" "table_row"
And "Pending" "text" should exist in the "This privacy policy" "table_row"
Scenario: Policies and agreements profile link visible for current user
Given I log in as "user1"
And I press "Next"
And I set the field "I agree to the This site policy" to "1"
And I press "Next"
When I follow "Profile" in the user menu
# User can see his own agreements link in the profile.
Then I should see "Policies and agreements"
And I follow "Policies and agreements"
And "Accepted" "text" should exist in the "This site policy" "table_row"
# User can't see agreements link in other user profiles.
And I am on "Course1" course homepage
And I navigate to course participants
And I follow "User Two"
And I should not see "Policies and agreements"
Scenario: Policies and agreements profile link visible also for users who can access on behalf of others
Given the following "role capability" exists:
| role | manager |
| tool/policy:acceptbehalf | allow |
And I log in as "manager"
And I press "Next"
And I set the field "I agree to the This site policy" to "1"
And I press "Next"
# User can see agreements link in other user profiles because has the capability for accepting on behalf of them.
When I am on "Course1" course homepage
And I navigate to course participants
And I follow "User Two"
Then I should see "Policies and agreements"
Scenario: Agree on behalf of another user as an admin who is logged in as a manager
Given the following "role capability" exists:
| role | manager |
| tool/policy:acceptbehalf | allow |
When I log in as "manager"
And I press "Next"
And I set the field "I agree to the This site policy" to "1"
And I press "Next"
And I log out
And I am on the "manager" "user > profile" page logged in as "admin"
And I follow "Log in as"
And I press "Continue"
And I navigate to "Users > Privacy and policies > Manage policies" in site administration
And I click on "1 of 4 (25%)" "link" in the "This site policy" "table_row"
And I click on "Accept This site policy" "link" in the "User One" "table_row"
Then I should see "Accepting policy"
And I should see "User One"
And I should see "This site policy"
And I should see "I acknowledge that I have received a request to give consent on behalf of the above user(s)."
And I set the field "Remarks" to "Consent received from a parent"
And I press "Give consent"
And "Accepted on user's behalf" "text" should exist in the "User One" "table_row"
And "Max Manager" "link" should not exist in the "User One" "table_row"
And "Admin User" "link" should exist in the "User One" "table_row"
And "Consent received from a parent" "text" should exist in the "User One" "table_row"
And "Pending" "text" should exist in the "User Two" "table_row"
@javascript
Scenario: Bulk agree on behalf of another users as a manager, multiple policies, javascript on
Given the following "role capability" exists:
| role | manager |
| tool/policy:acceptbehalf | allow |
And I log in as "admin"
And I navigate to "Users > Privacy and policies > Manage policies" in site administration
And I click on "Actions" "link_or_button" in the "This privacy policy" "table_row"
And I click on "Set status to \"Active\"" "link" in the "This privacy policy" "table_row"
And I wait until "Activate" "button" exists
And I press "Activate"
And I log out
When I log in as "manager"
And I press "Next"
And I press "Next"
And I set the field "I agree to the This site policy" to "1"
And I set the field "I agree to the This privacy policy" to "1"
And I press "Next"
And I navigate to "Users > Privacy and policies > User agreements" in site administration
And I click on "Select" "checkbox" in the "User One" "table_row"
And I press "Consent"
And I should see "Accepting policy"
And I should see "One"
And I click on "Cancel" "button" in the "Accepting policy" "dialogue"
And I should not see "Accepting policy"
And I click on "Select" "checkbox" in the "User Two" "table_row"
And I press "Consent"
And I should see "Accepting policy"
And I should see "User One, User Two"
When I press "Give consent"
Then "Accepted on user's behalf" "text" should exist in the "User One" "table_row"
And "Accepted on user's behalf" "text" should exist in the "User Two" "table_row"
Scenario: View acceptances made by users on their own after inactivating a policy
Given I log in as "user1"
And I should see "This site policy"
And I should not see "Course overview"
And I press "Next"
And I set the field "I agree to the This site policy" to "1"
And I press "Next"
And I should see "Calendar"
And I log out
And I log in as "admin"
And I navigate to "Users > Privacy and policies > Manage policies" in site administration
And I click on "Actions" "link_or_button" in the "This privacy policy" "table_row"
And I click on "Set status to \"Active\"" "link" in the "This privacy policy" "table_row"
And I press "Continue"
And I click on "Set status to \"Inactive\"" "link" in the "This privacy policy" "table_row"
And I press "Continue"
And I log out
When I log in as "user1"
Then I should see "Calendar"
@@ -0,0 +1,125 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Step definition for tool_policy
*
* @package tool_policy
* @category test
* @copyright 2018 Marina Glancy
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(__DIR__ . '/../../../../../lib/behat/behat_base.php');
use Behat\Gherkin\Node\TableNode as TableNode;
/**
* Step definition for tool_policy
*
* @package tool_policy
* @category test
* @copyright 2018 Marina Glancy
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class behat_tool_policy extends behat_base {
/**
* Click on an entry in the edit menu.
*
* @Given /^the following policies exist:$/
*
* Supported table fields:
*
* - Name: Policy name (required).
* - Revision: Revision name (policy version).
* - Status: Policy version status - 'draft', 'active' or 'archived'. Defaults to 'active'.
* - Audience: Target users - 'guest', 'all' or 'loggedin'. Default to 'all'.
* - Type: 0 - site policy, 1 - privacy policy, 2 - third party policy, 99 - other.
* - Summary: Policy summary text.
* - Content: Policy full text.
* - Agreement style (agreementstyle): 0 - On the consent page, 1 - On its own page
* - Agreement optional (optional): 0 - Compulsory policy, 1 - Optional policy
*
* @param TableNode $data
*/
public function the_following_policies_exist(TableNode $data) {
global $CFG;
if (empty($CFG->sitepolicyhandler) || $CFG->sitepolicyhandler !== 'tool_policy') {
throw new Exception('Site policy handler is not set to "tool_policy"');
}
$fields = [
'name',
'revision',
'policy',
'status',
'audience',
'type',
'content',
'summary',
'agreementstyle',
'optional',
];
// Associative array "policy identifier" => id in the database .
$policies = [];
foreach ($data->getHash() as $elementdata) {
$data = (object)[
'audience' => \tool_policy\policy_version::AUDIENCE_ALL,
'archived' => 0,
'type' => 0
];
$elementdata = array_change_key_case($elementdata, CASE_LOWER);
foreach ($elementdata as $key => $value) {
if ($key === 'policy') {
if (array_key_exists($value, $policies)) {
$data->policyid = $policies[$value];
}
} else if ($key === 'status') {
$data->archived = ($value === 'archived');
} else if ($key === 'audience') {
if ($value === 'guest') {
$data->audience = \tool_policy\policy_version::AUDIENCE_GUESTS;
} else if ($value === 'loggedin') {
$data->audience = \tool_policy\policy_version::AUDIENCE_LOGGEDIN;
}
} else if (($key === 'summary' || $key === 'content') && !empty($value)) {
$data->{$key.'_editor'} = ['text' => $value, 'format' => FORMAT_MOODLE];
} else if (in_array($key, $fields) && $value !== '') {
$data->$key = $value;
}
}
if (empty($data->name) || empty($data->content_editor) || empty($data->summary_editor)) {
throw new Exception('Policy is missing at least one of the required fields: name, content, summary');
}
if (!empty($data->policyid)) {
$version = tool_policy\api::form_policydoc_update_new($data);
} else {
$version = \tool_policy\api::form_policydoc_add($data);
}
if (!empty($elementdata['policy'])) {
$policies[$elementdata['policy']] = $version->get('policyid');
}
if (empty($elementdata['status']) || $elementdata['status'] === 'active') {
\tool_policy\api::make_current($version->get('id'));
}
}
}
}
@@ -0,0 +1,877 @@
@tool @tool_policy
Feature: User must accept policy managed by this plugin when logging in and signing up
In order to record user agreement to use the site
As a user
I need to be able to accept site policy during sign up
Scenario: Accept policy on sign up, no site policy
Given the following config values are set as admin:
| registerauth | email |
| passwordpolicy | 0 |
| sitepolicyhandler | tool_policy |
And I am on site homepage
And I follow "Log in"
When I click on "Create new account" "link"
Then I should not see "I understand and agree"
And I set the following fields to these values:
| Username | user1 |
| Password | user1 |
| Email address | user1@address.invalid |
| Email (again) | user1@address.invalid |
| First name | User1 |
| Last name | L1 |
And I press "Create my new account"
And I should see "Confirm your account"
And I should see "An email should have been sent to your address at user1@address.invalid"
And I confirm email for "user1"
And I should see "Thanks, User1 L1"
And I should see "Your registration has been confirmed"
And I open my profile in edit mode
And the field "First name" matches value "User1"
And I log out
# Confirm that user can login and browse the site (edit their profile).
And I log in as "user1"
And I open my profile in edit mode
And the field "First name" matches value "User1"
Scenario: Accept policy on sign up, only draft policy
Given the following config values are set as admin:
| registerauth | email |
| passwordpolicy | 0 |
| sitepolicyhandler | tool_policy |
And the following policies exist:
| Policy | Name | Revision | Content | Summary | Status |
| P1 | This site policy | | full text1 | short text1 | draft |
| P1 | This privacy policy | | full text2 | short text2 | draft |
And I am on site homepage
And I follow "Log in"
When I click on "Create new account" "link"
Then I should not see "I understand and agree"
And I set the following fields to these values:
| Username | user1 |
| Password | user1 |
| Email address | user1@address.invalid |
| Email (again) | user1@address.invalid |
| First name | User1 |
| Last name | L1 |
And I press "Create my new account"
And I should see "Confirm your account"
And I should see "An email should have been sent to your address at user1@address.invalid"
And I confirm email for "user1"
And I should see "Thanks, User1 L1"
And I should see "Your registration has been confirmed"
And I open my profile in edit mode
And the field "First name" matches value "User1"
And I log out
# Confirm that user can login and browse the site (edit their profile).
And I log in as "user1"
And I open my profile in edit mode
And the field "First name" matches value "User1"
Scenario: Accept policy on sign up, one policy
Given the following config values are set as admin:
| registerauth | email |
| passwordpolicy | 0 |
| sitepolicyhandler | tool_policy |
Given the following policies exist:
| Policy | Name | Revision | Content | Summary | Status |
| P1 | This site policy | | full text1 | short text1 | archived |
| P1 | This site policy | | full text2 | short text2 | active |
| P1 | This site policy | | full text3 | short text3 | draft |
And I am on site homepage
And I follow "Log in"
When I click on "Create new account" "link"
Then I should see "This site policy" in the "region-main" "region"
And I should see "short text2"
And I should see "full text2"
And I press "Next"
And I should see "Please agree to the following policies"
And I should see "This site policy" in the "region-main" "region"
And I should see "short text2"
And I should not see "full text2"
And I set the field "I agree to the This site policy" to "1"
And I press "Next"
And I should not see "I understand and agree"
And I set the following fields to these values:
| Username | user1 |
| Password | user1 |
| Email address | user1@address.invalid |
| Email (again) | user1@address.invalid |
| First name | User1 |
| Last name | L1 |
And I press "Create my new account"
And I should see "Confirm your account"
And I should see "An email should have been sent to your address at user1@address.invalid"
And I confirm email for "user1"
And I should see "Thanks, User1 L1"
And I should see "Your registration has been confirmed"
And I open my profile in edit mode
And the field "First name" matches value "User1"
And I log out
# Confirm that user can login and browse the site.
And I log in as "user1"
And I follow "Profile" in the user menu
# User can see his own agreements in the profile.
And I follow "Policies and agreements"
And "Accepted" "text" should exist in the "This site policy" "table_row"
And I log out
Scenario: Accept policy on sign up, multiple policies
Given the following config values are set as admin:
| registerauth | email |
| passwordpolicy | 0 |
| sitepolicyhandler | tool_policy |
Given the following policies exist:
| Name | Type | Revision | Content | Summary | Status | Audience |
| This site policy | 0 | | full text2 | short text2 | active | all |
| This privacy policy | 1 | | full text3 | short text3 | active | loggedin |
| This guests policy | 0 | | full text4 | short text4 | active | guest |
And I am on site homepage
And I follow "Log in"
When I click on "Create new account" "link"
Then I should see "This site policy" in the "region-main" "region"
And I should see "short text2"
And I should see "full text2"
And I press "Next"
And I should see "This privacy policy" in the "region-main" "region"
And I should see "short text3"
And I should see "full text3"
And I press "Next"
And I should see "Please agree to the following policies"
And I should see "This site policy" in the "region-main" "region"
And I should see "short text2"
And I should not see "full text2"
And I should see "This privacy policy" in the "region-main" "region"
And I should see "short text3"
And I should not see "full text3"
And I should not see "This guests policy" in the "region-main" "region"
And I should not see "short text4"
And I should not see "full text4"
And I set the field "I agree to the This site policy" to "1"
And I set the field "I agree to the This privacy policy" to "1"
And I press "Next"
And I should not see "I understand and agree"
And I set the following fields to these values:
| Username | user1 |
| Password | user1 |
| Email address | user1@address.invalid |
| Email (again) | user1@address.invalid |
| First name | User1 |
| Last name | L1 |
And I press "Create my new account"
And I should see "Confirm your account"
And I should see "An email should have been sent to your address at user1@address.invalid"
And I confirm email for "user1"
And I should see "Thanks, User1 L1"
And I should see "Your registration has been confirmed"
And I open my profile in edit mode
And the field "First name" matches value "User1"
And I log out
# Confirm that user can login and browse the site.
And I log in as "user1"
And I follow "Profile" in the user menu
# User can see his own agreements in the profile.
And I follow "Policies and agreements"
And "Accepted" "text" should exist in the "This site policy" "table_row"
And "Accepted" "text" should exist in the "This privacy policy" "table_row"
And I should not see "This guests policy"
And I log out
Scenario: Accept policy on sign up and age verification
Given the following config values are set as admin:
| registerauth | email |
| passwordpolicy | 0 |
| sitepolicyhandler | tool_policy |
| agedigitalconsentverification | 1 |
Given the following policies exist:
| Name | Revision | Content | Summary | Status |
| This site policy | | full text2 | short text2 | active |
And I am on site homepage
And I follow "Log in"
When I click on "Create new account" "link"
Then I should see "Age and location verification"
And I set the field "What is your age?" to "16"
And I set the field "In which country do you live?" to "DZ"
And I press "Proceed"
And I should see "This site policy"
And I should see "short text2"
And I should see "full text2"
And I press "Next"
And I should see "Please agree to the following policies"
And I should see "This site policy"
And I should see "short text2"
And I should not see "full text2"
And I set the field "I agree to the This site policy" to "1"
And I press "Next"
And I should not see "I understand and agree"
And I set the following fields to these values:
| Username | user1 |
| Password | user1 |
| Email address | user1@address.invalid |
| Email (again) | user1@address.invalid |
| First name | User1 |
| Last name | L1 |
And I press "Create my new account"
And I should see "Confirm your account"
And I should see "An email should have been sent to your address at user1@address.invalid"
And I confirm email for "user1"
And I should see "Thanks, User1 L1"
And I should see "Your registration has been confirmed"
And I open my profile in edit mode
And the field "First name" matches value "User1"
And I log out
# Confirm that user can login and browse the site.
And I log in as "user1"
And I follow "Profile" in the user menu
# User can see his own agreements in the profile.
And I follow "Policies and agreements"
And "Accepted" "text" should exist in the "This site policy" "table_row"
And I log out
Scenario: Accept policy on sign up, do not accept all policies
Given the following config values are set as admin:
| registerauth | email |
| passwordpolicy | 0 |
| sitepolicyhandler | tool_policy |
And the following policies exist:
| Name | Type | Revision | Content | Summary | Status | Audience |
| This site policy | 0 | | full text2 | short text2 | active | all |
| This privacy policy | 1 | | full text3 | short text3 | active | loggedin |
And I am on site homepage
And I follow "Log in"
And I click on "Create new account" "link"
And I should see "This site policy"
And I press "Next"
And I should see "This privacy policy"
And I press "Next"
And I should see "Please agree to the following policies"
And I should see "This site policy"
And I should see "This privacy policy"
# Confirm that a notification is displayed if none of the policies are accepted.
When I set the field "I agree to the This site policy" to "0"
And I set the field "I agree to the This privacy policy" to "0"
And I press "Next"
Then I should see "Please agree to the following policies"
And I should see "Before continuing you need to acknowledge all these policies."
# Confirm that a notification is displayed if only some policies are accepted.
When I set the field "I agree to the This site policy" to "1"
And I set the field "I agree to the This privacy policy" to "0"
Then I should see "Please agree to the following policies"
And I should see "Before continuing you need to acknowledge all these policies."
Scenario: Accept policy on login, do not accept all policies
Given the following config values are set as admin:
| registerauth | email |
| passwordpolicy | 0 |
| sitepolicyhandler | tool_policy |
And the following policies exist:
| Name | Type | Revision | Content | Summary | Status | Audience |
| This site policy | 0 | | full text2 | short text2 | active | all |
| This privacy policy | 1 | | full text3 | short text3 | active | loggedin |
And the following "users" exist:
| username | firstname | lastname | email |
| user1 | User | 1 | user1@example.com |
And I log in as "user1"
And I should see "This site policy"
And I press "Next"
And I should see "This privacy policy"
And I press "Next"
And I should see "Please agree to the following policies"
And I should see "This site policy"
And I should see "This privacy policy"
# Confirm that a notification is displayed if none of the policies are accepted.
When I set the field "I agree to the This site policy" to "0"
And I set the field "I agree to the This privacy policy" to "0"
And I press "Next"
Then I should see "Please agree to the following policies"
And I should see "Before continuing you need to acknowledge all these policies."
# Confirm that a notification is displayed if only some policies are accepted.
When I set the field "I agree to the This site policy" to "1"
And I set the field "I agree to the This privacy policy" to "0"
Then I should see "Please agree to the following policies"
And I should see "Before continuing you need to acknowledge all these policies."
# Confirm that user can not browse the site (edit their profile).
When I follow "Profile" in the user menu
Then I should see "Please agree to the following policies"
Scenario: Accept policy on login, accept all policies
Given the following config values are set as admin:
| registerauth | email |
| passwordpolicy | 0 |
| sitepolicyhandler | tool_policy |
And the following policies exist:
| Name | Type | Revision | Content | Summary | Status | Audience |
| This site policy | 0 | | full text2 | short text2 | active | all |
| This privacy policy | 1 | | full text3 | short text3 | active | loggedin |
And the following "users" exist:
| username | firstname | lastname | email |
| user1 | User | 1 | user1@example.com |
And I log in as "user1"
And I should see "This site policy"
And I press "Next"
And I should see "This privacy policy"
And I press "Next"
And I should see "Please agree to the following policies"
And I should see "This site policy"
And I should see "This privacy policy"
# User accepts all policies.
When I set the field "I agree to the This site policy" to "1"
And I set the field "I agree to the This privacy policy" to "1"
And I press "Next"
Then I should not see "Please agree to the following policies"
And I should not see "Before continuing you need to acknowledge all these policies."
# Confirm that user can login and browse the site (edit their profile).
When I open my profile in edit mode
Then the field "First name" matches value "User"
And I log out
# Confirm when logging again as user, the policies are not displayed.
When I log in as "user1"
Then I should not see "This site policy"
And I should not see "This privacy policy"
And I should not see "Please agree to the following policies"
# Confirm that user can login and browse the site (edit their profile).
When I open my profile in edit mode
Then the field "First name" matches value "User"
Scenario: Accept policy on login, accept new policy documents
Given the following config values are set as admin:
| registerauth | email |
| passwordpolicy | 0 |
| sitepolicyhandler | tool_policy |
And the following policies exist:
| Name | Type | Revision | Content | Summary | Status | Audience |
| This site policy | 0 | | full text2 | short text2 | active | all |
| This privacy policy | 1 | | full text3 | short text3 | active | loggedin |
And the following "users" exist:
| username | firstname | lastname | email |
| user1 | User | 1 | user1@example.com |
And I log in as "user1"
And I should see "This site policy"
And I press "Next"
And I should see "This privacy policy"
And I press "Next"
And I should see "Please agree to the following policies"
And I should see "This site policy"
And I should see "This privacy policy"
# User accepts all policies.
When I set the field "I agree to the This site policy" to "1"
And I set the field "I agree to the This privacy policy" to "1"
And I press "Next"
Then I should not see "Please agree to the following policies"
# Confirm that user can login and browse the site (edit their profile).
When I open my profile in edit mode
Then the field "First name" matches value "User"
And I log out
# Create new policy document.
And I log in as "admin"
And I navigate to "Users > Privacy and policies > Manage policies" in site administration
And I should see "Policies and agreements"
And I should see "New policy"
And I follow "New policy"
And I set the following fields to these values:
| Name | This third parties policy |
| Type | Third parties policy |
| User consent | All users |
| Summary | short text4 |
| Full policy | full text4 |
| Active | 1 |
When I press "Save"
Then I should see "Policies and agreements"
And I should see "This third parties policy"
And I log out
# Confirm when logging again as user, the new policies are displayed.
When I log in as "user1"
And I should not see "This site policy"
And I should not see "This privacy policy"
Then I should see "This third parties policy"
And I press "Next"
And I should see "Please agree to the following policies"
And I should see "This third parties policy"
And I set the field "This third parties policy" to "1"
And I press "Next"
# Confirm that user can login and browse the site (edit their profile).
When I open my profile in edit mode
Then the field "First name" matches value "User"
Scenario: Accept policy on login, accept new policy version
Given the following config values are set as admin:
| registerauth | email |
| passwordpolicy | 0 |
| sitepolicyhandler | tool_policy |
And the following policies exist:
| Name | Type | Revision | Content | Summary | Status | Audience |
| This site policy | 0 | | full text2 | short text2 | active | all |
And the following "users" exist:
| username | firstname | lastname | email |
| user1 | User | 1 | user1@example.com |
And I log in as "user1"
And I should see "This site policy"
And I press "Next"
And I should see "Please agree to the following policies"
And I should see "This site policy"
# User accepts policy.
When I set the field "I agree to the This site policy" to "1"
And I press "Next"
Then I should not see "Please agree to the following policies"
# Confirm that user can login and browse the site (edit their profile).
When I open my profile in edit mode
Then the field "First name" matches value "User"
And I log out
# Create new version of the policy document.
And I log in as "admin"
And I navigate to "Users > Privacy and policies > Manage policies" in site administration
# Menu is already open because javascript is disabled.
Then I should see "View"
And I should see "Edit"
And I should see "Set status to \"Inactive\""
When I follow "Edit"
Then I should see "Editing policy"
And I set the field "Name" to "This site policy new version"
And I set the field "Summary" to "short text2 new version"
And I set the field "Full policy" to "full text2 new version"
And I press "Save"
And I log out
# Confirm that the user has to agree to the new version of the policy.
When I log in as "user1"
Then I should see "This site policy new version"
And I should see "short text2 new version"
And I should see "full text2 new version"
When I press "Next"
Then I should see "Please agree to the following policies"
And I should see "This site policy new version"
And I should see "short text2 new version"
# User accepts policy.
And I set the field "I agree to the This site policy new version" to "1"
When I press "Next"
Then I should not see "Please agree to the following policies"
# Confirm that user can login and browse the site (edit their profile).
When I open my profile in edit mode
Then the field "First name" matches value "User"
@javascript
Scenario: Accept policy on login as guest
Given the following config values are set as admin:
| registerauth | email |
| passwordpolicy | 0 |
| sitepolicyhandler | tool_policy |
And the following policies exist:
| Name | Type | Revision | Content | Summary | Status | Audience |
| This site policy | 0 | | full text2 | short text2 | active | all |
| This privacy policy | 1 | | full text3 | short text3 | active | loggedin |
| This guests policy | 0 | | full text4 | short text4 | active | guest |
And I am on site homepage
And I change window size to "large"
And I follow "Log in"
When I press "Access as a guest"
Then I should see "If you continue browsing this website, you agree to our policies"
# Confirm when navigating, the pop-up policies are displayed.
When I am on the "My courses" page
Then I should see "If you continue browsing this website, you agree to our policies"
And I should see "This site policy"
And I should see "This guests policy"
And I should not see "This privacy policy"
# Confirm when clicking on the policy links, the policy content is displayed.
When I click on "This site policy" "link"
Then I should see "full text2"
And I click on "Close" "button" in the "This site policy" "dialogue"
And I should not see "full text2"
When I click on "This guests policy" "link"
Then I should see "full text4"
And I click on "Close" "button" in the "This guests policy" "dialogue"
And I should not see "full text4"
# Confirm when agreeing to policies the pop-up is no longer displayed.
When I follow "Continue"
Then I should not see "If you continue browsing this website, you agree to our policies"
Scenario: Accept policy on sign up, after completing sign up attempt to create another account
Given the following config values are set as admin:
| registerauth | email |
| passwordpolicy | 0 |
| sitepolicyhandler | tool_policy |
Given the following policies exist:
| Name | Type | Revision | Content | Summary | Status | Audience |
| This site policy | 0 | | full text2 | short text2 | active | all |
| This privacy policy | 1 | | full text3 | short text3 | active | loggedin |
| This guests policy | 0 | | full text4 | short text4 | active | guest |
And I am on site homepage
And I follow "Log in"
When I click on "Create new account" "link"
Then I should see "This site policy" in the "region-main" "region"
And I should see "short text2"
And I should see "full text2"
When I press "Next"
Then I should see "This privacy policy" in the "region-main" "region"
And I should see "short text3"
And I should see "full text3"
When I press "Next"
Then I should see "Please agree to the following policies"
And I should see "This site policy" in the "region-main" "region"
And I should see "short text2"
And I should see "This privacy policy" in the "region-main" "region"
And I should see "short text3"
And I should not see "This guests policy" in the "region-main" "region"
And I should not see "short text4"
And I set the field "I agree to the This site policy" to "1"
And I set the field "I agree to the This privacy policy" to "1"
When I press "Next"
Then I should not see "I understand and agree"
And I should see "New account"
And I set the following fields to these values:
| Username | user1 |
| Password | user1 |
| Email address | user1@address.invalid |
| Email (again) | user1@address.invalid |
| First name | User1 |
| Last name | L1 |
When I press "Create my new account"
Then I should see "Confirm your account"
And I should see "An email should have been sent to your address at user1@address.invalid"
And I follow "Log in"
When I click on "Create new account" "link"
# Confirm that the user can view and accept policies when attempting to create another account.
Then I should see "This site policy" in the "region-main" "region"
And I should see "short text2"
And I should see "full text2"
When I press "Next"
Then I should see "This privacy policy" in the "region-main" "region"
And I should see "short text3"
And I should see "full text3"
When I press "Next"
Then I should see "Please agree to the following policies"
And I should see "This site policy" in the "region-main" "region"
And I should see "short text2"
And I should not see "full text2"
And I should see "This privacy policy" in the "region-main" "region"
And I should see "short text3"
And I should not see "full text3"
And I should not see "This guests policy" in the "region-main" "region"
And I should not see "short text4"
And I should not see "full text4"
And I set the field "I agree to the This site policy" to "1"
And I set the field "I agree to the This privacy policy" to "1"
When I press "Next"
Then I should not see "I understand and agree"
And I should see "New account"
Scenario: Accept policy while being logged in as another user
Given the following config values are set as admin:
| sitepolicyhandler | tool_policy |
And the following policies exist:
| Name | Type | Revision | Content | Summary | Status | Audience |
| This site policy | 0 | | full text2 | short text2 | active | all |
| This privacy policy | 1 | | full text3 | short text3 | active | loggedin |
And the following "users" exist:
| username | firstname | lastname | email |
| user1 | User | 1 | user1@example.com |
When I am on the "user1" "user > profile" page logged in as "admin"
And I follow "Log in as"
Then I should see "You are logged in as User 1"
And I press "Continue"
And I should see "Please read our This site policy"
And I press "Next"
And I should see "Please read our This privacy policy"
And I press "Next"
And I should see "Viewing this page on behalf of User 1"
And I set the field "I agree to the This site policy" to "1"
And I set the field "I agree to the This privacy policy" to "1"
And I press "Next"
And I log out
And I log in as "user1"
And I follow "Profile" in the user menu
And I follow "Policies and agreements"
And "Admin User" "link" should exist in the "This site policy" "table_row"
And "Admin User" "link" should exist in the "This privacy policy" "table_row"
Scenario: Log in as another user without capability to accept policies on their behalf
Given the following config values are set as admin:
| sitepolicyhandler | tool_policy |
And the following policies exist:
| Name | Type | Revision | Content | Summary | Status | Audience |
| This site policy | 0 | | full text2 | short text2 | active | all |
| This privacy policy | 1 | | full text3 | short text3 | active | loggedin |
And the following "users" exist:
| username | firstname | lastname | email |
| user1 | User | 1 | user1@example.com |
| manager | Max | Manager | man@example.com |
And the following "role assigns" exist:
| user | role | contextlevel | reference |
| manager | manager | System | |
When I log in as "manager"
And I press "Next"
And I press "Next"
And I set the field "I agree to the This site policy" to "1"
And I set the field "I agree to the This privacy policy" to "1"
And I press "Next"
And I am on the "user1" "user > profile" page
And I follow "Log in as"
Then I should see "You are logged in as User 1"
And I press "Continue"
And I should see "Policies and agreements"
And I should see "No permission to agree to the policies on behalf of this user"
And I should see "Sorry, you do not have the required permission to agree to the following policies on behalf of User 1"
Scenario: Accept policy on sign up as a guest, one policy
Given the following config values are set as admin:
| registerauth | email |
| passwordpolicy | 0 |
| sitepolicyhandler | tool_policy |
Given the following policies exist:
| Policy | Name | Revision | Content | Summary | Status |
| P1 | This site policy | | full text1 | short text1 | archived |
| P1 | This site policy | | full text2 | short text2 | active |
| P1 | This site policy | | full text3 | short text3 | draft |
And I am on site homepage
And I follow "Log in"
# First log in as a guest
And I press "Access as a guest"
# Now sign up
And I follow "Log in"
When I click on "Create new account" "link"
Then I should see "This site policy"
And I should see "short text2"
And I should see "full text2"
And I press "Next"
And I should see "Please agree to the following policies"
And I should see "This site policy"
And I should see "short text2"
And I should not see "full text2"
And I set the field "I agree to the This site policy" to "1"
And I press "Next"
And I should not see "I understand and agree"
And I set the following fields to these values:
| Username | user1 |
| Password | user1 |
| Email address | user1@address.invalid |
| Email (again) | user1@address.invalid |
| First name | User1 |
| Last name | L1 |
And I press "Create my new account"
And I should see "Confirm your account"
And I should see "An email should have been sent to your address at user1@address.invalid"
And I confirm email for "user1"
And I should see "Thanks, User1 L1"
And I should see "Your registration has been confirmed"
And I open my profile in edit mode
And the field "First name" matches value "User1"
And I log out
# Confirm that user can login and browse the site.
And I log in as "user1"
And I follow "Profile" in the user menu
# User can see his own agreements in the profile.
And I follow "Policies and agreements"
And "Accepted" "text" should exist in the "This site policy" "table_row"
And I log out
Scenario: Accepting policies on sign up, multiple policies with different style of giving ageement.
Given the following config values are set as admin:
| registerauth | email |
| passwordpolicy | 0 |
| sitepolicyhandler | tool_policy |
And the following policies exist:
| name | summary | content | agreementstyle |
| Privacy policy | We scan your thoughts | Here goes content. | 0 |
| Digital maturity declaration | You declare be old enough | Here goes content. | 1 |
| Cookies policy | We eat cookies, srsly | Here goes content. | 0 |
| Terms of Service | We teach, you learn | Here goes content. | 1 |
And I am on site homepage
And I follow "Log in"
When I click on "Create new account" "link"
# The first policy with the agreement style "on its own page" must be accepted first.
Then I should see "Digital maturity declaration" in the "region-main" "region"
And I should see "You declare be old enough"
And I should see "Here goes content."
And I press "I agree to the Digital maturity declaration"
# The second policy with the agreement style "on its own page" must be accepted now.
And I should see "Terms of Service" in the "region-main" "region"
And I should see "We teach, you learn"
And I should see "Here goes content."
And I press "I agree to the Terms of Service"
# Only now we see the remaining consent page policies.
And I should see "Policy 1 out of 2"
And I should see "Privacy policy" in the "region-main" "region"
And I should see "We scan your thoughts"
And I should see "Here goes content."
And I press "Next"
And I should see "Policy 2 out of 2"
And I should see "Cookies policy" in the "region-main" "region"
And I should see "We eat cookies, srsly"
And I should see "Here goes content."
And I press "Next"
And I should see "Please agree to the following policies"
And I should see "Privacy policy"
And I should see "Cookies policy"
And I should not see "Digital maturity declaration" in the "region-main" "region"
And I should not see "Terms of Service" in the "region-main" "region"
And I should not see "Here goes content."
And I set the field "I agree to the Privacy policy" to "1"
And I set the field "I agree to the Cookies policy" to "1"
And I press "Next"
And I should see "New account"
And I set the following fields to these values:
| Username | user1 |
| Password | user1 |
| Email address | user1@address.invalid |
| Email (again) | user1@address.invalid |
| First name | User1 |
| Last name | L1 |
And I press "Create my new account"
And I should see "Confirm your account"
And I should see "An email should have been sent to your address at user1@address.invalid"
And I confirm email for "user1"
And I should see "Thanks, User1 L1"
And I should see "Your registration has been confirmed"
And I open my profile in edit mode
And the field "First name" matches value "User1"
And I log out
# Confirm that user can login and browse the site.
And I log in as "user1"
And I follow "Profile" in the user menu
# User can see his own agreements in the profile.
And I follow "Policies and agreements"
And "Accepted" "text" should exist in the "Privacy policy" "table_row"
And "Accepted" "text" should exist in the "Cookies policy" "table_row"
And "Accepted" "text" should exist in the "Terms of Service" "table_row"
And "Accepted" "text" should exist in the "Digital maturity declaration" "table_row"
And I log out
Scenario: Accepting policies on login, multiple policies with different style of giving ageement.
Given the following config values are set as admin:
| sitepolicyhandler | tool_policy |
And the following policies exist:
| name | summary | content | agreementstyle |
| Digital maturity declaration | You declare be old enough | Here goes content. | 1 |
| Privacy policy | We scan your thoughts | Here goes content. | 0 |
| Terms of Service | We teach, you learn | Here goes content. | 1 |
| Cookies policy | We eat cookies, srsly | Here goes content. | 0 |
And the following "users" exist:
| username | firstname | lastname | email |
| user1 | User | One | user1@example.com |
And I log in as "user1"
# The first policy with the agreement style "on its own page" must be accepted first.
Then I should see "Digital maturity declaration" in the "region-main" "region"
And I should see "You declare be old enough"
And I should see "Here goes content."
And I press "I agree to the Digital maturity declaration"
# The second policy with the agreement style "on its own page" must be accepted now.
And I should see "Terms of Service" in the "region-main" "region"
And I should see "We teach, you learn"
And I should see "Here goes content."
# If the user logs out now, only the first policy is accepted and we return to the same page.
And I log out
And I log in as "user1"
And I should see "Terms of Service" in the "region-main" "region"
And I should see "We teach, you learn"
And I should see "Here goes content."
And I press "I agree to the Terms of Service"
# Only now we see the remaining consent page policies.
And I should see "Policy 1 out of 2"
And I should see "Privacy policy" in the "region-main" "region"
And I should see "We scan your thoughts"
And I should see "Here goes content."
And I press "Next"
And I should see "Policy 2 out of 2"
And I should see "Cookies policy" in the "region-main" "region"
And I should see "We eat cookies, srsly"
And I should see "Here goes content."
And I press "Next"
And I should see "Please agree to the following policies"
And I should see "Privacy policy"
And I should see "Cookies policy"
And I should not see "Digital maturity declaration" in the "region-main" "region"
And I should not see "Terms of Service" in the "region-main" "region"
And I should not see "Here goes content."
And I set the field "I agree to the Privacy policy" to "1"
And I set the field "I agree to the Cookies policy" to "1"
And I press "Next"
And I follow "Profile" in the user menu
# User can see his own agreements in the profile.
And I follow "Policies and agreements"
And "Accepted" "text" should exist in the "Privacy policy" "table_row"
And "Accepted" "text" should exist in the "Cookies policy" "table_row"
And "Accepted" "text" should exist in the "Terms of Service" "table_row"
And "Accepted" "text" should exist in the "Digital maturity declaration" "table_row"
And I log out
Scenario: Accepting policies on login, all and loggedin policies to be accepted on their own page.
Given the following config values are set as admin:
| sitepolicyhandler | tool_policy |
And the following policies exist:
| name | summary | content | agreementstyle | audience |
| Privacy policy | We scan your thoughts | Here goes content. | 1 | all |
| Digital maturity declaration | You declare be old enough | Here goes content. | 1 | loggedin |
| Cookies policy | We eat cookies, srsly | Here goes content. | 1 | guest |
| Terms of Service | We teach, you learn | Here goes content. | 1 | all |
And the following "users" exist:
| username | firstname | lastname | email |
| user1 | User | One | user1@example.com |
And I log in as "user1"
# All the policies to be displayed one by one with a button to accept each of them prior seeing the next.
Then I should see "Privacy policy" in the "region-main" "region"
And I should see "We scan your thoughts"
And I should see "Here goes content."
And I press "I agree to the Privacy policy"
And I should see "Digital maturity declaration" in the "region-main" "region"
And I should see "You declare be old enough"
And I should see "Here goes content."
And I press "I agree to the Digital maturity declaration"
And I should see "Terms of Service" in the "region-main" "region"
And I should see "We teach, you learn"
And I should see "Here goes content."
And I press "I agree to the Terms of Service"
And I follow "Profile" in the user menu
And I follow "Policies and agreements"
And "Accepted" "text" should exist in the "Privacy policy" "table_row"
And "Accepted" "text" should exist in the "Terms of Service" "table_row"
And "Accepted" "text" should exist in the "Digital maturity declaration" "table_row"
And "Cookies policy" "table_row" should not exist
And I log out
Scenario: Accepting policies on sign up, policies to be accepted on their own page.
Given the following config values are set as admin:
| registerauth | email |
| passwordpolicy | 0 |
| sitepolicyhandler | tool_policy |
And the following policies exist:
| name | summary | content | agreementstyle | audience |
| Privacy policy | We scan your thoughts | Here goes content. | 1 | guest |
| Digital maturity declaration | You declare be old enough | Here goes content. | 1 | all |
| Cookies policy | We eat cookies, srsly | Here goes content. | 1 | loggedin |
| Terms of Service | We teach, you learn | Here goes content. | 1 | guest |
And I am on site homepage
And I follow "Log in"
When I click on "Create new account" "link"
# All the policies to be displayed one by one with a button to accept each of them prior seeing the next.
Then I should see "Digital maturity declaration" in the "region-main" "region"
And I should see "You declare be old enough"
And I should see "Here goes content."
And I press "I agree to the Digital maturity declaration"
And I should see "Cookies policy" in the "region-main" "region"
And I should see "We eat cookies, srsly"
And I press "I agree to the Cookies policy"
And I should see "New account"
And I set the following fields to these values:
| Username | user1 |
| Password | user1 |
| Email address | user1@address.invalid |
| Email (again) | user1@address.invalid |
| First name | User1 |
| Last name | L1 |
And I press "Create my new account"
And I should see "Confirm your account"
And I should see "An email should have been sent to your address at user1@address.invalid"
And I confirm email for "user1"
And I should see "Thanks, User1 L1"
And I should see "Your registration has been confirmed"
And I open my profile in edit mode
And the field "First name" matches value "User1"
And I log out
# Confirm that user can login and browse the site.
And I log in as "user1"
And I follow "Profile" in the user menu
# User can see his own agreements in the profile.
And I follow "Policies and agreements"
And "Accepted" "text" should exist in the "Digital maturity declaration" "table_row"
And "Accepted" "text" should exist in the "Cookies policy" "table_row"
And "Privacy policy" "table_row" should not exist
And "Terms of Service" "table_row" should not exist
And I log out
@@ -0,0 +1,260 @@
@tool @tool_policy
Feature: Manage policies
In order to manage policies
As a manager
I need to be able to create and edit site policies
Background:
Given the following config values are set as admin:
| sitepolicyhandler | tool_policy |
And the following "users" exist:
| username | firstname | lastname | email |
| user1 | User | One | one@example.com |
| user2 | User | Two | two@example.com |
| manager | Max | Manager | man@example.com |
And the following "role assigns" exist:
| user | role | contextlevel | reference |
| manager | manager | System | |
Scenario: Create new policy and save as draft
When I log in as "manager"
And I navigate to "Users > Privacy and policies > Manage policies" in site administration
And I follow "New policy"
And I set the following fields to these values:
| Name | Policy1 |
| Version | v1 |
| Summary | Policy summary |
| Full policy | Full text |
And the field "Type" matches value "Site policy"
And the field "User consent" matches value "All users"
And the field "status" matches value "0"
And "Draft" "field" should exist
And "Active" "field" should exist
And "Minor change" "field" should not exist
And I should not see "Minor change"
And "Save as draft" "button" should not exist
And I press "Save"
Then the following should exist in the "tool-policy-managedocs-wrapper" table:
| Name | Policy status | Version | Agreements |
| Policy1 Site policy, All users, Compulsory | Draft | v1 | N/A |
And I log out
Scenario: Create new policy and save as active
When I log in as "manager"
And I navigate to "Users > Privacy and policies > Manage policies" in site administration
And I follow "New policy"
And I set the following fields to these values:
| Name | Policy1 |
| Version | v1 |
| Summary | Policy summary |
| Full policy | Full text |
| Active | 1 |
And I press "Save"
Then the following should exist in the "tool-policy-managedocs-wrapper" table:
| Name | Policy status | Version | Agreements |
| Policy1 Site policy, All users, Compulsory | Active | v1 | 0 of 4 (0%) |
And I log out
Scenario: Edit active policy and save as minor change
Given the following policies exist:
| Name | Revision | Content | Summary | Status |
| Policy1 | v1 | full text2 | short text2 | active |
And I log in as "manager"
And I press "Next"
And I set the field "I agree to the Policy1" to "1"
And I press "Next"
And I navigate to "Users > Privacy and policies > Manage policies" in site administration
And I click on "Edit" "link" in the "Policy1" "table_row"
And "Draft" "field" should not exist
And "Active" "field" should not exist
And "Minor change" "field" should exist
And "Save as draft" "button" should exist
And I set the field "Version" to "v1 amended"
And I set the field "Minor change" to "1"
And I press "Save"
Then the following should exist in the "tool-policy-managedocs-wrapper" table:
| Name | Policy status | Version | Agreements |
| Policy1 Site policy, All users, Compulsory | Active | v1 amended | 1 of 4 (25%) |
And I log out
Scenario: Edit active policy and save as draft
Given the following policies exist:
| Name | Revision | Content | Summary | Status |
| Policy1 | v1 | full text2 | short text2 | active |
And I log in as "manager"
And I press "Next"
And I set the field "I agree to the Policy1" to "1"
And I press "Next"
And I navigate to "Users > Privacy and policies > Manage policies" in site administration
And I click on "Edit" "link" in the "Policy1" "table_row"
And I set the field "Version" to "v2"
And I press "Save as draft"
Then the following should exist in the "tool-policy-managedocs-wrapper" table:
| Name | Policy status | Version | Agreements |
| Policy1 Site policy, All users, Compulsory | Active | v1 | 1 of 4 (25%) |
| Policy1 Site policy, All users, Compulsory | Draft | v2 | N/A |
And I log out
Scenario: Edit active policy and save as new active version
Given the following policies exist:
| Name | Revision | Content | Summary | Status |
| Policy1 | v1 | full text2 | short text2 | active |
And I log in as "manager"
And I press "Next"
And I set the field "I agree to the Policy1" to "1"
And I press "Next"
And I navigate to "Users > Privacy and policies > Manage policies" in site administration
And I click on "Edit" "link" in the "Policy1" "table_row"
And I set the field "Name" to "Policy2"
And I set the field "Version" to "v2"
And I press "Save"
Then the following should exist in the "tool-policy-managedocs-wrapper" table:
| Name | Policy status | Version | Agreements |
| Policy2 Site policy, All users, Compulsory | Active | v2 | 0 of 4 (0%) |
And I should not see "Policy1"
And I should not see "v1"
And I click on "View previous versions" "link" in the "Policy2" "table_row"
And I should see "Policy2 previous versions"
And I should not see "v2"
Then the following should exist in the "tool-policy-managedocs-wrapper" table:
| Name | Policy status | Version | Agreements |
| Policy1 Site policy, All users, Compulsory | Inactive | v1 | 1 of 4 (25%) |
And I log out
Scenario: Edit draft policy and save as draft
Given the following policies exist:
| Name | Revision | Content | Summary | Status |
| Policy1 | v1 | full text2 | short text2 | draft |
And I log in as "manager"
And I navigate to "Users > Privacy and policies > Manage policies" in site administration
And I click on "Edit" "link" in the "Policy1" "table_row"
And I set the field "Version" to "v2"
And "Draft" "field" should exist
And "Active" "field" should exist
And "Minor change" "field" should not exist
And I should not see "Minor change"
And "Save as draft" "button" should not exist
And I press "Save"
Then the following should exist in the "tool-policy-managedocs-wrapper" table:
| Name | Policy status | Version | Agreements |
| Policy1 Site policy, All users, Compulsory | Draft | v2 | N/A |
And I should not see "v1"
And "View previous versions" "link" should not exist
And I log out
Scenario: Edit draft policy and save as active
Given the following policies exist:
| Name | Revision | Content | Summary | Status |
| Policy1 | v1 | full text2 | short text2 | draft |
And I log in as "manager"
And I navigate to "Users > Privacy and policies > Manage policies" in site administration
And I click on "Edit" "link" in the "Policy1" "table_row"
And I set the field "Version" to "v2"
And I set the field "Active" to "1"
And I press "Save"
Then the following should exist in the "tool-policy-managedocs-wrapper" table:
| Name | Policy status | Version | Agreements |
| Policy1 Site policy, All users, Compulsory | Active | v2 | 0 of 4 (0%) |
And I should not see "v1"
And "View previous versions" "link" should not exist
And I log out
Scenario: Activate draft policy
Given the following policies exist:
| Name | Revision | Content | Summary | Status |
| Policy1 | v1 | full text2 | short text2 | draft |
And I log in as "manager"
And I navigate to "Users > Privacy and policies > Manage policies" in site administration
And I click on "Set status to \"Active\"" "link" in the "Policy1" "table_row"
Then I should see "All users will be required to agree to this new policy version to be able to use the site."
And I press "Continue"
And the following should exist in the "tool-policy-managedocs-wrapper" table:
| Name | Policy status | Version | Agreements |
| Policy1 Site policy, All users, Compulsory | Active | v1 | 0 of 4 (0%) |
And "View previous versions" "link" should not exist
And I log out
Scenario: Edit archived policy and save as draft
Given the following policies exist:
| Name | Revision | Content | Summary | Status |
| Policy1 | v1 | full text2 | short text2 | active |
And I log in as "manager"
And I press "Next"
And I set the field "I agree to the Policy1" to "1"
And I press "Next"
And I navigate to "Users > Privacy and policies > Manage policies" in site administration
And I click on "Set status to \"Inactive\"" "link" in the "Policy1" "table_row"
Then I should see "You are about to inactivate policy"
And I press "Continue"
And the following should exist in the "tool-policy-managedocs-wrapper" table:
| Name | Policy status | Version | Agreements |
| Policy1 Site policy, All users, Compulsory | Inactive | v1 | 1 of 4 (25%) |
And I click on "Create a new draft" "link" in the "Policy1" "table_row"
And I set the field "Version" to "v2"
And I set the field "Name" to "Policy2"
And the field "status" matches value "0"
And "Draft" "field" should exist
And "Active" "field" should exist
And "Minor change" "field" should not exist
And I should not see "Minor change"
And "Save as draft" "button" should not exist
And I press "Save"
And the following should exist in the "tool-policy-managedocs-wrapper" table:
| Name | Policy status | Version | Agreements |
| Policy2 Site policy, All users, Compulsory | Draft | v2 | N/A |
And I should not see "v1"
And I should not see "Policy1"
And I click on "View previous versions" "link" in the "Policy2" "table_row"
And I should see "Policy2 previous versions"
And the following should exist in the "tool-policy-managedocs-wrapper" table:
| Name | Policy status | Version | Agreements |
| Policy1 Site policy, All users, Compulsory | Inactive | v1 | 1 of 4 (25%) |
And I should not see "v2"
And I log out
Scenario: Edit archived policy and save as active
Given the following policies exist:
| Name | Revision | Content | Summary | Status |
| Policy1 | v1 | full text2 | short text2 | active |
And I log in as "manager"
And I press "Next"
And I set the field "I agree to the Policy1" to "1"
And I press "Next"
And I navigate to "Users > Privacy and policies > Manage policies" in site administration
And I click on "Set status to \"Inactive\"" "link" in the "Policy1" "table_row"
And I press "Continue"
And I click on "Create a new draft" "link" in the "Policy1" "table_row"
And I set the field "Version" to "v2"
And I set the field "Name" to "Policy2"
And I set the field "Active" to "1"
And I press "Save"
And the following should exist in the "tool-policy-managedocs-wrapper" table:
| Name | Policy status | Version | Agreements |
| Policy2 Site policy, All users, Compulsory | Active | v2 | 0 of 4 (0%) |
And I should not see "v1"
And I should not see "Policy1"
And I click on "View previous versions" "link" in the "Policy2" "table_row"
And I should see "Policy2 previous versions"
And the following should exist in the "tool-policy-managedocs-wrapper" table:
| Name | Policy status | Version | Agreements |
| Policy1 Site policy, All users, Compulsory | Inactive | v1 | 1 of 4 (25%) |
And I should not see "v2"
And I log out
Scenario: Current user can go back to previous page in List of active policies page
Given the following policies exist:
| Name | Revision | Content | Summary | Status |
| Policy1 | v1 | full text2 | short text2 | active |
And I log in as "user1"
And I press "Next"
And I set the field "I agree to the Policy1" to "1"
And I press "Next"
And I follow "Preferences" in the user menu
And I should see "Preferences"
And I should see "Policies"
# User should see a redirect back to previous page link.
And I click on "Policies" "link"
And I should see "List of active policies"
And I should see "Go back to previous page"
When I click on "Go back to previous page" "link"
Then I should see "Preferences"
@@ -0,0 +1,264 @@
@tool @tool_policy
Feature: Optional policies
In order to exercise my privacy rights
As a user
I should be able to decline policy statements and withdraw my previously given consent to them
Background:
Given the following config values are set as admin:
| sitepolicyhandler | tool_policy |
And the following "users" exist:
| username | firstname | lastname | email |
| user1 | User | One | one@example.com |
| user2 | User | Two | two@example.com |
| manager | Max | Manager | man@example.com |
And the following "role assigns" exist:
| user | role | contextlevel | reference |
| manager | manager | System | |
And the following "courses" exist:
| fullname | shortname |
| Course1 | C1 |
And the following "course enrolments" exist:
| user | course | role |
| user1 | C1 | student |
| user2 | C1 | student |
Scenario: Configuring a policy as optional
Given I log in as "manager"
And I navigate to "Users > Privacy and policies > Manage policies" in site administration
And I follow "New policy"
# Policies are compulsory by default.
And the field "Agreement optional" matches value "No"
# Optional status can be set when creating a new policy.
And I set the following fields to these values:
| Name | ConsentPageOptional1 |
| Version | v1 |
| Summary | Policy summary |
| Full policy | Full text |
| Active | 1 |
| Show policy before showing other policies | No |
| Agreement optional | Yes |
When I press "Save"
Then the following should exist in the "tool-policy-managedocs-wrapper" table:
| Name | Policy status | Version |
| ConsentPageOptional1 Site policy, All users, Optional | Active | v1 |
# Optional status can be edited.
And I open the action menu in "ConsentPageOptional1" "table_row"
And I click on "Edit" "link" in the "ConsentPageOptional1" "table_row"
And I set the field "Agreement optional" to "No"
And I set the field "Minor change" to "1"
And I press "Save"
And the following should exist in the "tool-policy-managedocs-wrapper" table:
| Name | Policy status | Version |
| ConsentPageOptional1 Site policy, All users, Compulsory | Active | v1 |
Scenario: Compulsory policies must be accepted prior signup, optional policies just after it
Given the following config values are set as admin:
| registerauth | email |
| passwordpolicy | 0 |
And the following policies exist:
| Name | Content | Summary | Agreementstyle | Optional |
| ConsentPageOptional1 | full text1 | short text1 | 0 | 1 |
| ConsentPageOptional2 | full text2 | short text2 | 0 | 1 |
| ConsentPageCompulsory1 | full text3 | short text3 | 0 | 0 |
| OwnPageCompulsory1 | full text4 | short text4 | 1 | 0 |
| OwnPageOptional1 | full text5 | short text5 | 1 | 1 |
And I am on site homepage
And I follow "Log in"
And I click on "Create new account" "link"
# Compulsory policies displayed on own page are shown first and must be agreed.
And I should see "OwnPageCompulsory1" in the "region-main" "region"
And I should see "short text4" in the "region-main" "region"
And I should see "full text4" in the "region-main" "region"
And I press "I agree to the OwnPageCompulsory1"
# Compulsory policies displayed on the consent page are shown next and must be agreed.
And I should see "ConsentPageCompulsory1"
And I should see "short text3" in the "region-main" "region"
And I should see "full text3" in the "region-main" "region"
And I press "Next"
And I should see "Please agree to the following policies"
And I set the field "I agree to the ConsentPageCompulsory1" to "1"
And I press "Next"
# The signup form can be submitted and a new account created.
And I set the following fields to these values:
| Username | user3 |
| Password | user3 |
| Email address | user3@address.invalid |
| Email (again) | user3@address.invalid |
| First name | User3 |
| Last name | L3 |
And I press "Create my new account"
And I should see "Confirm your account"
And I should see "An email should have been sent to your address at user3@address.invalid"
And I confirm email for "user3"
And I should see "Thanks, User3 L3"
And I should see "Your registration has been confirmed"
When I press "Continue"
# After confirming the new account, the user is logged in and asked to accept or decline the optional policies.
# First come policies displayed on their own page.
Then I should see "OwnPageOptional1"
And I should see "short text5" in the "region-main" "region"
And I should see "full text5" in the "region-main" "region"
And I press "No thanks, I decline OwnPageOptional1"
# Then come policies displayed on the consent page.
And I should see "ConsentPageOptional1" in the "region-main" "region"
And I should see "short text1" in the "region-main" "region"
And I should see "full text1" in the "region-main" "region"
And I press "Next"
And I should see "ConsentPageOptional2" in the "region-main" "region"
And I should see "short text2" in the "region-main" "region"
And I should see "full text2" in the "region-main" "region"
And I press "Next"
And I should see "Please agree to the following policies"
And I set the field "I agree to the ConsentPageOptional1" to "1"
And I set the field "No thanks, I decline ConsentPageOptional2" to "0"
And I press "Next"
# Accepted and declined policies are shown in the profile.
And I follow "Profile" in the user menu
And I follow "Policies and agreements"
And "Accepted" "text" should exist in the "ConsentPageCompulsory1" "table_row"
And "Accepted" "text" should exist in the "ConsentPageOptional1" "table_row"
And "Accepted" "text" should exist in the "OwnPageCompulsory1" "table_row"
And "Declined" "text" should exist in the "OwnPageOptional1" "table_row"
And "Declined" "text" should exist in the "ConsentPageOptional2" "table_row"
Scenario: When a new optional policy is added, users are asked to accept/decline it on their next login
Given the following policies exist:
| Name | Content | Summary | Agreementstyle | Optional |
| ConsentPageOptional1 | full text1 | short text1 | 0 | 1 |
| OwnPageOptional1 | full text5 | short text5 | 1 | 1 |
When I log in as "user1"
# First come policies displayed on their own page.
Then I should see "OwnPageOptional1"
And I should see "short text5" in the "region-main" "region"
And I should see "full text5" in the "region-main" "region"
And I press "I agree to the OwnPageOptional1"
# Then come policies displayed on the consent page.
And I should see "ConsentPageOptional1" in the "region-main" "region"
And I should see "short text1" in the "region-main" "region"
And I should see "full text1" in the "region-main" "region"
And I press "Next"
And I should see "Please agree to the following policies"
And I set the field "No thanks, I decline ConsentPageOptional1" to "0"
And I press "Next"
# Accepted and declined policies are shown in the profile.
And I follow "Profile" in the user menu
And I follow "Policies and agreements"
And "Accepted" "text" should exist in the "OwnPageOptional1" "table_row"
And "Declined" "text" should exist in the "ConsentPageOptional1" "table_row"
Scenario: Users can withdraw an accepted optional policy and re-accept it again (js off)
Given the following policies exist:
| Name | Content | Summary | Agreementstyle | Optional |
| OwnPageOptional1 | full text1 | short text1 | 1 | 1 |
And I log in as "user1"
And I press "I agree to the OwnPageOptional1"
And I follow "Profile" in the user menu
And I follow "Policies and agreements"
And "Accepted" "text" should exist in the "OwnPageOptional1" "table_row"
And "Withdraw" "link" should exist in the "OwnPageOptional1" "table_row"
When I click on "Withdraw acceptance of OwnPageOptional1" "link" in the "OwnPageOptional1" "table_row"
Then I should see "Withdrawing policy"
And I should see "User One"
And I should see "OwnPageOptional1"
And I press "Withdraw user consent"
And "Declined" "text" should exist in the "OwnPageOptional1" "table_row"
And "Accept" "link" should exist in the "OwnPageOptional1" "table_row"
And I click on "Accept OwnPageOptional1" "link" in the "OwnPageOptional1" "table_row"
And I should see "Accepting policy"
And I should see "User One"
And I should see "OwnPageOptional1"
And I press "Give consent"
And "Accepted" "text" should exist in the "OwnPageOptional1" "table_row"
@javascript
Scenario: Users can withdraw an accepted optional policy and re-accept it again (js on)
Given the following policies exist:
| Name | Content | Summary | Agreementstyle | Optional |
| OwnPageOptional1 | full text1 | short text1 | 1 | 1 |
And I log in as "user1"
And I press "I agree to the OwnPageOptional1"
And I follow "Profile" in the user menu
And I follow "Policies and agreements"
And "Accepted" "text" should exist in the "OwnPageOptional1" "table_row"
And "Withdraw" "link" should exist in the "OwnPageOptional1" "table_row"
When I click on "Withdraw acceptance of OwnPageOptional1" "link" in the "OwnPageOptional1" "table_row"
Then I should see "Withdrawing policy"
And I should see "User One"
And I should see "OwnPageOptional1"
And I press "Withdraw user consent"
And "Declined" "text" should exist in the "OwnPageOptional1" "table_row"
And "Accept" "link" should exist in the "OwnPageOptional1" "table_row"
And I click on "Accept OwnPageOptional1" "link" in the "OwnPageOptional1" "table_row"
And I should see "Accepting policy"
And I should see "User One"
And I should see "OwnPageOptional1"
And I press "Give consent"
And "Accepted" "text" should exist in the "OwnPageOptional1" "table_row"
Scenario: Managers can see accepted, declined and pending acceptances of optional policies
Given the following policies exist:
| Name | Content | Summary | Agreementstyle | Optional |
| OwnPageOptional1 | full text1 | short text1 | 1 | 1 |
| OwnPageOptional2 | full text2 | short text2 | 1 | 1 |
And I log in as "user1"
And I press "I agree to the OwnPageOptional1"
And I press "No thanks, I decline OwnPageOptional2"
And I log out
And I log in as "manager"
And I press "I agree to the OwnPageOptional1"
And I press "I agree to the OwnPageOptional2"
When I navigate to "Users > Privacy and policies > User agreements" in site administration
# User One has accepted just some policies.
Then "Partially accepted" "text" should exist in the "User One" "table_row"
And "Details" "link" should exist in the "User One" "table_row"
# User Two did not have a chance to respond to the new policies yet.
And "Pending" "text" should exist in the "User Two" "table_row"
And "Details" "link" should exist in the "User Two" "table_row"
# Max Manager accepted all and can also change status of own acceptances.
And "Accepted" "text" should exist in the "Max Manager" "table_row"
And "Details" "link" should exist in the "Max Manager" "table_row"
And "Withdraw accepted policies" "link" should exist in the "Max Manager" "table_row"
And "Withdraw acceptance of OwnPageOptional1" "link" should exist in the "Max Manager" "table_row"
And "Withdraw acceptance of OwnPageOptional2" "link" should exist in the "Max Manager" "table_row"
Scenario: Administrators can see accepted, declined and pending acceptances of optional policies and also change them on behalf of other users
Given the following policies exist:
| Name | Content | Summary | Agreementstyle | Optional |
| OwnPageOptional1 | full text1 | short text1 | 1 | 1 |
| OwnPageOptional2 | full text2 | short text2 | 1 | 1 |
And I log in as "user1"
And I press "I agree to the OwnPageOptional1"
And I press "No thanks, I decline OwnPageOptional2"
And I log out
And I log in as "admin"
When I navigate to "Users > Privacy and policies > User agreements" in site administration
# User One has accepted just some policies.
Then "Partially accepted" "text" should exist in the "User One" "table_row"
And "Details" "link" should exist in the "User One" "table_row"
And "Withdraw acceptance of OwnPageOptional1" "link" should exist in the "User One" "table_row"
And "Accept OwnPageOptional2" "link" should exist in the "User One" "table_row"
# User Two did not have a chance to respond to the new policies yet.
And "Pending" "text" should exist in the "User Two" "table_row"
And "Accept pending policies" "link" should exist in the "User Two" "table_row"
And "Decline pending policies" "link" should exist in the "User Two" "table_row"
And "Accept OwnPageOptional1" "link" should exist in the "User Two" "table_row"
And "Decline OwnPageOptional1" "link" should exist in the "User Two" "table_row"
And "Accept OwnPageOptional2" "link" should exist in the "User Two" "table_row"
And "Decline OwnPageOptional2" "link" should exist in the "User Two" "table_row"
# Accept all policies on Max Manager's behalf.
And I click on "Accept pending policies" "link" in the "Max Manager" "table_row"
And I press "Give consent"
And "Accepted" "text" should exist in the "Max Manager" "table_row"
# Decline all policies on User Two's behalf.
And I click on "Decline pending policies" "link" in the "User Two" "table_row"
And I press "Decline user consent"
And "Declined on user's behalf" "text" should exist in the "User Two" "table_row"
And "Accepted" "text" should not exist in the "User Two" "table_row"
And "Pending" "text" should not exist in the "User Two" "table_row"
# Accept policy on User One's behalf.
And I click on "Accept OwnPageOptional2" "link" in the "User One" "table_row"
And I press "Give consent"
And "Accepted on user's behalf" "text" should exist in the "User One" "table_row"
And "Declined" "text" should not exist in the "User One" "table_row"
And "Pending" "text" should not exist in the "User One" "table_row"