}
sub bz_test_bug {
- my ($self, $fields, $bug, $expect, $t, $creation_time) = @_;
+ my ($self, $fields, $bug, $orig_expect, $t, $creation_time) = @_;
+
+ my $expect = dclone($orig_expect);
foreach my $field (sort @$fields) {
# "description" is used by Bug.create but comments are not returned
next;
}
+ foreach my $field (qw(assigned_to creator qa_contact)) {
+ if (!$t->{user}) {
+ $expect->{$field} = email_filter($expect->{$field});
+ }
+ }
+
if ($field =~ /^is_/) {
ok(defined $bug->{$field}, $self->TYPE . ": $field is not null");
is($bug->{$field} ? 1 : 0, $expect->{$field} ? 1 : 0,
}
elsif ($field eq 'cc') {
foreach my $cc_item (@{ $expect->{cc} || [] }) {
+ $cc_item = email_filter($cc_item) if !$t->{user};
ok(grep($_ eq $cc_item, @{ $bug->{cc} }),
$self->TYPE . ": $field contains $cc_item");
}
use autodie;
use Data::Dumper;
+use Email::Address;
use Test::More;
use parent qw(Exporter);
trim
url_quote
random_string
+ email_filter
log_in
logout
}
}
+sub email_filter {
+ my ($toencode) = @_;
+ my @emails = Email::Address->parse($toencode);
+ if (scalar @emails) {
+ my @hosts = map { quotemeta($_->host) } @emails;
+ my $hosts_re = join('|', @hosts);
+ $toencode =~ s/\@(?:$hosts_re)//g;
+ return $toencode;
+ }
+ return $toencode;
+}
+
1;
__END__
"content_type is correct");
cmp_ok($attachment->{file_name}, '=~', qr/^\w+\.pl$/,
"filename is in the expected format");
- is($attachment->{creator}, $config->{QA_Selenium_TEST_user_login},
- "creator is the correct user");
+ is($attachment->{creator}, ($t->{user} ? $config->{QA_Selenium_TEST_user_login} : email_filter($config->{QA_Selenium_TEST_user_login})),
+ "creator is the correct user");
my $data = $attachment->{data};
$data = decode_base64($data) if $rpc->isa('QA::RPC::JSONRPC');
is($data, $content, 'data is correct');
is($comment->{text}, $expected_text, "comment has the correct text");
my $priv_login = $rpc->bz_config->{PRIVATE_BUG_USER . '_user_login'};
+ $priv_login = $t->{user} ? $priv_login : email_filter($priv_login);
is($comment->{creator}, $priv_login, "comment creator is correct");
my $creation_day;
'Admin correctly gets all user fields');
}
elsif ($user) {
- ok(exists $item->{email} && exists $item->{can_login},
- 'Logged-in user correctly gets email and can_login');
+ ok(exists $item->{can_login},
+ 'Logged-in user correctly gets can_login');
ok(!exists $item->{email_enabled}
&& !exists $item->{login_denied_text},
"Non-admin user doesn't get email_enabled and login_denied_text");