1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
|
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This Source Code Form is "Incompatible With Secondary Licenses", as
# defined by the Mozilla Public License, v. 2.0.
use 5.14.0;
use strict;
use warnings;
use FindBin qw($RealBin);
use lib "$RealBin/../lib", "$RealBin/../../local/lib/perl5";
use Test::More "no_plan";
use QA::Util;
my ($sel, $config) = get_selenium();
log_in($sel, $config, 'admin');
set_parameters($sel, { "Administrative Policies" => {"allowuserdeletion-on" => undef} });
# First delete test users, if not deleted correctly during a previous run.
cleanup_users($sel);
# The Master group inherits privs of the Slave group.
go_to_admin($sel);
$sel->click_ok("link=Groups");
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is("Edit Groups");
$sel->click_ok("link=Master");
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is("Change Group: Master");
my $group_url = $sel->get_location();
$group_url =~ /group=(\d+)$/;
my $master_gid = $1;
go_to_admin($sel);
$sel->click_ok("link=Groups");
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is("Edit Groups");
$sel->click_ok("link=Add Group");
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is("Add group");
$sel->type_ok("name", "Slave");
$sel->type_ok("desc", "Members of the Master group are also members of this group");
$sel->uncheck_ok("isactive");
ok(!$sel->is_checked("insertnew"), "Group not added to products by default");
$sel->click_ok("create");
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is("New Group Created");
my $slave_gid = $sel->get_value("group_id");
$sel->add_selection_ok("members_add", "label=Master");
$sel->click_ok('//input[@value="Update Group"]');
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is("Change Group: Slave");
# Create users.
go_to_admin($sel);
$sel->click_ok("link=Users");
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is('Search users');
$sel->click_ok('link=add a new user');
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is('Add user');
$sel->type_ok('email', 'master@selenium.bugzilla.org');
$sel->type_ok('name', 'master-user');
$sel->type_ok('password', 'selenium', 'Enter password');
$sel->type_ok('disabledtext', 'Not for common usage');
$sel->click_ok('add');
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is('Edit user master-user (master@selenium.bugzilla.org)');
$sel->check_ok("//input[\@name='group_$master_gid']");
$sel->click_ok('update');
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is('User master@selenium.bugzilla.org updated');
$sel->is_text_present_ok('The account has been added to the Master group');
$sel->click_ok("link=add a new user");
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is('Add user');
$sel->type_ok('email', 'slave@selenium.bugzilla.org');
$sel->type_ok('name', 'slave-user');
$sel->type_ok('password', 'selenium', 'Enter password');
$sel->type_ok('disabledtext', 'Not for common usage');
$sel->click_ok('add');
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is('Edit user slave-user (slave@selenium.bugzilla.org)');
$sel->check_ok("//input[\@name='group_$slave_gid']");
$sel->click_ok('update');
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is('User slave@selenium.bugzilla.org updated');
$sel->is_text_present_ok('The account has been added to the Slave group');
$sel->click_ok("link=add a new user");
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is('Add user');
$sel->type_ok('email', 'reg@selenium.bugzilla.org');
$sel->type_ok('name', 'reg-user');
$sel->type_ok('password', 'selenium', 'Enter password');
$sel->type_ok('disabledtext', 'Not for common usage');
$sel->click_ok('add');
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is('Edit user reg-user (reg@selenium.bugzilla.org)');
# Disabled accounts are not listed by default.
$sel->click_ok('link=find other users');
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is('Search users');
$sel->select_ok('is_enabled', 'label=Enabled');
$sel->click_ok('search');
$sel->wait_for_page_to_load_ok(WAIT_TIME);
ok(!$sel->is_text_present('master@selenium.bugzilla.org'), 'Inactive user account master-user not listed by default');
ok(!$sel->is_text_present('slave@selenium.bugzilla.org'), 'Inactive user account slave-user not listed by default');
ok(!$sel->is_text_present('reg@selenium.bugzilla.org'), 'Inactive user account reg-user not displayed by default');
# Now make sure group inheritance works correctly.
$sel->click_ok('link=find other users');
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is('Search users');
$sel->check_ok('grouprestrict');
$sel->select_ok('groupid', 'label=Master');
$sel->select_ok('matchtype', 'value=substr');
$sel->select_ok('is_enabled', 'label=All');
$sel->click_ok('search');
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->is_text_present_ok('master@selenium.bugzilla.org', 'master-user in Master group');
ok(!$sel->is_text_present('slave@selenium.bugzilla.org'), 'slave-user not in Master group');
ok(!$sel->is_text_present('reg@selenium.bugzilla.org'), 'reg-user not in Master group');
$sel->click_ok('link=find other users');
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is('Search users');
$sel->check_ok('grouprestrict');
$sel->select_ok('groupid', 'label=Slave');
$sel->select_ok('matchtype', 'value=substr');
$sel->select_ok('is_enabled', 'label=All');
$sel->click_ok('search');
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->is_text_present_ok('master@selenium.bugzilla.org', 'master-user in Slave group');
$sel->is_text_present_ok('slave@selenium.bugzilla.org', 'slave-user in Slave group');
ok(!$sel->is_text_present('reg@selenium.bugzilla.org'), 'reg-user not in Slave group');
# Add a regular expression to the Slave group.
go_to_admin($sel);
$sel->click_ok("link=Groups");
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is("Edit Groups");
$sel->click_ok('link=Slave');
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is('Change Group: Slave');
$sel->type_ok('regexp', '^reg\@.*$');
$sel->click_ok('//input[@value="Update Group"]');
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is("Change Group: Slave");
# Test group inheritance again.
go_to_admin($sel);
$sel->click_ok("link=Users");
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is('Search users');
$sel->check_ok('grouprestrict');
$sel->select_ok('groupid', 'label=Master');
$sel->select_ok('matchtype', 'value=substr');
$sel->select_ok('is_enabled', 'label=All');
$sel->click_ok('search');
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->is_text_present_ok('master@selenium.bugzilla.org', 'master-user in Master group');
ok(!$sel->is_text_present('slave@selenium.bugzilla.org'), 'slave-user not in Master group');
ok(!$sel->is_text_present('reg@selenium.bugzilla.org'), 'reg-user not in Master group');
$sel->click_ok('link=find other users');
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is('Search users');
$sel->check_ok('grouprestrict');
$sel->select_ok('groupid', 'label=Slave');
$sel->select_ok('matchtype', 'value=substr');
$sel->select_ok('is_enabled', 'label=All');
$sel->click_ok('search');
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->is_text_present_ok('master@selenium.bugzilla.org', 'master-user in Slave group');
$sel->is_text_present_ok('slave@selenium.bugzilla.org', 'slave-user in Slave group');
$sel->is_text_present_ok('reg@selenium.bugzilla.org', 'reg-user in Slave group');
# Remove created users and groups.
cleanup_users($sel);
cleanup_groups($sel, $slave_gid);
logout($sel);
sub cleanup_users {
my $sel = shift;
go_to_admin($sel);
$sel->click_ok("link=Users");
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is("Search users");
$sel->type_ok('matchstr', '(master|slave|reg)@selenium.bugzilla.org');
$sel->select_ok('matchtype', 'value=regexp');
$sel->select_ok('is_enabled', 'label=All');
$sel->click_ok("search");
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is("Select user");
foreach my $user ('master', 'slave', 'reg') {
my $login = $user . '@selenium.bugzilla.org';
next unless $sel->is_text_present($login);
$sel->click_ok("link=$login");
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is("Edit user ${user}-user ($login)");
$sel->click_ok("delete");
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is("Confirm deletion of user $login");
ok(!$sel->is_text_present('You cannot delete this user account'), 'The user can be safely deleted');
$sel->click_ok("delete");
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is("User $login deleted");
$sel->click_ok('link=show the user list again');
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is('Select user');
}
}
sub cleanup_groups {
my ($sel, $slave_gid) = @_;
go_to_admin($sel);
$sel->click_ok("link=Groups");
$sel->wait_for_page_to_load(WAIT_TIME);
$sel->title_is("Edit Groups");
$sel->click_ok("//a[\@href='editgroups.cgi?action=del&group=$slave_gid']");
$sel->wait_for_page_to_load(WAIT_TIME);
$sel->title_is("Delete group 'Slave'");
$sel->is_text_present_ok("Do you really want to delete this group?");
ok(!$sel->is_element_present("removeusers"), 'No direct members in this group');
$sel->click_ok("delete");
$sel->wait_for_page_to_load(WAIT_TIME);
$sel->title_is("Group Deleted");
$sel->is_text_present_ok("The group Slave has been deleted.");
}
|