[Bps-public-commit] rt-extension-rest2 branch, master, updated. 746bb0c6308d4d016209e8eb0689a90b347a25fc

Jim Brandt jbrandt at bestpractical.com
Tue Aug 29 17:03:16 EDT 2017


The branch, master has been updated
       via  746bb0c6308d4d016209e8eb0689a90b347a25fc (commit)
       via  05cbcdad28105adcbe5cea1ed2a5fd992cff833f (commit)
      from  9c622a81a8d27e598116ec8233964cc083bb21e9 (commit)

Summary of changes:
 lib/RT/Extension/REST2/Util.pm |  7 ++++++-
 t/organization.t               | 39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+), 1 deletion(-)
 create mode 100644 t/organization.t

- Log -----------------------------------------------------------------
commit 05cbcdad28105adcbe5cea1ed2a5fd992cff833f
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Tue Aug 29 16:59:22 2017 -0400

    Test showing incorrect id with Org containing dashes

diff --git a/t/organization.t b/t/organization.t
new file mode 100644
index 0000000..a9fb831
--- /dev/null
+++ b/t/organization.t
@@ -0,0 +1,39 @@
+use strict;
+use warnings;
+use lib 't/lib';
+use RT::Extension::REST2::Test tests => undef;
+
+RT->Config->Set('Organization', 'name-with-dashes');
+
+my $mech = RT::Extension::REST2::Test->mech;
+my $auth = RT::Extension::REST2::Test->authorization_header;
+my $rest_base_path = '/REST/2.0';
+my $user = RT::Extension::REST2::Test->user;
+
+$user->PrincipalObj->GrantRight( Right => 'SuperUser' );
+
+my $queue_url;
+# search Name = General
+{
+    my $res = $mech->post_json("$rest_base_path/queues",
+        [{ field => 'Name', value => 'General' }],
+        'Authorization' => $auth,
+    );
+    is($res->code, 200);
+
+    my $content = $mech->json_response;
+    is($content->{count}, 1);
+    is($content->{page}, 1);
+    is($content->{per_page}, 20);
+    is($content->{total}, 1);
+    is(scalar @{$content->{items}}, 1);
+
+    my $queue = $content->{items}->[0];
+    is($queue->{type}, 'queue');
+    is($queue->{id}, 1);
+    like($queue->{_url}, qr{$rest_base_path/queue/1$});
+    $queue_url = $queue->{_url};
+}
+
+done_testing;
+

commit 746bb0c6308d4d016209e8eb0689a90b347a25fc
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Tue Aug 29 16:59:56 2017 -0400

    Parse Organization using the configured value
    
    Use the configured Organization value for more accurate
    parsing of uid, specifically to correctly parse Organizations
    containing dashes. See RT ed007dae for similar handling.

diff --git a/lib/RT/Extension/REST2/Util.pm b/lib/RT/Extension/REST2/Util.pm
index 8989500..143472b 100644
--- a/lib/RT/Extension/REST2/Util.pm
+++ b/lib/RT/Extension/REST2/Util.pm
@@ -33,7 +33,12 @@ sub expand_uid {
 
     return if not defined $uid;
 
-    my ($class, $rtname, $id) = $uid =~ /^([^-]+?)(?:-(.+?))?-(.+)$/;
+    my $Organization = RT->Config->Get('Organization');
+    my ($class, $id);
+    if ($uid =~ /^([\w:]+)-\Q$Organization\E-(.+)$/) {
+        ($class, $id) = ($1, $2);
+    }
+
     return unless $class and $id;
 
     $class =~ s/^RT:://;

-----------------------------------------------------------------------


More information about the Bps-public-commit mailing list