1 |
efrain |
1 |
@mod @mod_customcert
|
|
|
2 |
Feature: Being able to verify that a certificate is valid or not
|
|
|
3 |
In order to ensure that a user can verify a certificate is valid
|
|
|
4 |
As a teacher and non-user
|
|
|
5 |
I need to be able to verify a certificate
|
|
|
6 |
|
|
|
7 |
Background:
|
|
|
8 |
Given the following "courses" exist:
|
|
|
9 |
| fullname | shortname | category |
|
|
|
10 |
| Course 1 | C1 | 0 |
|
|
|
11 |
And the following "users" exist:
|
|
|
12 |
| username | firstname | lastname | email |
|
|
|
13 |
| teacher1 | Teacher | 1 | teacher1@example.com |
|
|
|
14 |
| student1 | Student | 1 | student1@example.com |
|
|
|
15 |
And the following "course enrolments" exist:
|
|
|
16 |
| user | course | role |
|
|
|
17 |
| teacher1 | C1 | editingteacher |
|
|
|
18 |
| student1 | C1 | student |
|
|
|
19 |
And the following "activities" exist:
|
|
|
20 |
| activity | name | intro | course | idnumber | verifyany |
|
|
|
21 |
| customcert | Custom certificate 1 | Custom certificate 1 intro | C1 | customcert1 | 0 |
|
|
|
22 |
| customcert | Custom certificate 2 | Custom certificate 2 intro | C1 | customcert2 | 1 |
|
|
|
23 |
|
|
|
24 |
Scenario: Verify a certificate as a teacher
|
|
|
25 |
And I log in as "student1"
|
|
|
26 |
And I am on "Course 1" course homepage
|
|
|
27 |
And I follow "Custom certificate 1"
|
|
|
28 |
And I press "View certificate"
|
|
|
29 |
And I log out
|
|
|
30 |
And I log in as "teacher1"
|
|
|
31 |
And I am on "Course 1" course homepage
|
|
|
32 |
And I follow "Custom certificate 1"
|
|
|
33 |
And I navigate to "Verify certificate" in current page administration
|
|
|
34 |
And I set the field "Code" to "NOTAVALIDCODE"
|
|
|
35 |
And I press "Verify"
|
|
|
36 |
And I should see "Not verified"
|
|
|
37 |
And I verify the "Custom certificate 1" certificate for the user "student1"
|
|
|
38 |
|
|
|
39 |
Scenario: Attempt to verify a certificate as a non-user
|
|
|
40 |
And I visit the verification url for the "Custom certificate 1" certificate
|
|
|
41 |
# User should get redirected to log in as we do not allow non-users to verify.
|
|
|
42 |
And I should see "Lost password?"
|
|
|
43 |
|
|
|
44 |
Scenario: Verify a certificate as a non-user
|
|
|
45 |
And I log in as "student1"
|
|
|
46 |
And I am on "Course 1" course homepage
|
|
|
47 |
And I follow "Custom certificate 2"
|
|
|
48 |
And I press "View certificate"
|
|
|
49 |
And I log out
|
|
|
50 |
And I visit the verification url for the "Custom certificate 2" certificate
|
|
|
51 |
And I set the field "Code" to "NOTAVALIDCODE"
|
|
|
52 |
And I press "Verify"
|
|
|
53 |
And I should see "Not verified"
|
|
|
54 |
And I verify the "Custom certificate 2" certificate for the user "student1"
|
|
|
55 |
|
|
|
56 |
Scenario: Attempt to verify a certificate as a non-user using the site-wide URL
|
|
|
57 |
And the following config values are set as admin:
|
|
|
58 |
| verifyallcertificates | 0 | customcert |
|
|
|
59 |
And I visit the verification url for the site
|
|
|
60 |
# User should see an error message as we do not allow non-users to verify all certificates on the site.
|
|
|
61 |
And I should see "You do not have the permission to verify all certificates on the site"
|
|
|
62 |
|
|
|
63 |
Scenario: Attempt to verify a certificate as a teacher using the site-wide URL
|
|
|
64 |
And the following config values are set as admin:
|
|
|
65 |
| verifyallcertificates | 0 | customcert |
|
|
|
66 |
And I log in as "teacher1"
|
|
|
67 |
And I visit the verification url for the site
|
|
|
68 |
# User should see an error message as we do not allow teachers to verify all certificates on the site.
|
|
|
69 |
And I should see "You do not have the permission to verify all certificates on the site"
|
|
|
70 |
|
|
|
71 |
Scenario: Verify a certificate as an admin using the site-wide URL
|
|
|
72 |
And the following config values are set as admin:
|
|
|
73 |
| verifyallcertificates | 0 | customcert |
|
|
|
74 |
And I log in as "student1"
|
|
|
75 |
And I am on "Course 1" course homepage
|
|
|
76 |
And I follow "Custom certificate 1"
|
|
|
77 |
And I press "View certificate"
|
|
|
78 |
And I am on "Course 1" course homepage
|
|
|
79 |
And I follow "Custom certificate 2"
|
|
|
80 |
And I press "View certificate"
|
|
|
81 |
And I log out
|
|
|
82 |
And I log in as "admin"
|
|
|
83 |
# The admin (or anyone with the capability 'mod/customcert:verifyallcertificates') can visit the URL regardless of the setting.
|
|
|
84 |
And I visit the verification url for the site
|
|
|
85 |
And I set the field "Code" to "NOTAVALIDCODE"
|
|
|
86 |
And I press "Verify"
|
|
|
87 |
And I should see "Not verified"
|
|
|
88 |
# The admin (or anyone with the capability 'mod/customcert:verifyallcertificates') can verify any certificate regardless of the 'verifyany' setting.
|
|
|
89 |
And I verify the "Custom certificate 1" certificate for the user "student1"
|
|
|
90 |
And I verify the "Custom certificate 2" certificate for the user "student1"
|
|
|
91 |
|
|
|
92 |
Scenario: Verify a certificate as a non-user using the site-wide URL
|
|
|
93 |
And the following config values are set as admin:
|
|
|
94 |
| verifyallcertificates | 1 | customcert |
|
|
|
95 |
And I log in as "student1"
|
|
|
96 |
And I am on "Course 1" course homepage
|
|
|
97 |
And I follow "Custom certificate 1"
|
|
|
98 |
And I press "View certificate"
|
|
|
99 |
And I am on "Course 1" course homepage
|
|
|
100 |
And I follow "Custom certificate 2"
|
|
|
101 |
And I press "View certificate"
|
|
|
102 |
And I log out
|
|
|
103 |
And I visit the verification url for the site
|
|
|
104 |
And I set the field "Code" to "NOTAVALIDCODE"
|
|
|
105 |
And I press "Verify"
|
|
|
106 |
And I should see "Not verified"
|
|
|
107 |
And I can not verify the "Custom certificate 1" certificate for the user "student1"
|
|
|
108 |
And I verify the "Custom certificate 2" certificate for the user "student1"
|