Property changes on: trunk
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/DEV-capside/release-3.9.0:6365-6370
/branches/DEV-extra-notification-data:6734-6746
/branches/DEV-odw-calculations:9016-9160
/branches/DEV-restapi-monitoringservers:9778
/branches/DEV-snmp-multi:7324-7376
/branches/US187:9403-9479
/branches/US198b:8875-8994
/branches/US310:9851-9873
/branches/US539:12178-12182
/branches/enterprise/BRAN-3.14:6874,6882,6956
/branches/enterprise/DEV-professional:6494-8475,8477-8478,8486,8490,8492,8494,8499-8500,8515,8518-8519,8524,8527-8529,8531-8532,8536,8538,8540-8544,8547-8552,8554,8557,8600-8601,8637,8749,8772,8897,8917,8944-8945,8947,8950-8952,8967,8969,8979,8982,8987,8998,9006,9008,9011,9013,9026,9033-9036,9038,9040,9042,9044,9048,9050-9053,9062,9064-9065,9069,9078,9081,9088,9096,9099-9101,9103,9105,9115,9118,9347,9353-9354,9411,9432,9445,9486,9538-9550,9569-9571,9620,9635,9637-9638,9645-9647,9693,9699,9721,9814,9825,9857,9879,9881,9939,10002,10029,10038-10041,10070,10086,10093,10345,10347,10388,10407,10481,10549,10560-10562,10565,10568,10571,10577,10622,10932,11025,11035,11360-11612,11798-11799,11920,12075-12076,12096,12189,12207,12232,12266,12288,12322,12334,12355,12372,12401-12406,12428,12491,12523,12539-12540,12544,12546,12555,12580,12583,12599-12600,12609,12611,12614-12615,12618,12624,12630-12631,12633,12643,12645-12646,12649,12653-12654,12657-12658,12660,12662-12663,12666,12668,12678-
12679,12681-12682,12685,12687,12691-12693,12697,12703,12721,12724-12725,12731-12732,12737-12739,12741,12743-12744,12746,12750,12754-12756,12759,12764-12765,12770,12772-12776,12784,12787-12788,12795,12797,12799-12800,12806,12810,12814,12816-12817,12822-12823,12827,12833,12838,12841,12843-12846,12848,12851-12853,12856,12858,12860-12861,12863,12867,12876,12879-12880,12883-12884,12894,12900,12904,12907,12912,12914,12920-12922,12929,12931,12933-12934,12938-12940,12944,12954-12955,13126-13127,13211
/branches/nagvis-iframe:9764-9786
/branches/opsview2runtime:10960-11258
/branches/opsview2runtime_xs:11279-11303
/branches/us168:8759,8762-8763,8766-8768,8770,8774-8777,8794,8798-8799,8801-8803,8821-8822,8834,8837-8838,8932,8937,8947,8969,8977,8981,9004,9007,9009-9010,9012,9024,9049
/commercial/branches/BRAN-4.2:10944,11017
/commercial/branches/BRAN-4.3:12423-12426
/commercial/branches/US306-slaves:9804-9823
/commercial/branches/US307-network-map:9685-9837
+ /branches/DEV-capside/release-3.9.0:6365-6370
/branches/DEV-extra-notification-data:6734-6746
/branches/DEV-odw-calculations:9016-9160
/branches/DEV-restapi-monitoringservers:9778
/branches/DEV-snmp-multi:7324-7376
/branches/US187:9403-9479
/branches/US198b:8875-8994
/branches/US310:9851-9873
/branches/US539:12178-12182
/branches/enterprise/BRAN-3.14:6874,6882,6956
/branches/enterprise/DEV-professional:6494-8475,8477-8478,8486,8490,8492,8494,8499-8500,8515,8518-8519,8524,8527-8529,8531-8532,8536,8538,8540-8544,8547-8552,8554,8557,8600-8601,8637,8749,8772,8897,8917,8944-8945,8947,8950-8952,8967,8969,8979,8982,8987,8998,9006,9008,9011,9013,9026,9033-9036,9038,9040,9042,9044,9048,9050-9053,9062,9064-9065,9069,9078,9081,9088,9096,9099-9101,9103,9105,9115,9118,9347,9353-9354,9411,9432,9445,9486,9538-9550,9569-9571,9620,9635,9637-9638,9645-9647,9693,9699,9721,9814,9825,9857,9879,9881,9939,10002,10029,10038-10041,10070,10086,10093,10345,10347,10388,10407,10481,10549,10560-10562,10565,10568,10571,10577,10622,10932,11025,11035,11360-11612,11798-11799,11920,12075-12076,12096,12189,12207,12232,12266,12288,12322,12334,12355,12372,12401-12406,12428,12491,12523,12539-12540,12544,12546,12555,12580,12583,12599-12600,12609,12611,12614-12615,12618,12624,12630-12631,12633,12643,12645-12646,12649,12653-12654,12657-12658,12660,12662-12663,12666,12668,12678-
12679,12681-12682,12685,12687,12691-12693,12697,12703,12721,12724-12725,12731-12732,12737-12739,12741,12743-12744,12746,12750,12754-12756,12759,12764-12765,12770,12772-12776,12784,12787-12788,12795,12797,12799-12800,12806,12810,12814,12816-12817,12822-12823,12827,12833,12838,12841,12843-12846,12848,12851-12853,12856,12858,12860-12861,12863,12867,12876,12879-12880,12883-12884,12894,12900,12904,12907,12912,12914,12920-12922,12929,12931,12933-12934,12938-12940,12944,12954-12955,12958,13126-13127,13211
/branches/nagvis-iframe:9764-9786
/branches/opsview2runtime:10960-11258
/branches/opsview2runtime_xs:11279-11303
/branches/us168:8759,8762-8763,8766-8768,8770,8774-8777,8794,8798-8799,8801-8803,8821-8822,8834,8837-8838,8932,8937,8947,8969,8977,8981,9004,9007,9009-9010,9012,9024,9049
/commercial/branches/BRAN-4.2:10944,11017
/commercial/branches/BRAN-4.3:12423-12426
/commercial/branches/US306-slaves:9804-9823
/commercial/branches/US307-network-map:9685-9837
Modified: trunk/opsview-core/lib/Opsview/Schema/Hostgroups.pm
===================================================================
--- trunk/opsview-core/lib/Opsview/Schema/Hostgroups.pm 2013-08-15 20:51:06 UTC (rev 13316)
+++ trunk/opsview-core/lib/Opsview/Schema/Hostgroups.pm 2013-08-15 20:52:06 UTC (rev 13317)
@@ -253,6 +253,12 @@
}
}
+sub can_see_parent {
+ my ( $self, $user ) = @_;
+ return unless $user;
+ return $user->role->hostgroups->count( { id => $self->parentid } );
+}
+
# Copied from Opsview::Hostgroup
sub typeid {
my $self = shift;
Modified: trunk/opsview-web/lib/Opsview/Web/Controller/Admin/Hostgroup.pm
===================================================================
--- trunk/opsview-web/lib/Opsview/Web/Controller/Admin/Hostgroup.pm 2013-08-15 20:51:06 UTC (rev 13316)
+++ trunk/opsview-web/lib/Opsview/Web/Controller/Admin/Hostgroup.pm 2013-08-15 20:52:06 UTC (rev 13317)
@@ -234,11 +234,13 @@
sub remove : Local {
my ( $self, $c ) = @_;
$c->forward( "/admin/check_save_access" );
+
my $group = $c->stash->{list_rs}->find( $c->req->param("group") );
- # add in as an extra step to make sure group exists to delete, rather than
- # propagate error to UI when it doesnt
- if ($group) {
+ if ( $group and $group->can_see_parent( $c->user ) ) {
+
+ # add in as an extra step to make sure group exists to delete, rather
+ # than propagate error to UI when it doesnt
my $audit_text =
$c->translate( "messages.auditlog.hostgroup.deleteHostgroup [_1]",
$group->identity_string );
@@ -250,9 +252,11 @@
}
);
}
+
$c->stash( wrapper => "wrappers/blank" );
$c->forward( "graph" );
$c->stash( template => "graph_diagram" );
+
}
sub adopt : Local {
@@ -294,12 +298,18 @@
$c->stash( show_graph_options => 1 );
}
- $c->stash(
- count_hosts => $c->stash->{list_rs}->find($id)->count_related("hosts"),
- template => "menu",
- wrapper => "wrappers/menu"
- );
+ if ( my $group = $c->stash->{list_rs}->find($id) ) {
+ $c->stash(
+ count_hosts =>
+ $c->stash->{list_rs}->find($id)->count_related("hosts"),
+ template => "menu",
+ wrapper => "wrappers/menu",
+ hide_removal => $group->can_see_parent( $c->user ) ? 0 : 1,
+ );
+
+ }
+
}
__PACKAGE__->meta->make_immutable;
Modified: trunk/opsview-web/lib/Opsview/Web/Controller/REST/Config/Hostgroup.pm
===================================================================
--- trunk/opsview-web/lib/Opsview/Web/Controller/REST/Config/Hostgroup.pm 2013-08-15 20:51:06 UTC (rev 13316)
+++ trunk/opsview-web/lib/Opsview/Web/Controller/REST/Config/Hostgroup.pm 2013-08-15 20:52:06 UTC (rev 13317)
@@ -49,5 +49,25 @@
}
}
+around object_DELETE => sub {
+ my ( $orig, $self, $c, $id ) = @_;
+
+ if ( my $group = $c->model('OpsviewSchema::Hostgroups')->find($id) ) {
+ if ( $group->can_see_parent( $c->user ) ) {
+ $self->$orig( $c, $id );
+ }
+ else {
+ $c->res->status(400);
+ $c->error( "You cannot delete " . $group->name );
+ $c->detach;
+ }
+ }
+ else {
+ $c->res->status(404);
+ $c->detach;
+ }
+
+};
+
__PACKAGE__->meta->make_immutable;
1;
===================================================================
--- trunk/opsview-web/t/860menus.t 2013-08-15 20:51:06 UTC (rev 13316)
+++ trunk/opsview-web/t/860menus.t 2013-08-15 20:52:06 UTC (rev 13317)
@@ -486,6 +486,7 @@
);
$mech->content_contains( "Rename 'alphaearly'", "Got rename option" )
|| diag( $mech->content );
+$mech->content_contains( 'Remove group' );
# Need to go to graph first, because there is a referrer check for the menu
$mech->get_ok( "/admin/hostgroup/graph" );
@@ -496,6 +497,7 @@
$mech->content_contains( "Rename 'Monitoring Servers'",
"Got rename option for lights" )
|| diag( $mech->content );
+$mech->content_lacks( 'Remove group' );
# Check that host gets menu correctly when ACTIONSOME is set
# DB change!
Modified: trunk/opsview-web/t/tests/Test/Opsview/Web/REST/Hostgroups.pm
===================================================================
--- trunk/opsview-web/t/tests/Test/Opsview/Web/REST/Hostgroups.pm 2013-08-15 20:51:06 UTC (rev 13316)
+++ trunk/opsview-web/t/tests/Test/Opsview/Web/REST/Hostgroups.pm 2013-08-15 20:52:06 UTC (rev 13317)
@@ -42,6 +42,52 @@
$mech->request( DELETE("$path/3") );
is( $mech->status, 200, " but admin can" );
+ # Set up access for the next couple of tests.
+ $mech->request(
+ PUT(
+ '/rest/config/role/23', Content => q|
+ {
+ "accesses" : [
+ {
+ "name" : "CONFIGUREPROFILES",
+ "ref" : "/rest/config/access/23"
+ },
+ {
+ "name" : "CONFIGUREROLES",
+ "ref" : "/rest/config/access/27"
+ },
+ {
+ "name" : "TESTSOME",
+ "ref" : "/rest/config/access/22"
+ },
+ {
+ "name" : "VIEWSOME",
+ "ref" : "/rest/config/access/2"
+ },
+ {
+ "name" : "CONFIGUREHOSTGROUPS",
+ "ref" : "/rest/config/access/29"
+ },
+ {
+ "name" : "CONFIGURESAVE",
+ "ref" : "/rest/config/access/13"
+ }
+ ]
+ }|
+ )
+ );
+ is( $mech->status, 200,
+ "Have added CONFIGUREHOSTGROUPS and CONFIGURESAVE to customeraops"
+ );
+
+ $self->mech_rest_api_login( 'customeraops', 'customeraops' );
+ $mech->request( DELETE("$path/8") );
+ is( $mech->status, 200, "customeraops can remove middling" );
+
+ $self->mech_rest_api_login( 'customeraops', 'customeraops' );
+ $mech->request( DELETE("$path/6") );
+ is( $mech->status, 400, " but not UK2 (can't see parent group)" );
+
}
1;