[Bps-public-commit] r15563 - in sd/trunk: .

sartak at bestpractical.com sartak at bestpractical.com
Wed Aug 27 15:46:31 EDT 2008


Author: sartak
Date: Wed Aug 27 15:46:29 2008
New Revision: 15563

Modified:
   sd/trunk/   (props changed)
   sd/trunk/t/sd-rt-permission.t

Log:
 r70603 at onn:  sartak | 2008-08-27 15:46:14 -0400
 A failing test for pushing a ticket when we have no write right


Modified: sd/trunk/t/sd-rt-permission.t
==============================================================================
--- sd/trunk/t/sd-rt-permission.t	(original)
+++ sd/trunk/t/sd-rt-permission.t	Wed Aug 27 15:46:29 2008
@@ -6,9 +6,6 @@
 use warnings;
 no warnings 'once';
 
-# create a ticket as root, then try to pull it as someone who doesn't have the
-# rights to see it
-
 use Test::More;
 
 BEGIN {
@@ -24,16 +21,17 @@
     diag "export SD_REPO=".$ENV{'PROPHET_REPO'} ."\n";
 }
 
-use Prophet::Test tests => 2;
+use Prophet::Test tests => 11;
 use App::SD::Test;
 use RT::Client::REST;
 use RT::Client::REST::Ticket;
 
 RT::Handle->InsertData( $RT::EtcPath . '/initialdata' );
 
+my ($ret, $out, $err);
 my ( $url, $m ) = RT::Test->started_ok;
 
-my $user = RT::Test->load_or_create_user(
+my $alice = RT::Test->load_or_create_user(
     Name     => 'alice',
     Password => 'AlicesPassword',
 );
@@ -41,12 +39,15 @@
 my $root = RT::Client::REST->new( server => $url );
 $root->login( username => 'root', password => 'password' );
 
+diag("create a ticket as root, then try to pull it as someone who doesn't have the rights to see it");
+
 my $ticket = RT::Client::REST::Ticket->new(
     rt      => $root,
     queue   => 'General',
     status  => 'new',
     subject => 'Fly Man',
-)->store( text => "Ticket Comment" );
+)->store(text => "Ticket Comment");
+my $ticket_id = $ticket->id;
 
 my $root_url = $url;
 $root_url =~ s|http://|http://root:password@|;
@@ -57,11 +58,48 @@
 my $sd_alice_url = "rt:$alice_url|General|Status!='resolved'";
 
 as_alice {
-    run_output_matches( 'sd', [ 'pull', '--from',  $sd_alice_url ],
-        [
-            qr/^Pulling from rt:/,
-            "No new changesets.",
-        ],
+    ($ret, $out, $err) = run_script('sd', ['pull', '--from',  $sd_alice_url]);
+    ok($ret);
+    like($out, qr/No new changesets/);
+
+    TODO: {
+        local $TODO = "not coming through for some reason";
+        like($err, qr/No tickets found/);
+    }
+};
+
+diag("grant read rights, ensure we can pull it");
+
+my $queue = RT::Queue->new($RT::SystemUser);
+$queue->Load('General');
+
+$alice->PrincipalObj->GrantRight(Right => 'SeeQueue',   Object => $queue);
+$alice->PrincipalObj->GrantRight(Right => 'ShowTicket', Object => $queue);
+
+my $flyman_id;
+as_alice {
+    ($ret, $out, $err) = run_script('sd', ['pull', '--from',  $sd_alice_url]);
+    ok($ret);
+    like($out, qr/Merged one changeset/);
+
+    run_output_matches( 'sd', [ 'ticket', 'list', '--regex', '.' ],
+        [qr/(.*?)(?{ $flyman_id = $1 }) Fly Man new/] );
+};
+
+diag("without write rights, ensure that trying to push it gives a sane error");
+
+as_alice {
+    run_output_matches('sd', ['ticket', 'update', $flyman_id, '--', 'priority=20'],
+        [qr/ticket .*$flyman_id.* updated/],
     );
+
+    ($ret, $out, $err) = run_script('sd', ['push', '--to',  $sd_alice_url]);
+    ok($ret);
+    like($err, qr/You are not allowed to modify ticket $ticket_id/);
+
+    TODO: {
+        local $TODO = "we report success even though it failed";
+        unlike($out, qr/Merged one changeset/);
+    }
 };
 



More information about the Bps-public-commit mailing list