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

sartak at bestpractical.com sartak at bestpractical.com
Wed Aug 27 13:42:17 EDT 2008


Author: sartak
Date: Wed Aug 27 13:42:16 2008
New Revision: 15550

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

Log:
 r70580 at onn:  sartak | 2008-08-27 13:42:10 -0400
 Some tests for permission denied errors when pulling from RT


Added: sd/trunk/t/sd-rt-permission.t
==============================================================================
--- (empty file)
+++ sd/trunk/t/sd-rt-permission.t	Wed Aug 27 13:42:16 2008
@@ -0,0 +1,67 @@
+#!/usr/bin/env perl
+# to run:
+#
+# RT_DBA_USER=root RT_DBA_PASSWORD= prove -lv -I/Users/clkao/work/bps/rt-3.7/lib t/sd-rt.t
+use strict;
+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 {
+    unless (eval 'use RT::Test; 1') {
+        diag $@;
+        plan skip_all => 'requires 3.7 or newer to run tests.';
+    }
+}
+
+BEGIN {
+    require File::Temp;
+    $ENV{'PROPHET_REPO'} = $ENV{'SD_REPO'} = File::Temp::tempdir( CLEANUP => 0 ) . '/_svb';
+    diag "export SD_REPO=".$ENV{'PROPHET_REPO'} ."\n";
+}
+
+use Prophet::Test tests => 2;
+use App::SD::Test;
+use RT::Client::REST;
+use RT::Client::REST::Ticket;
+
+RT::Handle->InsertData( $RT::EtcPath . '/initialdata' );
+
+my ( $url, $m ) = RT::Test->started_ok;
+
+my $user = RT::Test->load_or_create_user(
+    Name     => 'alice',
+    Password => 'AlicesPassword',
+);
+
+my $root = RT::Client::REST->new( server => $url );
+$root->login( username => 'root', password => 'password' );
+
+my $ticket = RT::Client::REST::Ticket->new(
+    rt      => $root,
+    queue   => 'General',
+    status  => 'new',
+    subject => 'Fly Man',
+)->store( text => "Ticket Comment" );
+
+my $root_url = $url;
+$root_url =~ s|http://|http://root:password@|;
+my $sd_root_url = "rt:$root_url|General|Status!='resolved'";
+
+my $alice_url = $url;
+$alice_url =~ s|http://|http://alice:AlicesPassword@|;
+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.",
+        ],
+    );
+};
+



More information about the Bps-public-commit mailing list