summaryrefslogtreecommitdiff
path: root/rt/t/web
diff options
context:
space:
mode:
Diffstat (limited to 'rt/t/web')
-rw-r--r--rt/t/web/attachment_encoding.t103
-rw-r--r--rt/t/web/basic.t11
-rw-r--r--rt/t/web/cf_select_one.t10
-rw-r--r--rt/t/web/compilation_errors.t12
-rw-r--r--rt/t/web/html_template.t78
-rw-r--r--rt/t/web/offline_messages_utf8.t6
-rw-r--r--rt/t/web/query_builder.t13
-rw-r--r--rt/t/web/redirect-after-login.t243
-rw-r--r--rt/t/web/rest-non-ascii-subject.t5
-rw-r--r--rt/t/web/rights1.t28
-rw-r--r--rt/t/web/saved_search_update.t63
-rw-r--r--rt/t/web/ticket_seen.t26
-rw-r--r--rt/t/web/ticket_txn_content.t79
13 files changed, 615 insertions, 62 deletions
diff --git a/rt/t/web/attachment_encoding.t b/rt/t/web/attachment_encoding.t
new file mode 100644
index 000000000..6796c9969
--- /dev/null
+++ b/rt/t/web/attachment_encoding.t
@@ -0,0 +1,103 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use RT::Test tests => 28;
+use Encode;
+my ( $baseurl, $m ) = RT::Test->started_ok;
+ok $m->login, 'logged in as root';
+
+$RT::Test::SKIP_REQUEST_WORK_AROUND = 1;
+
+use utf8;
+
+use File::Spec;
+
+diag 'test without attachments' if $ENV{TEST_VERBOSE};
+
+{
+ $m->get_ok( $baseurl . '/Ticket/Create.html?Queue=1' );
+
+ $m->form_number(3);
+ $m->submit_form(
+ form_number => 3,
+ fields => { Subject => '标题', Content => '测试' },
+ );
+ $m->content_like( qr/Ticket \d+ created/i, 'created the ticket' );
+ $m->follow_link_ok( { text => 'with headers' },
+ '-> /Ticket/Attachment/WithHeaders/...' );
+ $m->content_contains( '标题', 'has subject 标题' );
+ $m->content_contains( '测试', 'has content 测试' );
+
+ my ( $id ) = $m->uri =~ /(\d+)$/;
+ ok( $id, 'found attachment id' );
+ my $attachment = RT::Attachment->new( $RT::SystemUser );
+ ok($attachment->Load($id), "load att $id");
+ # let make original encoding to gbk
+ ok( $attachment->SetHeader( 'X-RT-Original-Encoding' => 'gbk' ),
+ 'set original encoding to gbk' );
+ $m->get( $m->uri );
+ $m->content_contains( '标题', 'has subject 标题' );
+ $m->content_contains( '测试', 'has content 测试' );
+}
+
+diag 'test with attachemnts' if $ENV{TEST_VERBOSE};
+
+{
+
+ my $file =
+ File::Spec->catfile( File::Spec->tmpdir, 'rt_attachemnt_abcde.txt' );
+ open my $fh, '>', $file or die $!;
+ binmode $fh, ':utf8';
+ print $fh '附件';
+ close $fh;
+
+ $m->get_ok( $baseurl . '/Ticket/Create.html?Queue=1' );
+
+ $m->form_number(3);
+ $m->submit_form(
+ form_number => 3,
+ fields => { Subject => '标题', Content => '测试', Attach => $file },
+ );
+ $m->content_like( qr/Ticket \d+ created/i, 'created the ticket' );
+ $m->follow_link_ok( { text => 'with headers' },
+ '-> /Ticket/Attachment/WithHeaders/...' );
+
+ # subject is in the parent attachment, so there is no 标题
+ $m->content_lacks( '标题', 'does not have content 标题' );
+ $m->content_contains( '测试', 'has content 测试' );
+
+ my ( $id ) = $m->uri =~ /(\d+)$/;
+ ok( $id, 'found attachment id' );
+ my $attachment = RT::Attachment->new( $RT::SystemUser );
+ ok($attachment->Load($id), "load att $id");
+ # let make original encoding to gbk
+ ok( $attachment->SetHeader( 'X-RT-Original-Encoding' => 'gbk' ),
+ 'set original encoding to gbk' );
+ $m->get( $m->uri );
+ $m->content_lacks( '标题', 'does not have content 标题' );
+ $m->content_contains( '测试', 'has content 测试' );
+
+
+ $m->back;
+ $m->back;
+ $m->follow_link_ok( { text_regex => qr/by Enoch Root/ },
+ '-> /Ticket/Attachment/...' );
+ $m->content_contains( '附件', 'has content 附件' );
+
+ ( $id ) = $m->uri =~ /(\d+)\D+$/;
+ ok( $id, 'found attachment id' );
+ $attachment = RT::Attachment->new( $RT::SystemUser );
+ ok($attachment->Load($id), "load att $id");
+
+ # let make original encoding to gbk
+ ok( $attachment->SetHeader( 'X-RT-Original-Encoding' => 'gbk' ),
+ 'set original encoding to gbk' );
+ $m->get( $m->uri );
+ $m->content_contains( '附件', 'has content 附件' );
+
+ unlink $file;
+}
+
+
diff --git a/rt/t/web/basic.t b/rt/t/web/basic.t
index bc4d65587..3f94e732f 100644
--- a/rt/t/web/basic.t
+++ b/rt/t/web/basic.t
@@ -4,7 +4,7 @@ use strict;
use warnings;
use Encode;
-use RT::Test tests => 24;
+use RT::Test tests => 21;
$RT::Test::SKIP_REQUEST_WORK_AROUND = 1;
my ($baseurl, $agent) = RT::Test->started_ok;
@@ -20,15 +20,8 @@ diag $url if $ENV{TEST_VERBOSE};
# test a login
{
- ok($agent->{form}->find_input('user'));
- ok($agent->{form}->find_input('pass'));
-
- ok($agent->{'content'} =~ /username:/i);
- $agent->field( 'user' => 'root' );
- $agent->field( 'pass' => 'password' );
-
+ $agent->login('root' => 'password');
# the field isn't named, so we have to click link 0
- $agent->click(0);
is( $agent->{'status'}, 200, "Fetched the page ok");
ok( $agent->{'content'} =~ /Logout/i, "Found a logout link");
}
diff --git a/rt/t/web/cf_select_one.t b/rt/t/web/cf_select_one.t
index 39a808083..26c1fcf65 100644
--- a/rt/t/web/cf_select_one.t
+++ b/rt/t/web/cf_select_one.t
@@ -3,7 +3,7 @@
use strict;
use warnings;
-use RT::Test tests => 41;
+use RT::Test tests => 46;
my ($baseurl, $m) = RT::Test->started_ok;
ok $m->login, 'logged in as root';
@@ -31,9 +31,9 @@ diag "Create a CF" if $ENV{'TEST_VERBOSE'};
ok $cfid, "found id of the CF in the form, it's #$cfid";
}
-diag "add 'qwe', 'ASD' and '0' as values to the CF" if $ENV{'TEST_VERBOSE'};
+diag "add 'qwe', 'ASD', '0' and ' foo ' as values to the CF" if $ENV{'TEST_VERBOSE'};
{
- foreach my $value(qw(qwe ASD 0)) {
+ foreach my $value(qw(qwe ASD 0), 'foo ') {
$m->submit_form(
form_name => "ModifyCustomField",
fields => {
@@ -42,6 +42,10 @@ diag "add 'qwe', 'ASD' and '0' as values to the CF" if $ENV{'TEST_VERBOSE'};
button => 'Update',
);
$m->content_like( qr/Object created/, 'added a value to the CF' ); # or diag $m->content;
+ my $v = $value;
+ $v =~ s/^\s+$//;
+ $v =~ s/\s+$//;
+ $m->content_like( qr/value="$v"/, 'the added value is right' );
}
}
diff --git a/rt/t/web/compilation_errors.t b/rt/t/web/compilation_errors.t
index 46a862868..4fd9c40e9 100644
--- a/rt/t/web/compilation_errors.t
+++ b/rt/t/web/compilation_errors.t
@@ -7,7 +7,7 @@ BEGIN {
sub wanted {
-f && /\.html$/ && $_ !~ /Logout.html$/;
}
- my $tests = 7;
+ my $tests = 4;
find( sub { wanted() and $tests += 4 }, 'share/html/' );
plan tests => $tests;
}
@@ -36,15 +36,7 @@ is ($agent->{'status'}, 200, "Loaded a page");
# {{{ test a login
# follow the link marked "Login"
-
-ok($agent->{form}->find_input('user'));
-
-ok($agent->{form}->find_input('pass'));
-like ($agent->{'content'} , qr/username:/i);
-$agent->field( 'user' => 'root' );
-$agent->field( 'pass' => 'password' );
-# the field isn't named, so we have to click link 0
-$agent->click(0);
+$agent->login(root => 'password');
is($agent->{'status'}, 200, "Fetched the page ok");
like( $agent->{'content'} , qr/Logout/i, "Found a logout link");
diff --git a/rt/t/web/html_template.t b/rt/t/web/html_template.t
new file mode 100644
index 000000000..a2461dc97
--- /dev/null
+++ b/rt/t/web/html_template.t
@@ -0,0 +1,78 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use RT::Test tests => 19;
+use Encode;
+my ( $baseurl, $m ) = RT::Test->started_ok;
+ok $m->login, 'logged in as root';
+
+$RT::Test::SKIP_REQUEST_WORK_AROUND = 1;
+RT::Test->set_mail_catcher;
+
+use utf8;
+
+diag('make Autoreply template a html one and add utf8 chars')
+ if $ENV{TEST_VERBOSE};
+
+{
+ $m->follow_link_ok( { text => 'Configuration' }, '-> Configuration' );
+ $m->follow_link_ok( { text => 'Global' }, '-> Global' );
+ $m->follow_link_ok( { text => 'Templates' }, '-> Templates' );
+ $m->follow_link_ok( { text => 'Autoreply' }, '-> Autoreply' );
+
+ $m->form_number(3);
+ $m->submit_form(
+ fields => {
+ Content => <<'EOF',
+Subject: AutoReply: {$Ticket->Subject}
+Content-Type: text/html
+
+你好 éèà€
+{$Ticket->Subject}
+-------------------------------------------------------------------------
+{$Transaction->Content()}
+
+EOF
+ },
+ );
+ $m->content_like( qr/Content changed/, 'content is changed' );
+ $m->content_contains( '你好', 'content is really updated' );
+}
+
+diag('create a ticket to see the autoreply mail') if $ENV{TEST_VERBOSE};
+
+{
+ $m->get_ok( $baseurl . '/Ticket/Create.html?Queue=1' );
+
+ $m->form_number(3);
+ $m->submit_form(
+ form_number => 3,
+ fields => { Subject => '标题', Content => '<h1>测试</h1>',
+ ContentType => 'text/html' },
+ );
+ $m->content_like( qr/Ticket \d+ created/i, 'created the ticket' );
+ $m->follow_link( text => 'Show' );
+ $m->content_contains( '你好', 'html has 你好' );
+ $m->content_contains( 'éèà€', 'html has éèà€' );
+ $m->content_contains( '标题',
+ 'html has ticket subject 标题' );
+ $m->content_contains( '&lt;h1&gt;测试&lt;/h1&gt;',
+ 'html has ticket html content 测试' );
+}
+
+diag('test real mail outgoing') if $ENV{TEST_VERBOSE};
+
+{
+
+ # $mail is utf8 encoded
+ my ($mail) = RT::Test->fetch_caught_mails;
+ $mail = decode_utf8 $mail;
+ like( $mail, qr/你好.*你好/s, 'mail has éèà€' );
+ like( $mail, qr/éèà€.*éèà€/s, 'mail has éèà€' );
+ like( $mail, qr/标题.*标题/s, 'mail has ticket subject 标题' );
+ like( $mail, qr/测试.*测试/s, 'mail has ticket content 测试' );
+ like( $mail, qr!<h1>测试</h1>!, 'mail has ticket html content 测试' );
+}
+
diff --git a/rt/t/web/offline_messages_utf8.t b/rt/t/web/offline_messages_utf8.t
index c32e0bc27..9901b4555 100644
--- a/rt/t/web/offline_messages_utf8.t
+++ b/rt/t/web/offline_messages_utf8.t
@@ -8,7 +8,7 @@ use Encode;
use RT::Ticket;
my ( $url, $m ) = RT::Test->started_ok;
-$m->default_header( 'Accept-Language' => "zh-cn" );
+$m->default_header( 'Accept-Language' => "zh-tw" );
ok( $m->login, 'logged in' );
my $ticket_id;
@@ -38,7 +38,7 @@ EOF
button => 'UpdateTickets',
);
my $content = encode 'utf8', $m->content;
- ok( $content =~ qr/申请单 #(\d+) 成功新增于 &#39;General&#39; 表单/, 'message is shown right' );
+ ok( $content =~ m/申請單 #(\d+) 成功新增於 &#39;General&#39; 表單/, 'message is shown right' );
$ticket_id = $1;
}
@@ -60,7 +60,7 @@ EOF
my $content = encode 'utf8', $m->content;
ok(
$content =~
-qr/主题\s*的值从\s*&#39;test message&#39;\s*改为\s*&#39;test message update&#39;/,
+qr/主題\s*的值從\s*&#39;test message&#39;\s*改為\s*&#39;test message update&#39;/,
'subject is updated'
);
}
diff --git a/rt/t/web/query_builder.t b/rt/t/web/query_builder.t
index 02ed1297f..fa2c56da8 100644
--- a/rt/t/web/query_builder.t
+++ b/rt/t/web/query_builder.t
@@ -5,7 +5,7 @@ use HTTP::Request::Common;
use HTTP::Cookies;
use LWP;
use Encode;
-use RT::Test tests => 42;
+use RT::Test tests => 44;
my $cookie_jar = HTTP::Cookies->new;
my ($baseurl, $agent) = RT::Test->started_ok;
@@ -246,4 +246,13 @@ diag "input a condition, select (several conditions), click delete"
);
}
-1;
+diag "send query with not quoted negative number";
+{
+ my $response = $agent->get($url."Search/Build.html?Query=Priority%20>%20-2");
+ ok( $response->is_success, "Fetched " . $url."Search/Build.html" );
+
+ is( getQueryFromForm,
+ "Priority > -2",
+ "query is the same"
+ );
+}
diff --git a/rt/t/web/redirect-after-login.t b/rt/t/web/redirect-after-login.t
new file mode 100644
index 000000000..d39bb58c8
--- /dev/null
+++ b/rt/t/web/redirect-after-login.t
@@ -0,0 +1,243 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use RT::Test tests => 120;
+
+my ($baseurl, $agent) = RT::Test->started_ok;
+
+my $url = $agent->rt_base_url;
+diag $url if $ENV{TEST_VERBOSE};
+
+# test a login from the main page
+{
+ $agent->get_ok($url);
+ is($agent->{'status'}, 200, "Loaded a page");
+ is($agent->uri, $url, "didn't redirect to /NoAuth/Login.html for base URL");
+ ok($agent->current_form->find_input('user'));
+ ok($agent->current_form->find_input('pass'));
+ like($agent->current_form->action, qr{/NoAuth/Login\.html$}, "login form action is correct");
+
+ ok($agent->content =~ /username:/i);
+ $agent->field( 'user' => 'root' );
+ $agent->field( 'pass' => 'password' );
+
+ # the field isn't named, so we have to click link 0
+ $agent->click(0);
+ is( $agent->status, 200, "Fetched the page ok");
+ ok( $agent->content =~ /Logout/i, "Found a logout link");
+ is( $agent->uri, $url, "right URL" );
+ like( $agent->{redirected_uri}, qr{/NoAuth/Login\.html$}, "We redirected from login");
+ $agent->logout();
+}
+
+# test a bogus login from the main page
+{
+ $agent->get_ok($url);
+ is($agent->{'status'}, 200, "Loaded a page");
+ is($agent->uri, $url, "didn't redirect to /NoAuth/Login.html for base URL");
+ ok($agent->current_form->find_input('user'));
+ ok($agent->current_form->find_input('pass'));
+ like($agent->current_form->action, qr{/NoAuth/Login\.html$}, "login form action is correct");
+
+ ok($agent->content =~ /username:/i);
+ $agent->field( 'user' => 'root' );
+ $agent->field( 'pass' => 'wrongpass' );
+
+ # the field isn't named, so we have to click link 0
+ $agent->click(0);
+ is( $agent->status, 200, "Fetched the page ok");
+
+ ok( $agent->content =~ /Your username or password is incorrect/i, "Found the error message");
+ like( $agent->uri, qr{/NoAuth/Login\.html$}, "now on /NoAuth/Login.html" );
+ $agent->logout();
+
+ # Handle the warning after we're done with the page, since this leaves us
+ # with a completely different $mech
+ $agent->warning_like(qr/FAILED LOGIN for root/, "got failed login warning");
+}
+
+# test a login from a non-front page, both with a double leading slash and without
+for my $path (qw(Prefs/Other.html /Prefs/Other.html)) {
+ my $requested = $url.$path;
+ $agent->get_ok($requested);
+ is($agent->status, 200, "Loaded a page");
+ like($agent->uri, qr'/NoAuth/Login\.html\?next=[a-z0-9]{32}', "on login page, with next page hash");
+ is($agent->{redirected_uri}, $requested, "redirected from our requested page");
+
+ ok($agent->current_form->find_input('user'));
+ ok($agent->current_form->find_input('pass'));
+ ok($agent->current_form->find_input('next'));
+ like($agent->value('next'), qr/^[a-z0-9]{32}$/i, "next page argument is a hash");
+ like($agent->current_form->action, qr{/NoAuth/Login\.html$}, "login form action is correct");
+
+ ok($agent->content =~ /username:/i);
+ $agent->field( 'user' => 'root' );
+ $agent->field( 'pass' => 'password' );
+
+ # the field isn't named, so we have to click link 0
+ $agent->click(0);
+ is( $agent->status, 200, "Fetched the page ok");
+ ok( $agent->content =~ /Logout/i, "Found a logout link");
+
+ if ($path =~ m{/}) {
+ (my $collapsed = $path) =~ s{^/}{};
+ is( $agent->uri, $url.$collapsed, "right URL, with leading slashes in path collapsed" );
+ } else {
+ is( $agent->uri, $requested, "right URL" );
+ }
+
+ like( $agent->{redirected_uri}, qr{/NoAuth/Login\.html}, "We redirected from login");
+ $agent->logout();
+}
+
+# test a bogus login from a non-front page
+{
+ my $requested = $url.'Prefs/Other.html';
+ $agent->get_ok($requested);
+ is($agent->status, 200, "Loaded a page");
+ like($agent->uri, qr'/NoAuth/Login\.html\?next=[a-z0-9]{32}', "on login page, with next page hash");
+ is($agent->{redirected_uri}, $requested, "redirected from our requested page");
+
+ ok($agent->current_form->find_input('user'));
+ ok($agent->current_form->find_input('pass'));
+ ok($agent->current_form->find_input('next'));
+ like($agent->value('next'), qr/^[a-z0-9]{32}$/i, "next page argument is a hash");
+ like($agent->current_form->action, qr{/NoAuth/Login\.html$}, "login form action is correct");
+
+ ok($agent->content =~ /username:/i);
+ $agent->field( 'user' => 'root' );
+ $agent->field( 'pass' => 'wrongpass' );
+
+ # the field isn't named, so we have to click link 0
+ $agent->click(0);
+ is( $agent->status, 200, "Fetched the page ok");
+
+ ok( $agent->content =~ /Your username or password is incorrect/i, "Found the error message");
+ like( $agent->uri, qr{/NoAuth/Login\.html$}, "still on /NoAuth/Login.html" );
+
+ # try to login again
+ ok($agent->current_form->find_input('user'));
+ ok($agent->current_form->find_input('pass'));
+ ok($agent->current_form->find_input('next'));
+ like($agent->value('next'), qr/^[a-z0-9]{32}$/i, "next page argument is a hash");
+ like($agent->current_form->action, qr{/NoAuth/Login\.html$}, "login form action is correct");
+
+ ok($agent->content =~ /username:/i);
+ $agent->field( 'user' => 'root' );
+ $agent->field( 'pass' => 'password' );
+
+ # the field isn't named, so we have to click link 0
+ $agent->click(0);
+ is( $agent->status, 200, "Fetched the page ok");
+
+ # check out where we got to
+ is( $agent->uri, $requested, "right URL" );
+ like( $agent->{redirected_uri}, qr{/NoAuth/Login\.html}, "We redirected from login");
+ $agent->logout();
+
+ # Handle the warning after we're done with the page, since this leaves us
+ # with a completely different $mech
+ $agent->warning_like(qr/FAILED LOGIN for root/, "got failed login warning");
+}
+
+# test a login from the main page with query params
+{
+ my $requested = $url."?user=root;pass=password";
+ $agent->get_ok($requested);
+ is($agent->{'status'}, 200, "Loaded a page");
+ is($agent->uri, $requested, "didn't redirect to /NoAuth/Login.html for base URL");
+ ok($agent->content =~ /Logout/i, "Found a logout link - we're logged in");
+ $agent->logout();
+}
+
+# test a bogus login from the main page with query params
+{
+ my $requested = $url."?user=root;pass=wrongpass";
+ $agent->get_ok($requested);
+ is($agent->{'status'}, 200, "Loaded a page");
+ is($agent->uri, $requested, "didn't redirect to /NoAuth/Login.html for base URL");
+
+ ok($agent->content =~ /Your username or password is incorrect/i, "Found the error message");
+ ok($agent->current_form->find_input('user'));
+ ok($agent->current_form->find_input('pass'));
+ like($agent->current_form->action, qr{/NoAuth/Login\.html$}, "login form action is correct");
+
+ # Handle the warning after we're done with the page, since this leaves us
+ # with a completely different $mech
+ $agent->warning_like(qr/FAILED LOGIN for root/, "got failed login warning");
+}
+
+# test a bogus login from a non-front page with query params
+{
+ my $requested = $url."Prefs/Other.html?user=root;pass=wrongpass";
+ $agent->get_ok($requested);
+ is($agent->status, 200, "Loaded a page");
+ like($agent->uri, qr'/NoAuth/Login\.html\?next=[a-z0-9]{32}', "on login page, with next page hash");
+ is($agent->{redirected_uri}, $requested, "redirected from our requested page");
+ ok( $agent->content =~ /Your username or password is incorrect/i, "Found the error message");
+
+ ok($agent->current_form->find_input('user'));
+ ok($agent->current_form->find_input('pass'));
+ ok($agent->current_form->find_input('next'));
+ like($agent->value('next'), qr/^[a-z0-9]{32}$/i, "next page argument is a hash");
+ like($agent->current_form->action, qr{/NoAuth/Login\.html$}, "login form action is correct");
+
+ # Try to login again
+ ok($agent->content =~ /username:/i);
+ $agent->field( 'user' => 'root' );
+ $agent->field( 'pass' => 'password' );
+
+ # the field isn't named, so we have to click link 0
+ $agent->click(0);
+ is( $agent->status, 200, "Fetched the page ok");
+
+ # check out where we got to
+ is( $agent->uri, $requested, "right URL" );
+ like( $agent->{redirected_uri}, qr{/NoAuth/Login\.html}, "We redirected from login");
+ $agent->logout();
+
+ # Handle the warning after we're done with the page, since this leaves us
+ # with a completely different $mech
+ $agent->warning_like(qr/FAILED LOGIN for root/, "got failed login warning");
+}
+
+# test REST login response
+{
+ my $requested = $url."REST/1.0/?user=root;pass=password";
+ $agent->get($requested);
+ is($agent->status, 200, "Loaded a page");
+ is($agent->uri, $requested, "didn't redirect to /NoAuth/Login.html for REST");
+ $agent->get_ok($url);
+ $agent->logout();
+}
+
+# test REST login response for wrong pass
+{
+ my $requested = $url."REST/1.0/?user=root;pass=passwrong";
+ $agent->get_ok($requested);
+ is($agent->status, 200, "Loaded a page");
+ is($agent->uri, $requested, "didn't redirect to /NoAuth/Login.html for REST");
+ like($agent->content, qr/401 Credentials required/i, "got error status");
+ like($agent->content, qr/Your username or password is incorrect/, "got error message");
+
+ # Handle the warning after we're done with the page, since this leaves us
+ # with a completely different $mech
+ $agent->warning_like(qr/FAILED LOGIN for root/, "got failed login warning");
+}
+
+# test REST login response for no creds
+{
+ my $requested = $url."REST/1.0/";
+ $agent->get_ok($requested);
+ is($agent->status, 200, "Loaded a page");
+ is($agent->uri, $requested, "didn't redirect to /NoAuth/Login.html for REST");
+ like($agent->content, qr/401 Credentials required/i, "got error status");
+ unlike($agent->content, qr/Your username or password is incorrect/, "didn't get any error message");
+}
+
+# XXX TODO: we should also be testing WebExternalAuth here, but we don't have
+# the framework for dealing with that
+
+1;
diff --git a/rt/t/web/rest-non-ascii-subject.t b/rt/t/web/rest-non-ascii-subject.t
index 70c910afe..371b2ffc0 100644
--- a/rt/t/web/rest-non-ascii-subject.t
+++ b/rt/t/web/rest-non-ascii-subject.t
@@ -49,7 +49,4 @@ is($ticket->Subject, $subject, "ticket subject successfully set");
my $attach = $ticket->Transactions->First->Attachments->First;
is($attach->Subject, $subject, "attachement subject successfully set");
-TODO: {
- local $TODO = "Not fixed yet, but not a regression";
- is($attach->GetHeader('Subject'), $subject, "attachement header subject successfully set");
-}
+is($attach->GetHeader('Subject'), $subject, "attachement header subject successfully set");
diff --git a/rt/t/web/rights1.t b/rt/t/web/rights1.t
index 6da204cc9..c8892f2fe 100644
--- a/rt/t/web/rights1.t
+++ b/rt/t/web/rights1.t
@@ -2,7 +2,7 @@
use strict;
use HTTP::Cookies;
-use RT::Test tests => 35;
+use RT::Test tests => 29;
my ($baseurl, $agent) = RT::Test->started_ok;
# Create a user with basically no rights, to start.
@@ -26,7 +26,7 @@ $agent->cookie_jar($cookie_jar);
no warnings 'once';
# get the top page
-login($agent, $user_obj);
+$agent->login( $user_obj->Name, 'customer');
# Test for absence of Configure and Preferences tabs.
ok(!$agent->find_link( url => "$RT::WebPath/Admin/",
@@ -107,28 +107,4 @@ ok($agent->form_name('BuildQuery'), "Yep, form is still there");
my $input = $agent->current_form->find_input('ValueOfActor');
ok(grep(/customer-$$/, $input->value_names()), "Found self in the actor listing");
-sub login {
- my $agent = shift;
-
- my $url = "http://localhost:" . RT->Config->Get('WebPort') . RT->Config->Get('WebPath') . "/";
- $agent->get($url);
- is( $agent->{'status'}, 200,
- "Loaded a page - http://localhost" . RT->Config->Get('WebPath') );
-
- # {{{ test a login
-
- # follow the link marked "Login"
-
- ok( $agent->{form}->find_input('user') );
-
- ok( $agent->{form}->find_input('pass') );
- like( $agent->{'content'} , qr/username:/i );
- $agent->field( 'user' => $user_obj->Name );
- $agent->field( 'pass' => 'customer' );
-
- # the field isn't named, so we have to click link 0
- $agent->click(0);
- is( $agent->{'status'}, 200, "Fetched the page ok" );
- like( $agent->{'content'} , qr/Logout/i, "Found a logout link" );
-}
1;
diff --git a/rt/t/web/saved_search_update.t b/rt/t/web/saved_search_update.t
new file mode 100644
index 000000000..9b2724e82
--- /dev/null
+++ b/rt/t/web/saved_search_update.t
@@ -0,0 +1,63 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use RT::Test tests => 16;
+
+my $root = RT::User->new( $RT::SystemUser );
+$root->Load('root');
+my $uid = $root->id;
+ok( $uid, 'loaded root' );
+
+my $group = RT::Group->new( $RT::SystemUser );
+my ($gid) = $group->CreateUserDefinedGroup( Name => 'foo' );
+ok( $gid, 'created group foo');
+ok( $group->AddMember( $root->PrincipalId ) );
+
+my ( $baseurl, $m ) = RT::Test->started_ok;
+ok($m->login, 'logged in');
+
+$m->follow_link_ok({text => "Tickets"}, "to query builder");
+
+$m->form_name("BuildQuery");
+
+$m->field(ValueOfid => 10 );
+$m->click("AddClause");
+$m->content_contains( 'id &lt; 10', "added new clause");
+
+$m->form_name("BuildQuery");
+$m->field(SavedSearchDescription => 'user_saved');
+$m->click("SavedSearchSave");
+
+$m->form_name("BuildQuery");
+is($m->value('SavedSearchDescription'), 'user_saved', "name is correct");
+like($m->value('SavedSearchOwner'), qr/^RT::User-\d+$/, "name is correct");
+ok(
+ scalar grep { $_ eq "RT::Group-$gid" }
+ $m->current_form->find_input('SavedSearchOwner')->possible_values,
+ 'found group foo'
+);
+$m->field(SavedSearchDescription => 'group_saved');
+$m->select(SavedSearchOwner => "RT::Group-$gid");
+$m->click("SavedSearchSave");
+
+$m->form_name("BuildQuery");
+is($m->value('SavedSearchOwner'), "RT::Group-$gid", "privacy is correct");
+is($m->value('SavedSearchDescription'), 'group_saved', "name is correct");
+$m->select(SavedSearchOwner => "RT::User-$uid");
+$m->field(SavedSearchDescription => 'user_saved');
+$m->click("SavedSearchSave");
+
+
+$m->form_name("BuildQuery");
+is($m->value('SavedSearchOwner'), "RT::User-$uid", "privacy is correct");
+is($m->value('SavedSearchDescription'), 'user_saved', "name is correct");
+$m->select(SavedSearchOwner => "RT::System-1");
+$m->field(SavedSearchDescription => 'system_saved');
+$m->click("SavedSearchSave");
+
+$m->form_name("BuildQuery");
+is($m->value('SavedSearchOwner'), "RT::System-1", "privacy is correct");
+is($m->value('SavedSearchDescription'), 'system_saved', "name is correct");
+
diff --git a/rt/t/web/ticket_seen.t b/rt/t/web/ticket_seen.t
index 00b2632d8..3a77a5899 100644
--- a/rt/t/web/ticket_seen.t
+++ b/rt/t/web/ticket_seen.t
@@ -3,7 +3,7 @@
use strict;
use warnings;
-use RT::Test tests => 16;
+use RT::Test tests => 21;
my $queue = RT::Test->load_or_create_queue( Name => 'Regression' );
ok $queue && $queue->id, 'loaded or created queue';
@@ -52,6 +52,14 @@ diag "user B adds a message, we check that user A see notification and can clear
my ($status, $msg) = $ticket->Correspond( Content => 'bla-bla' );
ok $status, 'added reply' or diag "error: $msg";
+ my $txns = $ticket->Transactions;
+ $txns->Limit(
+ FIELD => 'Type',
+ VALUE => "Correspond",
+ );
+ my $txn = $txns->Last;
+ my $reply_id = $txn->id;
+ ok( $reply_id, 'got correspond txn id' );
$agent_a->goto_ticket($tid);
$agent_a->content_like(qr/bla-bla/ims, 'the message on the page');
@@ -61,11 +69,23 @@ diag "user B adds a message, we check that user A see notification and can clear
'we have not seen something'
);
+ $agent_a->follow_link_ok(
+ { text => 'jump to the first unread message' },
+ 'try to jump to first unread message'
+ );
+ like( $agent_a->base, qr/#txn-$reply_id$/, 'contains anchor' );
+
$agent_a->follow_link_ok({text => 'jump to the first unread message and mark all messages as seen'}, 'try to mark all as seen');
$agent_a->content_like(
qr/Marked all messages as seen/ims,
'see success message'
);
+ like( $agent_a->base, qr/#txn-$reply_id$/, 'contains anchor' );
+
+ $agent_a->content_like(
+ qr/Marked all messages as seen/ims,
+ 'see success message'
+ );
$agent_a->goto_ticket($tid);
$agent_a->content_unlike(
@@ -74,7 +94,3 @@ diag "user B adds a message, we check that user A see notification and can clear
);
}
-
-
-
-
diff --git a/rt/t/web/ticket_txn_content.t b/rt/t/web/ticket_txn_content.t
new file mode 100644
index 000000000..1c1056a3e
--- /dev/null
+++ b/rt/t/web/ticket_txn_content.t
@@ -0,0 +1,79 @@
+#!/usr/bin/perl -w
+use strict;
+
+use RT::Test tests => 37;
+use File::Temp 'tempfile';
+use File::Spec;
+my ( $plain_fh, $plain_file ) =
+ tempfile( 'rttestXXXXXX', SUFFIX => '.txt', UNLINK => 1, TMPDIR => 1 );
+print $plain_fh "this is plain content";
+close $plain_fh;
+my $plain_name = (File::Spec->splitpath($plain_file))[-1];
+
+my ( $html_fh, $html_file ) =
+ tempfile( 'rttestXXXXXX', SUFFIX => '.html', UNLINK => 1, TMPDIR => 1 );
+print $html_fh "this is html content";
+close $html_fh;
+my $html_name = (File::Spec->splitpath($html_file))[-1];
+
+my ($baseurl, $m) = RT::Test->started_ok;
+ok $m->login, 'logged in';
+
+my $queue = RT::Queue->new($RT::Nobody);
+my $qid = $queue->Load('General');
+ok( $qid, "Loaded General queue" );
+
+RT::Test->set_mail_catcher;
+RT::Test->clean_caught_mails;
+
+for my $type ( 'text/plain', 'text/html' ) {
+ $m->form_name('CreateTicketInQueue');
+ $m->field( 'Queue', $qid );
+ $m->submit;
+ is( $m->status, 200, "request successful" );
+ $m->content_like( qr/Create a new ticket/, 'ticket create page' );
+
+ $m->form_name('TicketCreate');
+ $m->field( 'Subject', 'with plain attachment' );
+ $m->field( 'Attach', $plain_file );
+ $m->field( 'Content', 'this is main content' );
+ $m->field( 'ContentType', $type ) unless $type eq 'text/plain';
+ $m->submit;
+ is( $m->status, 200, "request successful" );
+ $m->content_like( qr/with plain attachment/,
+ 'we have subject on the page' );
+ $m->content_like( qr/this is main content/, 'main content' );
+ $m->content_like( qr/Download $plain_name/, 'download plain file link' );
+
+ my ( $mail ) = RT::Test->fetch_caught_mails;
+ like( $mail, qr/this is main content/, 'email contains main content' );
+ # check the email link in page too
+ $m->follow_link_ok( { text => 'Show' }, 'show the email outgoing' );
+ $m->content_like( qr/this is main content/, 'email contains main content');
+ $m->back;
+
+ $m->follow_link_ok( { text => 'Reply' }, "reply to the ticket" );
+ $m->form_name('TicketUpdate');
+ $m->field( 'Attach', $plain_file );
+ $m->click('AddMoreAttach');
+ is( $m->status, 200, "request successful" );
+
+ $m->form_name('TicketUpdate');
+ $m->field( 'Attach', $html_file );
+ # add UpdateCc so we can get email record
+ $m->field( 'UpdateCc', 'rt-test@example.com' );
+ $m->field( 'UpdateContent', 'this is main reply content' );
+ $m->field( 'UpdateContentType', $type ) unless $type eq 'text/plain';
+ $m->click('SubmitTicket');
+ is( $m->status, 200, "request successful" );
+
+ $m->content_like( qr/this is main reply content/, 'main reply content' );
+ $m->content_like( qr/Download $html_name/, 'download html file link' );
+
+ ( $mail ) = RT::Test->fetch_caught_mails;
+ like( $mail, qr/this is main reply content/, 'email contains main reply content' );
+ # check the email link in page too
+ $m->follow_link_ok( { text => 'Show', n => 2 }, 'show the email outgoing' );
+ $m->content_like( qr/this is main reply content/, 'email contains main reply content');
+ $m->back;
+}