[Rt-commit] rt branch, 4.0/rest-remove-link-validation, created. rt-4.0.5-80-g8270885
? sunnavy
sunnavy at bestpractical.com
Thu Mar 1 13:58:00 EST 2012
The branch, 4.0/rest-remove-link-validation has been created
at 8270885ce3f7d686bc572b7a8f3413835453bf2e (commit)
- Log -----------------------------------------------------------------
commit c7274db8e651c595f0cfc29d0818f92d9711d56a
Author: sunnavy <sunnavy at bestpractical.com>
Date: Fri Mar 2 02:23:22 2012 +0800
remove link validation in rest
it's too strict to handle stuff other than tickets.
no worries because lower layer can catch them.
diff --git a/bin/rt.in b/bin/rt.in
index 5e1c053..c4f0510 100755
--- a/bin/rt.in
+++ b/bin/rt.in
@@ -905,11 +905,6 @@ sub link {
if (@ARGV == 3) {
my ($from, $rel, $to) = @ARGV;
- if ($from !~ /^\d+$/ || $to !~ /^\d+$/) {
- my $bad = $from =~ /^\d+$/ ? $to : $from;
- whine "Invalid $type ID '$bad' specified.";
- $bad = 1;
- }
if (($type eq "ticket") && ( ! exists $ltypes{lc $rel})) {
whine "Invalid link '$rel' for type $type specified.";
$bad = 1;
diff --git a/share/html/REST/1.0/ticket/link b/share/html/REST/1.0/ticket/link
index aa80b0d..8d3345f 100755
--- a/share/html/REST/1.0/ticket/link
+++ b/share/html/REST/1.0/ticket/link
@@ -81,10 +81,9 @@ if ($id && $object && $id != $object) {
goto OUTPUT;
}
$id ||= $object;
-unless ($id =~ /^\d+$/ && $to =~ /^\d+$/) {
- my $bad = ($id !~ /^\d+$/) ? $id : $to;
+unless ($id =~ /^\d+$/) {
$output = $r->path_info. "\n";
- $output .= "Invalid ticket id: '$bad'.\n";
+ $output .= "Invalid ticket id: '$id'.\n";
$status = "400 Bad Request";
goto OUTPUT;
}
commit 8270885ce3f7d686bc572b7a8f3413835453bf2e
Author: sunnavy <sunnavy at bestpractical.com>
Date: Thu Mar 1 20:32:48 2012 +0800
cli link to articles test
diff --git a/t/web/command_line_link_to_articles.t b/t/web/command_line_link_to_articles.t
new file mode 100644
index 0000000..26ee65f
--- /dev/null
+++ b/t/web/command_line_link_to_articles.t
@@ -0,0 +1,48 @@
+use strict;
+use warnings;
+use Test::Expect;
+use RT::Test tests => 12, actual_server => 1;
+
+my $class = RT::Class->new( RT->SystemUser );
+my ( $class_id, $msg ) = $class->Create( Name => 'foo' );
+ok( $class_id, $msg );
+
+my $article = RT::Article->new( RT->SystemUser );
+( my $article_id, $msg ) =
+ $article->Create( Class => 'foo', Summary => 'article summary' );
+ok( $article_id, $msg );
+
+my ( $baseurl, $m ) = RT::Test->started_ok;
+my $rt_tool_path = "$RT::BinPath/rt";
+
+$ENV{'RTUSER'} = 'root';
+$ENV{'RTPASSWD'} = 'password';
+$RT::Logger->debug(
+ "Connecting to server at " . RT->Config->Get('WebBaseURL') );
+$ENV{'RTSERVER'} = RT->Config->Get('WebBaseURL');
+$ENV{'RTDEBUG'} = '1';
+$ENV{'RTCONFIG'} = '/dev/null';
+
+expect_run(
+ command => "$rt_tool_path shell",
+ prompt => 'rt> ',
+ quit => 'quit',
+);
+expect_send( q{create -t ticket set subject='new ticket'},
+ "creating a ticket..." );
+
+expect_like( qr/Ticket \d+ created/, "created the ticket" );
+expect_handle->before() =~ /Ticket (\d+) created/;
+my $ticket_id = $1;
+expect_send(
+ "link $ticket_id RefersTo a:$article_id",
+ "link $ticket_id RefersTo a:$article_id"
+);
+expect_like( qr/Created link $ticket_id RefersTo a:$article_id/,
+ 'created link' );
+expect_send( "show -s ticket/$ticket_id/links", "show ticket links" );
+expect_like( qr/RefersTo: [\w\d\.\-]+:\/\/[\w\d\.]+\/article\/$article_id/,
+ "found new created link" );
+
+expect_quit();
+
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list