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
|
# 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 strict;
use warnings;
use lib qw(lib);
use Test::More "no_plan";
use QA::Util;
my ($sel, $config) = get_selenium();
# Turn on the makeproductgroups parameter. Create a new product and check that
# it has automatically a group created for it with the same name.
log_in($sel, $config, 'admin');
set_parameters($sel, { "Group Security" => {"makeproductgroups-on" => undef} });
add_product($sel);
$sel->type_ok("product", "ready_to_die");
$sel->type_ok("description", "will die");
$sel->select_ok("default_op_sys_id", "Unspecified");
$sel->select_ok("default_platform_id", "Unspecified");
$sel->click_ok('//input[@value="Add"]');
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is("Product Created");
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=ready_to_die");
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is("Change Group: ready_to_die");
my $group_url = $sel->get_location();
$group_url =~ /group=(\d+)/;
my $group1_id = $1;
$sel->value_is("desc", "Access to bugs in the ready_to_die product");
my @groups = $sel->get_select_options("members_remove");
ok((grep { $_ eq 'admin' } @groups), "'admin' inherits group membership");
@groups = $sel->get_select_options("bless_from_remove");
ok((grep { $_ eq 'admin' } @groups), "'admin' inherits can bless group membership");
$sel->is_checked_ok("isactive");
# Check that the automatically created product group has the membercontrol
# for it set to Default and othercontrol set to NA.
edit_product($sel, "ready_to_die");
$sel->click_ok("link=Edit Group Access Controls:");
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is("Edit Group Controls for ready_to_die");
$sel->value_is("entry_$group1_id", "off");
$sel->value_is("canedit_$group1_id", "off");
$sel->selected_label_is("membercontrol_$group1_id", "Default");
$sel->selected_label_is("othercontrol_$group1_id", "NA");
edit_product($sel, "ready_to_die");
$sel->go_back_ok();
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->click_ok('//a[@href="editproducts.cgi?action=del&product=ready_to_die"]');
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is("Delete Product 'ready_to_die'");
$sel->click_ok("delete");
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is("Product Deleted");
# The product has been deleted, but the group must survive.
go_to_admin($sel);
$sel->click_ok("link=Groups");
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is("Edit Groups");
$sel->is_text_present_ok("Access to bugs in the ready_to_die product");
# Create a new product. As the "ready_to_die" group already exists,
# a new "ready_to_die_" one must be created.
add_product($sel);
$sel->type_ok("product", "ready_to_die");
$sel->type_ok("description", "will die");
$sel->select_ok("default_op_sys_id", "Unspecified");
$sel->select_ok("default_platform_id", "Unspecified");
$sel->click_ok('//input[@value="Add"]');
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is("Product Created");
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=ready_to_die_");
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is("Change Group: ready_to_die_");
$group_url = $sel->get_location();
$group_url =~ /group=(\d+)/;
my $group2_id = $1;
$sel->value_is("desc", "Access to bugs in the ready_to_die product");
@groups = $sel->get_select_options("members_remove");
ok((grep { $_ eq 'admin' } @groups), "'admin' inherits group membership");
@groups = $sel->get_select_options("bless_from_remove");
ok((grep { $_ eq 'admin' } @groups), "'admin' inherits can bless group membership");
$sel->value_is("isactive", "on");
# Check group settings. The old 'ready_to_die' group has no relationship
# with this new product, despite its identical name.
edit_product($sel, "ready_to_die");
$sel->click_ok("link=Edit Group Access Controls:");
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is("Edit Group Controls for ready_to_die");
$sel->value_is("entry_$group1_id", "off");
$sel->value_is("entry_$group2_id", "off");
$sel->value_is("canedit_$group1_id", "off");
$sel->value_is("canedit_$group2_id", "off");
$sel->selected_label_is("membercontrol_$group1_id", "NA");
$sel->selected_label_is("othercontrol_$group1_id", "NA");
$sel->selected_label_is("membercontrol_$group2_id", "Default");
$sel->selected_label_is("othercontrol_$group2_id", "NA");
# Delete the ready_to_die_ group. It's bound to the ready_to_die product,
# so the deletion requires explicit agreement from the admin.
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("//a[contains(\@href, 'editgroups.cgi?action=del&group=$group2_id')]");
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is("Delete group");
$sel->is_text_present_ok("This group is tied to the following products");
$sel->click_ok("delete");
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is("Cannot Delete Group");
my $text = trim($sel->get_text("error_msg"));
ok($text =~ qr/All references to this group must be removed/,
"Group ready_to_die_ cannot be deleted as it is bound to a product");
$sel->go_back_ok();
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is("Delete group");
$sel->click_ok("unbind");
$sel->click_ok("delete");
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is("Group Deleted");
$text = trim($sel->get_text("message"));
ok($text =~ qr/The group ready_to_die_ has been deleted/, "Group ready_to_die_ has been deleted");
edit_product($sel, "ready_to_die");
$sel->go_back_ok();
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->click_ok('//a[@href="editproducts.cgi?action=del&product=ready_to_die"]');
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is("Delete Product 'ready_to_die'");
$sel->click_ok("delete");
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is("Product Deleted");
# Reset the makeproductgroups parameter. Now creating a new product must
# not create a new group, nor bind any group with it.
set_parameters($sel, { "Group Security" => {"makeproductgroups-off" => undef} });
add_product($sel);
$sel->type_ok("product", "ready_to_die");
$sel->type_ok("description", "will die");
$sel->select_ok("default_op_sys_id", "Unspecified");
$sel->select_ok("default_platform_id", "Unspecified");
$sel->click_ok('//input[@value="Add"]');
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is("Product Created");
# Make sure that all group controls are set to NA for this product.
edit_product($sel, "ready_to_die");
$sel->title_is("Edit Product 'ready_to_die'");
$sel->click_ok("link=Edit Group Access Controls:");
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is("Edit Group Controls for ready_to_die");
$sel->value_is("entry_$group1_id", "off");
$sel->value_is("canedit_$group1_id", "off");
$sel->selected_label_is("membercontrol_$group1_id", "NA");
$sel->selected_label_is("othercontrol_$group1_id", "NA");
# Delete remaining groups and products.
go_to_admin($sel);
$sel->click_ok("link=Groups");
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is("Edit Groups");
ok(!$sel->is_text_present('ready_to_die__'), 'No ready_to_die__ group created');
$sel->click_ok("//a[contains(\@href, 'editgroups.cgi?action=del&group=$group1_id')]");
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is("Delete group");
$sel->click_ok("delete");
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is("Group Deleted");
$text = trim($sel->get_text("message"));
ok($text =~ /The group ready_to_die has been deleted/, "Group ready_to_die has been deleted");
edit_product($sel, "ready_to_die");
$sel->go_back_ok();
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->click_ok('//a[@href="editproducts.cgi?action=del&product=ready_to_die"]');
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is("Delete Product 'ready_to_die'");
$sel->click_ok("delete");
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is("Product Deleted");
logout($sel);
|