[Rt-commit] r5983 - in rtir/branches/2.1-EXPERIMENTAL: . html/RTIR
html/RTIR/Incident/Elements
ruz at bestpractical.com
ruz at bestpractical.com
Mon Sep 18 18:58:49 EDT 2006
Author: ruz
Date: Mon Sep 18 18:58:45 2006
New Revision: 5983
Added:
rtir/branches/2.1-EXPERIMENTAL/t/013-custom-field-ip.t
Modified:
rtir/branches/2.1-EXPERIMENTAL/ (props changed)
rtir/branches/2.1-EXPERIMENTAL/html/RTIR/Create.html
rtir/branches/2.1-EXPERIMENTAL/html/RTIR/Incident/Elements/Create
Log:
r1574 at cubic-pc: cubic | 2006-09-19 03:05:36 +0400
IP searching
* fix web IPs access interfaces
* add tests
Modified: rtir/branches/2.1-EXPERIMENTAL/html/RTIR/Create.html
==============================================================================
--- rtir/branches/2.1-EXPERIMENTAL/html/RTIR/Create.html (original)
+++ rtir/branches/2.1-EXPERIMENTAL/html/RTIR/Create.html Mon Sep 18 18:58:45 2006
@@ -188,16 +188,6 @@
</tr>
% } elsif ($Type eq "Block") {
<tr>
- <td class="label"><%loc("IP address")%>:</td>
- <td class="value" colspan="2">
- <& /RTIR/Elements/EditRTIRField,
- TicketObj => $TicketObj,
- QueueObj => $QueueObj,
- Name => 'IP',
- Default => $ARGS{'IP-Value'} || RT->Config->Get('_RTIR_IP_default'), &>
- </td>
- </tr>
- <tr>
<td class="label"><%loc("Netmask")%>:</td>
<td class="value" colspan="2">
<& /RTIR/Elements/EditRTIRField,
@@ -235,6 +225,16 @@
</tr>
% }
<tr>
+ <td class="label"><%loc("IP address")%>:</td>
+ <td class="value" colspan="2">
+ <& /RTIR/Elements/EditRTIRField,
+ TicketObj => $TicketObj,
+ QueueObj => $QueueObj,
+ Name => 'IP',
+ Default => $ARGS{'IP-Value'} || RT->Config->Get('_RTIR_IP_default'), &>
+ </td>
+ </tr>
+ <tr>
<td colspan="3">
<& /Ticket/Elements/EditCustomFields,
TicketObj => $TicketObj,
Modified: rtir/branches/2.1-EXPERIMENTAL/html/RTIR/Incident/Elements/Create
==============================================================================
--- rtir/branches/2.1-EXPERIMENTAL/html/RTIR/Incident/Elements/Create (original)
+++ rtir/branches/2.1-EXPERIMENTAL/html/RTIR/Incident/Elements/Create Mon Sep 18 18:58:45 2006
@@ -72,6 +72,14 @@
Rows => 1,
&></td></tr>
+<tr><td class="label"><&|/l&>IP</&>:</td>
+<td class="value">
+<& /RTIR/Elements/EditRTIRField,
+ QueueObj => $QueueObj,
+ Name => 'IP',
+ Cols => 40,
+&></td></tr>
+
<tr><td colspan="2">
<& /Ticket/Elements/EditCustomFields,
TicketObj => $TicketObj,
Added: rtir/branches/2.1-EXPERIMENTAL/t/013-custom-field-ip.t
==============================================================================
--- (empty file)
+++ rtir/branches/2.1-EXPERIMENTAL/t/013-custom-field-ip.t Mon Sep 18 18:58:45 2006
@@ -0,0 +1,130 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use Test::More tests => 134;
+
+require "t/rtir-test.pl";
+
+use_ok('RT');
+RT::LoadConfig();
+RT::Init();
+
+use_ok('RT::IR');
+
+my $cf;
+diag "load and check basic properties of the IP CF" if $ENV{'TEST_VERBOSE'};
+{
+ my $cfs = RT::CustomFields->new( $RT::SystemUser );
+ $cfs->Limit( FIELD => 'Name', VALUE => '_RTIR_IP' );
+ is( $cfs->Count, 1, "found one CF with name '_RTIR_IP'" );
+
+ $cf = $cfs->First;
+ is( $cf->Type, 'Freeform', 'type check' );
+ is( $cf->LookupType, 'RT::Queue-RT::Ticket', 'lookup type check' );
+ ok( !$cf->MaxValues, "unlimited number of values" );
+ ok( !$cf->Disabled, "not disabled" );
+}
+
+diag "check that CF applies to all RTIR's queues" if $ENV{'TEST_VERBOSE'};
+{
+ foreach ( 'Incidents', 'Incident Reports', 'Investigations', 'Blocks' ) {
+ my $queue = RT::Queue->new( $RT::SystemUser );
+ $queue->Load( $_ );
+ ok( $queue->id, 'loaded queue '. $_ );
+ my $cfs = $queue->TicketCustomFields;
+ $cfs->Limit( FIELD => 'id', VALUE => $cf->id, ENTRYAGGREGATOR => 'AND' );
+ is( $cfs->Count, 1, 'field applies to queue' );
+ }
+}
+
+my $agent = default_agent();
+my $rtir_user = rtir_user();
+
+diag "create a ticket via web and set IP" if $ENV{'TEST_VERBOSE'};
+{
+ my $i = 0;
+ my $incident_id; # block couldn't be created without incident id
+ foreach my $queue( 'Incidents', 'Incident Reports', 'Investigations', 'Blocks' ) {
+ diag "create a ticket in the '$queue' queue" if $ENV{'TEST_VERBOSE'};
+
+ my $val = '192.168.20.'. ++$i;
+ my $id = create_rtir_ticket(
+ $agent, $queue,
+ {
+ Subject => "test ip",
+ ($queue eq 'Blocks'? (Incident => $incident_id): ()),
+ },
+ { IP => $val },
+ );
+ $incident_id = $id if $queue eq 'Incidents';
+
+ display_ticket($agent, $id);
+ $agent->content_like( qr/\Q$val/, "IP on the page" );
+
+ my $ticket = RT::Ticket->new( $RT::SystemUser );
+ $ticket->Load( $id );
+ ok( $ticket->id, 'loaded ticket' );
+ is( $ticket->FirstCustomFieldValue('_RTIR_IP'), $val, 'correct value' );
+ }
+}
+
+diag "create a ticket via web with IP in message" if $ENV{'TEST_VERBOSE'};
+{
+ my $i = 0;
+ my $incident_id; # block couldn't be created without incident id
+ foreach my $queue( 'Incidents', 'Incident Reports', 'Investigations', 'Blocks' ) {
+ diag "create a ticket in the '$queue' queue" if $ENV{'TEST_VERBOSE'};
+
+ my $val = '192.168.20.'. ++$i;
+ my $id = create_rtir_ticket(
+ $agent, $queue,
+ {
+ Subject => "test ip in message",
+ ($queue eq 'Blocks'? (Incident => $incident_id): ()),
+ Content => "$val",
+ },
+ );
+ $incident_id = $id if $queue eq 'Incidents';
+
+ display_ticket($agent, $id);
+ $agent->content_like( qr/\Q$val/, "IP on the page" );
+
+ my $ticket = RT::Ticket->new( $RT::SystemUser );
+ $ticket->Load( $id );
+ ok( $ticket->id, 'loaded ticket' );
+ is( $ticket->FirstCustomFieldValue('_RTIR_IP'), $val, 'correct value' );
+ }
+}
+
+diag "create a ticket via web with CIDR in message" if $ENV{'TEST_VERBOSE'};
+{
+ my $i = 0;
+ my $incident_id; # block couldn't be created without incident id
+ foreach my $queue( 'Incidents', 'Incident Reports', 'Investigations', 'Blocks' ) {
+ diag "create a ticket in the '$queue' queue" if $ENV{'TEST_VERBOSE'};
+
+ my $val = '172.16.'. ++$i .'/31'; # add two hosts
+ my $id = create_rtir_ticket(
+ $agent, $queue,
+ {
+ Subject => "test ip in message",
+ ($queue eq 'Blocks'? (Incident => $incident_id): ()),
+ Content => "$val",
+ },
+ );
+ $incident_id = $id if $queue eq 'Incidents';
+
+ display_ticket($agent, $id);
+ $agent->content_like( qr/172\.16\.$i\.1/, "IP on the page" );
+ $agent->content_like( qr/172\.16\.$i\.2/, "IP on the page" );
+
+ my $ticket = RT::Ticket->new( $RT::SystemUser );
+ $ticket->Load( $id );
+ ok( $ticket->id, 'loaded ticket' );
+ my $values = $ticket->CustomFieldValues('_RTIR_IP');
+ my %has = map { $_->Content => 1 } @{ $values->ItemsArrayRef };
+ ok( $has{ "172.16.$i.1" }, "has value" ) or diag "but has values ". join ", ", keys %has;
+ ok( $has{ "172.16.$i.2" }, "has value" ) or diag "but has values ". join ", ", keys %has;
+ }
+}
More information about the Rt-commit
mailing list