summaryrefslogtreecommitdiffstats
path: root/xt
diff options
context:
space:
mode:
Diffstat (limited to 'xt')
-rw-r--r--xt/lib/QA/RPC.pm11
-rw-r--r--xt/lib/QA/Util.pm14
-rw-r--r--xt/webservice/bug_attachments.t4
-rw-r--r--xt/webservice/bug_comments.t1
-rw-r--r--xt/webservice/user_get.t4
5 files changed, 29 insertions, 5 deletions
diff --git a/xt/lib/QA/RPC.pm b/xt/lib/QA/RPC.pm
index e2f1f7597..93414e231 100644
--- a/xt/lib/QA/RPC.pm
+++ b/xt/lib/QA/RPC.pm
@@ -236,7 +236,9 @@ sub bz_run_tests {
}
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
@@ -253,6 +255,12 @@ sub bz_test_bug {
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,
@@ -260,6 +268,7 @@ sub bz_test_bug {
}
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");
}
diff --git a/xt/lib/QA/Util.pm b/xt/lib/QA/Util.pm
index 90a6902e5..eb68a0b5b 100644
--- a/xt/lib/QA/Util.pm
+++ b/xt/lib/QA/Util.pm
@@ -18,6 +18,7 @@ use lib "$RealBin/../../lib", "$RealBin/../../../local/lib/perl5";
use autodie;
use Data::Dumper;
+use Email::Address;
use Test::More;
use parent qw(Exporter);
@@ -25,6 +26,7 @@ use parent qw(Exporter);
trim
url_quote
random_string
+ email_filter
log_in
logout
@@ -367,6 +369,18 @@ sub set_parameters {
}
}
+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__
diff --git a/xt/webservice/bug_attachments.t b/xt/webservice/bug_attachments.t
index 2150a0ff8..b0e6af81c 100644
--- a/xt/webservice/bug_attachments.t
+++ b/xt/webservice/bug_attachments.t
@@ -141,8 +141,8 @@ sub post_success {
"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');
diff --git a/xt/webservice/bug_comments.t b/xt/webservice/bug_comments.t
index 2312083d6..107f866c3 100644
--- a/xt/webservice/bug_comments.t
+++ b/xt/webservice/bug_comments.t
@@ -47,6 +47,7 @@ sub test_comments {
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;
diff --git a/xt/webservice/user_get.t b/xt/webservice/user_get.t
index a31e957b4..835b48153 100644
--- a/xt/webservice/user_get.t
+++ b/xt/webservice/user_get.t
@@ -137,8 +137,8 @@ sub post_success {
'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");