Security update for permissions_by_term
[yaffs-website] / web / modules / contrib / permissions_by_term / tests / src / Behat / Features / access.feature
1 @api @drupal
2 Feature: Access
3   Several automated tests for the Permissions by Term Drupal 8 module.
4
5   Background:
6     Given restricted "tags" terms:
7       | name          | access_user   | access_role                             |
8       | Tag one       |               | administrator                           |
9       | Tag two       |               | authenticated                           |
10       | Tag three     |               |                                         |
11       | Tag admin     | admin         |                                         |
12       | Tag anonymous |               | anonymous, administrator, authenticated |
13     Given article content:
14       | title                          | author     | status | created           | field_tags    | alias                 |
15       | Only admin can access          | Admin      | 1      | 2014-10-17 8:00am | Tag one       | only-admin-can-access |
16       | Everybody can access           | Admin      | 1      | 2014-10-17 8:00am |               | no-term               |
17       | Term accessible                | Admin      | 1      | 2014-10-17 8:00am | Tag three     | term-no-restriction   |
18       | Unpublished node               | Admin      | 0      | 2014-10-17 8:00am |               | unpublished           |
19       | Only admin user can edit       | Admin      | 0      | 2014-10-17 8:00am | Tag admin     | unpublished           |
20       | Authenticated user can access  | Admin      | 0      | 2014-10-17 8:00am | Tag two       | unpublished           |
21       | Anonymous user can access      | Admin      | 1      | 2014-10-17 8:00am | Tag anonymous | anonymous             |
22     Given users:
23       | name          | mail            | pass     |
24       | Joe           | joe@example.com | password |
25     Given Node access records are rebuild.
26
27   Scenario: Anonymous users cannot see restricted node
28     Given I open node view by node title "Authenticated user can access"
29     Then I should see text matching "Access denied"
30
31   Scenario: Anonymous users can see allowed node with term with multiple user role relation in view
32     Given I am on "/"
33     And the cache has been cleared
34     Then I should see text matching "Anonymous user can access"
35
36 #@TODO: Test needs to be fixed. Implement a method, which waits for HTML tags.
37 #  Scenario: Anonymous users can see node, which is not connected to any permission.
38 #    Given I am logged in as a user with the "administrator" role
39 #    Then I am on "/admin/config/search/pages"
40 #    And I press "edit-wipe"
41 #    And I run cron
42 #    And I am on "/user/logout"
43 #    Then I am on "node/search"
44 #    And I fill in "edit-keys" with "Everybody can"
45 #    And I press "edit-submit--2"
46 #    Then I should not see text matching "Your search yielded no results."
47
48   Scenario: Anonymous users do not see unpublished nodes.
49     Given I am on "node/search"
50     And I fill in "edit-keys" with "Unpublished node"
51     And I press "edit-submit--2"
52     Then I should see text matching "Your search yielded no results."
53
54 #  Scenario: Anonymous users see nodes with term and no restriction
55 #    Given I run cron
56 #    Given I am on "/"
57 #    Given I am on "node/search"
58 #    And I fill in "edit-keys" with "Term accessible"
59 #    And I press "edit-submit--2"
60 #    Then I should not see text matching "Your search yielded no results."
61
62 #@TODO: Test needs to be fixed. Implement a method, which waits for HTML tags.
63 #  Scenario: Users cannot access restricted terms in taxonomy term field widgets.
64 #    Given I am on "/"
65 #    Then I am logged in as a user with the "administrator" role
66 #    And I am on "/admin/structure/types/manage/article/form-display"
67 #    And I select index 3 in dropdown named "fields[field_tags][type]"
68 #    And I scroll to element with id "edit-submit"
69 #    And I press "edit-submit"
70 #    Then I am on "/node/add/article"
71 #    Then I should not see "Tag admin" in the "#edit-field-tags" element
72 #    Then I should see "Tag three" in the "#edit-field-tags" element
73
74   Scenario: Users cannot access node edit forms without having access to related terms.
75     Given I am on "/"
76     Then I am logged in as a user with the "administrator" role
77     And I am on "/admin/people/roles/add"
78     And I fill in "edit-label" with "Editor"
79     And I fill in "edit-id" with "editor"
80     Then I press "edit-submit"
81     Then I am on "/admin/people/permissions"
82     And I check checkbox with id "edit-editor-access-content-overview" by JavaScript
83     And I check checkbox with id "edit-editor-administer-nodes" by JavaScript
84     And I check checkbox with id "edit-editor-administer-content-types" by JavaScript
85     And I check checkbox with id "edit-editor-create-article-content" by JavaScript
86     And I check checkbox with id "edit-editor-delete-any-article-content" by JavaScript
87     And I check checkbox with id "edit-editor-delete-own-article-content" by JavaScript
88     And I check checkbox with id "edit-editor-edit-any-article-content" by JavaScript
89     And I check checkbox with id "edit-editor-edit-own-article-content" by JavaScript
90     And I scroll to element with id "edit-submit"
91     And I press "edit-submit"
92     Then I am on "/admin/people/create"
93     And I fill in "edit-name" with "editor"
94     And I fill in "edit-pass-pass1" with "password"
95     And I fill in "edit-pass-pass2" with "password"
96     And I check checkbox with id "edit-roles-editor" by JavaScript
97     And I scroll to element with id "edit-submit"
98     And I press "edit-submit"
99     Then I am on "/user/logout"
100     Then I am on "/user/login"
101     And I fill in "edit-name" with "editor"
102     And I fill in "edit-pass" with "password"
103     And I scroll to element with id "edit-submit"
104     And I press "edit-submit"
105     Then I am on "/admin/content"
106     And I should not see text matching "Only admin user can edit"
107     And I should see text matching "Term accessible"
108     And I should see text matching "Everybody can access"
109     Then I open node edit form by node title "Only admin user can edit"
110     And I should see text matching "Access denied"
111
112 #@TODO: Test needs to be fixed. Implement a method, which waits for HTML tags.
113 #  Scenario: Users are accessing an node directly
114 #    Given I am logged in as a user with the "administrator" role
115 #    Then I am on "only-admin-can-access"
116 #    Then I should see text matching "Only admin can access"
117 #    Given I am logged in as "Joe"
118 #    Then I am on "only-admin-can-access"
119 #    Then I should see text matching "Access denied"
120
121 #@TODO: Test needs to be fixed. Implement a method, which waits for HTML tags.
122 #  Scenario: Users search for an node
123 #    Given I create 1000 nodes of type "article"
124 #    Given I am logged in as a user with the "administrator" role
125 #    And I am on "admin/config/system/cron"
126 #    And I press "edit-run"
127 #    Then I am on "node/search"
128 #    And I fill in "edit-keys" with "Only admin can access"
129 #    And I press "edit-submit"
130 #    Then I should see text matching "Only admin can access"
131 #    Given I am logged in as "Joe"
132 #    Then I am on "node/search"
133 #    And I fill in "edit-keys" with "Only admin can access"
134 #    And I press "edit-submit"
135 #    Then I should see text matching "Your search yielded no results."
136
137   Scenario: Users access an node by menu
138     Given I am logged in as a user with the "administrator" role
139     And I am on "admin/structure/menu/manage/main"
140     And I click "Add link"
141     And I fill in "edit-title-0-value" with "Only admin can access"
142     And I fill in "edit-link-0-uri" with "Only admin can access (1)"
143     And I press "edit-submit"
144     Then I click "Home"
145     Then I should see "Only admin can access" in the ".region-primary-menu" element
146     Given I am logged in as "Joe"
147     Then I should not see "Only admin can access" in the ".region-primary-menu" element
148
149   Scenario: Users access an nodes by view
150     Given I am logged in as a user with the "administrator" role
151     Then I am on "/"
152     And I should see text matching "Only admin can access"
153     Given I am logged in as "Joe"
154     Then I am on "/"
155     And I should not see text matching "Only admin can access"