Title: [opsview] [5327] Fixed bug in REST API when searching by id
Revision
5327
Author
tvoon
Date
2010-11-07 23:37:15 +0000 (Sun, 07 Nov 2010)

Log Message

Fixed bug in REST API when searching by id

Modified Paths


Modified: trunk/CHANGES
===================================================================
--- trunk/CHANGES	2010-11-07 22:24:42 UTC (rev 5326)
+++ trunk/CHANGES	2010-11-07 23:37:15 UTC (rev 5327)
@@ -87,6 +87,7 @@
     Fixed visual glitch of background image on forms with a long amount of data
     Fixed 2 small Nagios CGI bugs
     Fixed italics and bold text formatting in host comments
+    Fixed bug in REST API when searching by id
 
 
 3.9.0 28th September 2010

Modified: trunk/opsview-web/lib/Opsview/Web/ControllerBase/Config.pm
===================================================================
--- trunk/opsview-web/lib/Opsview/Web/ControllerBase/Config.pm	2010-11-07 22:24:42 UTC (rev 5326)
+++ trunk/opsview-web/lib/Opsview/Web/ControllerBase/Config.pm	2010-11-07 23:37:15 UTC (rev 5327)
@@ -90,6 +90,9 @@
 
     my $rs = $c->stash->{resultset};
 
+    # Need to override search column of id, because can be ambiguous
+    $c->req->params->{"s.me.id"} = delete $c->req->params->{"s.id"} if exists $c->req->params->{"s.id"};
+
     # Implement search based on parameters
     my %allowed_cols  = map { ( $_ => 1 ) } @{ $rs->result_class->allowed_columns };
     my $params        = $c->req->params;

Modified: trunk/opsview-web/t/650-api2-host.t
===================================================================
--- trunk/opsview-web/t/650-api2-host.t	2010-11-07 22:24:42 UTC (rev 5326)
+++ trunk/opsview-web/t/650-api2-host.t	2010-11-07 23:37:15 UTC (rev 5327)
@@ -267,6 +267,12 @@
 is( $ua->status, 404, "No object - deleted!" );
 $ua->content_contains( "No object found with id=17", "Got error message" );
 
+# Search by id
+$ua->get("http://localhost/rest/config/host?s.id=17");
+is( $ua->status, 200, "List returns..." );
+$res_data = eval $ua->content;
+is( $res_data->{summary}->{rows}, 0, "No rows" );
+
 # Need to set Content-Type otherwise WWW::Mechanize will assume post sends form data
 $ua->add_header( 'Content-type' => "text/x-data-dumper" );
 my $creation = {

_______________________________________________
Opsview-checkins mailing list
[email protected]
http://lists.opsview.org/lists/listinfo/opsview-checkins

Reply via email to