[Rt-commit] rtir branch, 4.0/correspondents-from-makeclicky, created. 4.0.1rc1-89-gd5f3bd2d

Brian Duggan brian at bestpractical.com
Fri Jun 8 18:26:30 EDT 2018


The branch, 4.0/correspondents-from-makeclicky has been created
        at  d5f3bd2d7d38ae3ee877a75fc6751eca099ea12e (commit)

- Log -----------------------------------------------------------------
commit e1d3b6a78942910e8ab56600d0a2e240c7538b15
Author: Brian C. Duggan <brian at bestpractical.com>
Date:   Mon Jun 4 15:05:19 2018 -0400

    Test Correspondents field on 'Investigate to' investigation creation
    
    MakeClicky 'Investigate to' links should load a queue selection page
    for investigation creation.
    
    That queue selection page form should lead to an investigation
    creation page.
    
    The Correspondents field on that investigation creation page should be
    populated with the MakeClicky 'Investigate to' email address.
    
    This change tests all four RTIR ticket types. It also adds tests the
    'Investigate to' link workflow. It removes testing the
    'foo-bar+baz at example.me' email address because this workflow does not
    currently properly URI-escape Requestors args.

diff --git a/t/015-make-clicky.t b/t/015-make-clicky.t
index c064fa95..5a4bb41c 100644
--- a/t/015-make-clicky.t
+++ b/t/015-make-clicky.t
@@ -19,10 +19,10 @@ diag "clicky ip" if $ENV{'TEST_VERBOSE'};
     my @links = $agent->followable_links;
     if ( $clicky{'ip'} ) {
         my ($lookup_link) = grep lc($_->text||'') eq 'lookup ip', @links;
-        ok($lookup_link, "found link");
-        ok($lookup_link->url =~ /(?<!\d)1\.0\.0\.0(?!\d)/, 'url has an ip' );
+        ok($lookup_link, "Found link for IP address");
+        ok($lookup_link->url =~ /(?<!\d)1\.0\.0\.0(?!\d)/, 'Found IP address in URL' );
     } else {
-        ok(!grep( lc $_->text eq 'lookup ip', @links ), "not found link");
+        ok(!grep( lc $_->text eq 'lookup ip', @links ), "Didn't find link for IP address");
     }
 
     $id = $agent->create_ir( { Subject => 'clicky ip', Content => '255.255.255.255' } );
@@ -30,85 +30,139 @@ diag "clicky ip" if $ENV{'TEST_VERBOSE'};
     @links = $agent->followable_links;
     if ( $clicky{'ip'} ) {
         my ($lookup_link) = grep lc($_->text||'') eq 'lookup ip', @links;
-        ok($lookup_link, "found link");
-        ok($lookup_link->url =~ /(?<!\d)255\.255\.255\.255(?!\d)/, 'url has an ip' );
+        ok($lookup_link, "Found link for IP address");
+        ok($lookup_link->url =~ /(?<!\d)255\.255\.255\.255(?!\d)/, 'Found IP address in URL' );
     } else {
-        ok(!grep( lc $_->text eq 'lookup ip', @links ), "not found link");
+        ok(!grep( lc $_->text eq 'lookup ip', @links ), "Didn't find link for IP address");
     }
 
     $id = $agent->create_ir( { Subject => 'clicky ip', Content => '255.255.255.256' } );
     $agent->display_ticket( $id);
     @links = $agent->followable_links;
-    ok(!grep( lc($_->text||'') eq 'lookup ip', @links ), "not found link");
+    ok(!grep( lc($_->text||'') eq 'lookup ip', @links ), "Didn't find link for IP address");
 
     $id = $agent->create_ir( { Subject => 'clicky ip', Content => '355.255.255.255' } );
     $agent->display_ticket( $id);
     @links = $agent->followable_links;
-    ok(!grep( lc($_->text||'') eq 'lookup ip', @links ), "not found link");
+    ok(!grep( lc($_->text||'') eq 'lookup ip', @links ), "Didn't find link for IP address");
 }
 
 diag "clicky email" if $ENV{'TEST_VERBOSE'};
 {
 
-    for my $email (
-        'foo at example.com',  'foo-bar+baz at example.me',
-        'foo at example.mobi', 'foo at localhost.localhost',
+    for my $create_method_ref (
+        sub { $agent->create_ir( $_[0] ) },
+        sub { $agent->create_incident( $_[0] ) },
+        sub { $agent->create_investigation( $_[0] ) },
+        sub {
+            $_[0]{Incident} = $agent->create_incident(@_);
+            $agent->create_countermeasure( $_[0] );
+        },
       )
     {
-        diag "test valid email $email" if $ENV{TEST_VERBOSE};
-        my ( $name, $domain ) = split /@/, $email, 2;
-        my $id =
-          $agent->create_ir( { Subject => 'clicky email', Content => $email } );
-        $agent->display_ticket($id);
-        my $email_link = $agent->find_link( url_regex => qr/\Qq=$email\E/, text_regex => qr/\Qlookup email\E$/ );
-        my $domain_link = $agent->find_link( text_regex => qr/^\Qlookup "$domain"\E$/i );
-        $agent->save_content('/tmp/x.html');
-        if ( $clicky{'email'} ) {
-            ok( $email_link,                                   "found link $email_link" );
-            ok( $email_link->url =~ /(?<!\w)\Qq=$email\E(?!\w)/, 'url '.$email_link->url.' has an email - '.$email );
-            ok( $domain_link,                                    "found link" );
-            ok( $domain_link->url =~ /(?<!\w)\Q$domain\E(?!\w)/, 'url has a domain' );
-        }
-        else {
-            ok( !$email_link, "not found email link" );
-            ok( !$domain_link, "not found domain link" );
-        }
-
-    }
-
-    for my $email ( 'foo at example') {
-        diag "test invalid email (invalid domain) $email" if $ENV{TEST_VERBOSE};
+        for my $email (
+            'foo at example.com',
+            'foo at example.mobi', 'foo at localhost.localhost',
+            )
+        {
+            diag "test valid email $email" if $ENV{TEST_VERBOSE};
+            my ( $name, $domain ) = split /@/, $email, 2;
+
+            my $id =
+              $create_method_ref->( { Subject => 'clicky email', Content => $email } );
+            $agent->display_ticket($id);
+
+            my $is_incident = $agent->text() =~ qr/Queue: Incidents/;
+
+            my $email_link = $agent->find_link( url_regex => qr/\Qq=$email\E/, text_regex => qr/\Qlookup email\E$/ );
+            my $domain_link = $agent->find_link( text_regex => qr/^\Qlookup "$domain"\E$/i );
+
+            my $investigate_link = $agent->find_link( url_regex => qr/\QRequestors=$email\E/,
+                                                   text_regex => qr/^\Qinvestigate to\E$/i ) if $is_incident;
+
+            $agent->save_content('/tmp/x.html');
+            if ( $clicky{'email'} ) {
+                ok( $email_link,                                   "Found link for $email_link" );
+                ok( $email_link->url =~ /(?<!\w)\Qq=$email\E(?!\w)/, 'URL link '.$email_link->url.' has an email address: '.$email );
+                ok( $domain_link,                                    "Found link for URL domain" );
+                ok( $domain_link->url =~ /(?<!\w)\Q$domain\E(?!\w)/, 'URL link has a domain' );
+
+                # Test that 'Investigate to' links go to the queue selection page for creating incidents.
+                # Then test that the new investigation form on that page loads the investigation creation page.
+                # Then test taht the Correspondents field is populated with the given email address.
+                if ( $is_incident ) {
+                    ok( $investigate_link, "found investigate link" );
+                    ok( $investigate_link->url =~ /(?<!\w)\QRequestors=$email\E(?!\w)/,
+                        'url '.$investigate_link->url.' has Requestors email' );
+                    $agent->follow_link_ok( { url => $investigate_link->url }, 'followed "investigate to" link' );
+                    $agent->title_is( 'Select Queue for New Investigation',
+                                      'selecting queue for new investigation' );
+                    $agent->submit_form_ok(
+                        {
+                            form_id => 'CreateInQueue',
+                        },
+                        'submitted new investigation form',
+                    );
+                    $agent->title_is( 'Launch a new investigation', 'launching a new investigation' );
+                    $agent->form_name( 'TicketCreate' );
+                    my @correspondents = $agent->find_all_inputs(
+                        name => 'Requestors',
+                        type => 'text',
+                        value => $email,
+                    );
+                    ok($correspondents[0], 'Found an email address');
+                    is($correspondents[0]->value, $email, 'Email is correct: ' . $correspondents[0]->value);
+                }
+            }
+            else {
+                ok( !$email_link, "Didn't find link for email address" );
+                ok( !$domain_link, "Didn't find link for domain" );
+                ok( !$investigate_link, "Didn't find 'Investigate to' link") if $is_incident;
+            }
 
-        my ( $name, $domain );
-        if ($email =~ /^(.*)@(.*)$/) {
-            ($name,$domain) = ($1,$2);
         }
-        my $id = $agent->create_ir( { Subject => 'clicky email', Content => $email } );
-        $agent->display_ticket($id);
-        my $email_link = $agent->find_link( url_regex => qr/\Qq=$email\E/, text_regex => qr/\Qlookup email\E$/ );
-        ok( !$email_link, "not found email link for $email" );
-        my $domain_link = $agent->find_link( text_regex => qr/^\Qlookup "$domain"\E$/i );
-        ok( !$domain_link, "not found domain link for $domain" );
 
-    }
-
-
-    for my $email ( '@example.com' ) {
-        diag "test invalid email (no local part) $email" if $ENV{TEST_VERBOSE};
+        for my $email ( 'foo at example') {
+            diag "test invalid email (invalid domain) $email" if $ENV{TEST_VERBOSE};
+
+            my ( $name, $domain );
+            if ($email =~ /^(.*)@(.*)$/) {
+                ($name,$domain) = ($1,$2);
+            }
+            my $id = $create_method_ref->( { Subject => 'clicky email', Content => $email } );
+            $agent->display_ticket($id);
+            my $is_incident = $agent->text() =~ qr/Queue: Incidents/;
+            my $email_link = $agent->find_link( url_regex => qr/\Qq=$email\E/, text_regex => qr/\Qlookup email\E$/ );
+            ok( !$email_link, "Didn't find an email link for $email" );
+            my $domain_link = $agent->find_link( text_regex => qr/^\Qlookup "$domain"\E$/i );
+            ok( !$domain_link, "Didn't find a domain link for $domain" );
+
+            my $investigate_link = $agent->find_link( url_regex => qr/\QRequestors=$email\E/,
+                                                      text_regex => qr/^\Qinvestigate to\E$/i )
+                if $is_incident;
+            ok( !$investigate_link, "Didn't find 'Investigate to' link for $email" );
+        }
 
-        my ( $name, $domain );
-        if ($email =~ /^(.*)@(.*)$/) {
-            ($name,$domain) = ($1,$2);
+        for my $email ( '@example.com' ) {
+            diag "test invalid email (no local part) $email" if $ENV{TEST_VERBOSE};
+
+            my ( $name, $domain );
+            if ($email =~ /^(.*)@(.*)$/) {
+                ($name,$domain) = ($1,$2);
+            }
+            my $id = $create_method_ref->( { Subject => 'clicky email', Content => $email } );
+            $agent->display_ticket($id);
+            my $is_incident = $agent->text() =~ qr/Queue: Incidents/;
+            my $email_link = $agent->find_link( url_regex => qr/\Qq=$email\E/, text_regex => qr/\Qlookup email\E$/ );
+            ok( !$email_link, "Didn't find link for $email" );
+            my $domain_link = $agent->find_link( text_regex => qr/^\Qlookup "$domain"\E$/i );
+            ok( $domain_link, "Found the bare domain for $domain" );
+            my $investigate_link = $agent->find_link( url_regex => qr/\QRequestors=$email\E/,
+                                                      text_regex => qr/^\Qinvestigate to\E$/i )
+                if $is_incident;
+            ok( !$investigate_link, "Didn't find 'Investigate to' link for $email" );
         }
-        my $id = $agent->create_ir( { Subject => 'clicky email', Content => $email } );
-        $agent->display_ticket($id);
-        my $email_link = $agent->find_link( url_regex => qr/\Qq=$email\E/, text_regex => qr/\Qlookup email\E$/ );
-        ok( !$email_link, "not found email link for $email" );
-        my $domain_link = $agent->find_link( text_regex => qr/^\Qlookup "$domain"\E$/i );
-        ok( $domain_link, "still found the bare domain for $domain" );
     }
-
-
 }
 
 diag "utf8 caching " if $ENV{'TEST_VERBOSE'};

commit b8a6415d858e5c2239b4083ed2c9799168815799
Author: Brian C. Duggan <brian at bestpractical.com>
Date:   Mon May 21 15:59:59 2018 -0400

    Pass Requestors through queue selection modal if provided
    
    ebe8874d introduced the new queue selection modal which requires some
    values intended for the create page to be written as hidden fields so
    they are passed on when submitted.
    
    This change adds Requestors to support the Investigate to
    link. Previously the "Investigate to" email addresses were being lost
    on the queue modal and not appearing in the Correspondents field.

diff --git a/html/RTIR/Elements/CreateInRTIRQueueModal b/html/RTIR/Elements/CreateInRTIRQueueModal
index f0e643a0..d4128b0c 100644
--- a/html/RTIR/Elements/CreateInRTIRQueueModal
+++ b/html/RTIR/Elements/CreateInRTIRQueueModal
@@ -51,6 +51,9 @@
 % }
 % if ($Child) {
 <input type="hidden" name="Child" value="<%$Child%>"/>
+% }
+% if ($Requestors) {
+<input type="hidden" name="Requestors" value="<%$Requestors%>"/>
 % }
   <&|/l_unsafe, $ticket_type,
       $m->scomp('/RTIR/Elements/SelectRTIRQueue',
@@ -95,5 +98,6 @@ my $ticket_type = lc RT::IR::TicketType( Lifecycle => $Lifecycle );
 $Lifecycle
 $Incident => undef
 $Child => undef
+$Requestors => undef
 </%ARGS>
 

commit 515c14ed40307c0a3c1824f0548a2103287ea27f
Author: Brian C. Duggan <brian at bestpractical.com>
Date:   Thu May 24 16:07:34 2018 -0400

    Test emails with +tags for 'Investigate to' MakeClicky links
    
    The MakeClicky tests do not test links for mails with +tags.
    
    This change re-adds testing 'foo-bar+baz at example.me' so that we can
    test a fix for emails with special characters.

diff --git a/t/015-make-clicky.t b/t/015-make-clicky.t
index 5a4bb41c..f657e713 100644
--- a/t/015-make-clicky.t
+++ b/t/015-make-clicky.t
@@ -61,12 +61,14 @@ diag "clicky email" if $ENV{'TEST_VERBOSE'};
       )
     {
         for my $email (
-            'foo at example.com',
+            'foo at example.com',  'foo-bar+baz at example.me',
             'foo at example.mobi', 'foo at localhost.localhost',
             )
         {
             diag "test valid email $email" if $ENV{TEST_VERBOSE};
             my ( $name, $domain ) = split /@/, $email, 2;
+            my $uri_escaped_email = $email;
+            RT::Interface::Web::EscapeURI(\$uri_escaped_email);
 
             my $id =
               $create_method_ref->( { Subject => 'clicky email', Content => $email } );
@@ -77,7 +79,7 @@ diag "clicky email" if $ENV{'TEST_VERBOSE'};
             my $email_link = $agent->find_link( url_regex => qr/\Qq=$email\E/, text_regex => qr/\Qlookup email\E$/ );
             my $domain_link = $agent->find_link( text_regex => qr/^\Qlookup "$domain"\E$/i );
 
-            my $investigate_link = $agent->find_link( url_regex => qr/\QRequestors=$email\E/,
+            my $investigate_link = $agent->find_link( url_regex => qr/\QRequestors=$uri_escaped_email\E/,
                                                    text_regex => qr/^\Qinvestigate to\E$/i ) if $is_incident;
 
             $agent->save_content('/tmp/x.html');
@@ -92,7 +94,7 @@ diag "clicky email" if $ENV{'TEST_VERBOSE'};
                 # Then test taht the Correspondents field is populated with the given email address.
                 if ( $is_incident ) {
                     ok( $investigate_link, "found investigate link" );
-                    ok( $investigate_link->url =~ /(?<!\w)\QRequestors=$email\E(?!\w)/,
+                    ok( $investigate_link->url =~ /(?<!\w)\QRequestors=$uri_escaped_email\E(?!\w)/,
                         'url '.$investigate_link->url.' has Requestors email' );
                     $agent->follow_link_ok( { url => $investigate_link->url }, 'followed "investigate to" link' );
                     $agent->title_is( 'Select Queue for New Investigation',

commit d5f3bd2d7d38ae3ee877a75fc6751eca099ea12e
Author: Brian C. Duggan <brian at bestpractical.com>
Date:   Fri Jun 8 18:09:31 2018 -0400

    Handle emails with +tags in 'Investigate to' MakeClicky links
    
    Email addresses with +tags were not URI-escaped in the RTIR MakeClicky
    callback for 'Investigate to' links. Then, the CreateInRTIRQueueModal
    would URI-unescape the Requestors GET parameter, replacing + with a
    sapce in the hidden input field. The modal passed that incorrect value
    to the RTIR investigation creation page.
    
    This change URI-escapes the email address in the RTIR MakeClicky
    callback before inserting in to the 'InvestigateTo' link. That allows
    the modal to unescape it to a correct value, and pass the correct
    value to the investigation creation page.

diff --git a/html/Callbacks/RTIR/Elements/MakeClicky/Default b/html/Callbacks/RTIR/Elements/MakeClicky/Default
index 15cabafd..e9e7b890 100644
--- a/html/Callbacks/RTIR/Elements/MakeClicky/Default
+++ b/html/Callbacks/RTIR/Elements/MakeClicky/Default
@@ -158,6 +158,8 @@ my %actions;
             RT::IR->HREFTo(qq{Tools/Lookup.html?$args{'lookup_params'}type=email&q=$escaped_email}). qq{">}
             .loc('lookup email') .q{</a>};
         if ( $args{'incident'} ) {
+	    my $uri_escaped_email = $escaped_email;
+	    RT::Interface::Web::EscapeURI(\$uri_escaped_email);
             if ( $r->uri =~ /Lookup.html$/ ) {
                 $result .= qq{<input type="checkbox" name="Requestorbox-$escaped_email" unchecked />};
             }
@@ -165,7 +167,7 @@ my %actions;
                 RT::IR->HREFTo( "CreateInQueue.html"
                 . qq{?Incident=$args{'incident'}}
                 . qq{&Lifecycle=}.RT::IR->lifecycle_investigation
-                . "&Requestors=$escaped_email")
+                . "&Requestors=$uri_escaped_email")
                 . qq{">}
                 . loc('Investigate to') .qq{</a>};
         }

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


More information about the rt-commit mailing list