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,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,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
Copied: trunk/opsview-web/t/tests/Test/Opsview/Web/REST/Sharednotificationprofiles.pm (from rev 12806, branches/enterprise/DEV-professional/opsview-web/t/tests/Test/Opsview/Web/REST/Sharednotificationprofiles.pm)
===================================================================
--- trunk/opsview-web/t/tests/Test/Opsview/Web/REST/Sharednotificationprofiles.pm (rev 0)
+++ trunk/opsview-web/t/tests/Test/Opsview/Web/REST/Sharednotificationprofiles.pm 2013-08-15 19:29:58 UTC (rev 13291)
@@ -0,0 +1,717 @@
+package Test::Opsview::Web::REST::Sharednotificationprofiles;
+
+use strict;
+use warnings;
+use FindBin '$Bin';
+use HTTP::Request::Common qw( GET PUT DELETE POST );
+use Test::Deep 'cmp_deeply';
+use Test::More tests => 15;
+
+use lib '/usr/local/opsview-web/t/tests';
+use base 'Test::Opsview::Web::REST';
+
+my $path = '/rest/config/sharednotificationprofile';
+
+sub tenancy : Tests {
+
+ my $self = shift;
+ my $mech = $self->mech_rest;
+ my $json = $self->{json};
+
+ subtest 'tenant_creates' => sub {
+
+ $self->mech_rest_api_login( 'customeraops', 'customeraops' );
+ $mech->request(
+ POST(
+ $path, Content => q|{
+ "all_hostgroups" : "0",
+ "all_keywords" : "0",
+ "all_servicegroups" : "0",
+ "host_notification_options" : "n",
+ "hostgroups" : [],
+ "keywords" : [],
+ "name" : "CustomerA tenant SNP",
+ "notification_level" : "1",
+ "notification_level_stop" : "0",
+ "notification_period" : {
+ "name" : "24x7",
+ },
+ "notificationmethods" : [],
+ "role" : {
+ "name" : "CustomerA",
+ },
+ "service_notification_options" : "n",
+ "servicegroups" : [],
+ }|
+ )
+ );
+ is( $mech->status, 403 );
+
+ };
+
+ subtest 'primary_creates' => sub {
+
+ $self->mech_rest_api_login( 'customeraadmin', 'customeraadmin' );
+ $mech->request(
+ POST(
+ $path, Content => q|{
+ "all_hostgroups" : "0",
+ "all_keywords" : "0",
+ "all_servicegroups" : "0",
+ "host_notification_options" : "n",
+ "hostgroups" : [],
+ "keywords" : [],
+ "name" : "CustomerA tenant SNP",
+ "notification_level" : "1",
+ "notification_level_stop" : "0",
+ "notification_period" : {
+ "name" : "24x7",
+ },
+ "notificationmethods" : [],
+ "role" : {
+ "name" : "CustomerA",
+ },
+ "service_notification_options" : "n",
+ "servicegroups" : [],
+ }|
+ )
+ );
+ my $got = eval { $json->decode( $mech->content ) };
+ die "Bad JSON: $@" if $@;
+ cmp_deeply(
+ $got,
+ {
+ object => {
+ 'all_hostgroups' => '0',
+ 'all_keywords' => '0',
+ 'all_servicegroups' => '0',
+ 'host_notification_options' => 'n',
+ 'hostgroups' => [],
+ 'id' => '8',
+ 'keywords' => [],
+ 'name' => 'CustomerA tenant SNP',
+ 'notification_level' => '1',
+ 'notification_level_stop' => '0',
+ 'notification_period' => {
+ 'name' => '24x7',
+ 'ref' => '/rest/config/timeperiod/1'
+ },
+ 'notificationmethods' => [],
+ 'role' => {
+ 'name' => 'CustomerA',
+ 'ref' => '/rest/config/role/22'
+ },
+ 'service_notification_options' => 'n',
+ 'servicegroups' => [],
+ 'uncommitted' => '1'
+ }
+ }
+ );
+ };
+
+ subtest 'primary_changes' => sub {
+
+ $self->mech_rest_api_login( 'customeraadmin', 'customeraadmin' );
+ $mech->request(
+ PUT(
+ "$path/8", Content => q|{
+ "all_hostgroups" : "0",
+ "all_keywords" : "0",
+ "all_servicegroups" : "0",
+ "host_notification_options" : "n",
+ "hostgroups" : [],
+ "keywords" : [],
+ "name" : "CustomerA primary tenant SNP",
+ "notification_level" : "1",
+ "notification_level_stop" : "0",
+ "notification_period" : {
+ "name" : "24x7",
+ },
+ "notificationmethods" : [],
+ "role" : {
+ "name" : "CustomerA",
+ },
+ "service_notification_options" : "n",
+ "servicegroups" : [],
+ }|
+ )
+ );
+ my $got = eval { $json->decode( $mech->content ) };
+ die "Bad JSON: $@" if $@;
+ cmp_deeply(
+ $got,
+ {
+ object => {
+ 'all_hostgroups' => '0',
+ 'all_keywords' => '0',
+ 'all_servicegroups' => '0',
+ 'host_notification_options' => 'n',
+ 'hostgroups' => [],
+ 'id' => '8',
+ 'keywords' => [],
+ 'name' => 'CustomerA primary tenant SNP',
+ 'notification_level' => '1',
+ 'notification_level_stop' => '0',
+ 'notification_period' => {
+ 'name' => '24x7',
+ 'ref' => '/rest/config/timeperiod/1'
+ },
+ 'notificationmethods' => [],
+ 'role' => {
+ 'name' => 'CustomerA',
+ 'ref' => '/rest/config/role/22'
+ },
+ 'service_notification_options' => 'n',
+ 'servicegroups' => [],
+ 'uncommitted' => '1'
+ }
+ }
+ );
+ };
+
+ subtest 'tenant_changes' => sub {
+
+ $self->mech_rest_api_login( 'customeraops', 'customeraops' );
+ $mech->request(
+ PUT(
+ "$path/8", Content => q|{
+ "all_hostgroups" : "0",
+ "all_keywords" : "0",
+ "all_servicegroups" : "0",
+ "host_notification_options" : "n",
+ "hostgroups" : [],
+ "keywords" : [],
+ "name" : "CustomerA tenant SNP",
+ "notification_level" : "1",
+ "notification_level_stop" : "0",
+ "notification_period" : {
+ "name" : "24x7",
+ },
+ "notificationmethods" : [],
+ "role" : {
+ "name" : "CustomerA",
+ },
+ "service_notification_options" : "n",
+ "servicegroups" : [],
+ }|
+ )
+ );
+ is( $mech->status, 404 );
+
+ };
+
+ subtest 'admin_creates' => sub {
+
+ $self->mech_rest_api_login( 'admin', 'initial' );
+ $mech->request(
+ PUT(
+ $path, Content => q|{
+ "all_hostgroups" : "0",
+ "all_keywords" : "0",
+ "all_servicegroups" : "0",
+ "host_notification_options" : "n",
+ "hostgroups" : [],
+ "keywords" : [],
+ "name" : "CustomerA tenant SNP blah",
+ "notification_level" : "1",
+ "notification_level_stop" : "0",
+ "notification_period" : {
+ "name" : "24x7",
+ },
+ "notificationmethods" : [],
+ "role" : {
+ "name" : "CustomerA operator",
+ },
+ "service_notification_options" : "n",
+ "servicegroups" : [],
+ }|
+ )
+ );
+ my $got = eval { $json->decode( $mech->content ) };
+ die "Bad JSON: $@" if $@;
+ cmp_deeply(
+ $got,
+ {
+ object => {
+ 'all_hostgroups' => '0',
+ 'all_keywords' => '0',
+ 'all_servicegroups' => '0',
+ 'host_notification_options' => 'n',
+ 'hostgroups' => [],
+ 'id' => '9',
+ 'keywords' => [],
+ 'name' => 'CustomerA tenant SNP blah',
+ 'notification_level' => '1',
+ 'notification_level_stop' => '0',
+ 'notification_period' => {
+ 'name' => '24x7',
+ 'ref' => '/rest/config/timeperiod/1'
+ },
+ 'notificationmethods' => [],
+ 'role' => {
+ 'name' => 'CustomerA operator',
+ 'ref' => '/rest/config/role/23'
+ },
+ 'service_notification_options' => 'n',
+ 'servicegroups' => [],
+ 'uncommitted' => '1'
+ }
+ }
+ );
+ };
+
+ subtest 'admin_changes' => sub {
+
+ $self->mech_rest_api_login( 'admin', 'initial' );
+ $mech->request(
+ PUT(
+ "$path/9", Content => q|{
+ "all_hostgroups" : "0",
+ "all_keywords" : "0",
+ "all_servicegroups" : "0",
+ "host_notification_options" : "n",
+ "hostgroups" : [],
+ "keywords" : [],
+ "name" : "CustomerA tenant SNP",
+ "notification_level" : "1",
+ "notification_level_stop" : "0",
+ "notification_period" : {
+ "name" : "24x7",
+ },
+ "notificationmethods" : [],
+ "role" : {
+ "name" : "CustomerA operator",
+ },
+ "service_notification_options" : "n",
+ "servicegroups" : [],
+ }|
+ )
+ );
+ my $got = eval { $json->decode( $mech->content ) };
+ die "Bad JSON: $@" if $@;
+ cmp_deeply(
+ $got,
+ {
+ object => {
+ 'all_hostgroups' => '0',
+ 'all_keywords' => '0',
+ 'all_servicegroups' => '0',
+ 'host_notification_options' => 'n',
+ 'hostgroups' => [],
+ 'id' => '9',
+ 'keywords' => [],
+ 'name' => 'CustomerA tenant SNP',
+ 'notification_level' => '1',
+ 'notification_level_stop' => '0',
+ 'notification_period' => {
+ 'name' => '24x7',
+ 'ref' => '/rest/config/timeperiod/1'
+ },
+ 'notificationmethods' => [],
+ 'role' => {
+ 'name' => 'CustomerA operator',
+ 'ref' => '/rest/config/role/23'
+ },
+ 'service_notification_options' => 'n',
+ 'servicegroups' => [],
+ 'uncommitted' => '1'
+ }
+ }
+ );
+ };
+
+ subtest 'admin_lists' => sub {
+ $self->mech_rest_api_login( 'admin', 'initial' );
+ $mech->get_ok($path);
+ my $got = eval { $json->decode( $mech->content ) };
+ die "Bad JSON: $@" if $@;
+ cmp_deeply(
+ $got,
+ {
+ 'list' => [
+ {
+ 'all_hostgroups' => '1',
+ 'all_keywords' => '1',
+ 'all_servicegroups' => '1',
+ 'host_notification_options' => 'u,d,r,f',
+ 'hostgroups' => [],
+ 'id' => '1',
+ 'keywords' => [],
+ 'name' => 'Admin role profile 1',
+ 'notification_level' => '1',
+ 'notification_level_stop' => '4',
+ 'notification_period' => {
+ 'name' => '24x7',
+ 'ref' => '/rest/config/timeperiod/1'
+ },
+ 'notificationmethods' => [],
+ 'ref' => '/rest/config/sharednotificationprofile/1',
+ 'role' => {
+ 'name' => 'Admin',
+ 'ref' => '/rest/config/role/10'
+ },
+ 'service_notification_options' => 'w,c,r,u,f',
+ 'servicegroups' => [],
+ 'uncommitted' => '0'
+ },
+ {
+ 'all_hostgroups' => '1',
+ 'all_keywords' => '1',
+ 'all_servicegroups' => '1',
+ 'host_notification_options' => 'u,d,r,f',
+ 'hostgroups' => [],
+ 'id' => '2',
+ 'keywords' => [],
+ 'name' => 'Admin role profile 2',
+ 'notification_level' => '1',
+ 'notification_level_stop' => '5',
+ 'notification_period' => {
+ 'name' => '24x7',
+ 'ref' => '/rest/config/timeperiod/1'
+ },
+ 'notificationmethods' => [],
+ 'ref' => '/rest/config/sharednotificationprofile/2',
+ 'role' => {
+ 'name' => 'Admin',
+ 'ref' => '/rest/config/role/10'
+ },
+ 'service_notification_options' => 'w,c,r,u,f',
+ 'servicegroups' => [],
+ 'uncommitted' => '0'
+ },
+ {
+ 'all_hostgroups' => '0',
+ 'all_keywords' => '0',
+ 'all_servicegroups' => '0',
+ 'host_notification_options' => 'n',
+ 'hostgroups' => [],
+ 'id' => '8',
+ 'keywords' => [],
+ 'name' => 'CustomerA primary tenant SNP',
+ 'notification_level' => '1',
+ 'notification_level_stop' => '0',
+ 'notification_period' => {
+ 'name' => '24x7',
+ 'ref' => '/rest/config/timeperiod/1'
+ },
+ 'notificationmethods' => [],
+ 'ref' => '/rest/config/sharednotificationprofile/8',
+ 'role' => {
+ 'name' => 'CustomerA',
+ 'ref' => '/rest/config/role/22'
+ },
+ 'service_notification_options' => 'n',
+ 'servicegroups' => [],
+ 'uncommitted' => '1'
+ },
+ {
+ 'all_hostgroups' => '0',
+ 'all_keywords' => '0',
+ 'all_servicegroups' => '0',
+ 'host_notification_options' => 'n',
+ 'hostgroups' => [],
+ 'id' => '9',
+ 'keywords' => [],
+ 'name' => 'CustomerA tenant SNP',
+ 'notification_level' => '1',
+ 'notification_level_stop' => '0',
+ 'notification_period' => {
+ 'name' => '24x7',
+ 'ref' => '/rest/config/timeperiod/1'
+ },
+ 'notificationmethods' => [],
+ 'ref' => '/rest/config/sharednotificationprofile/9',
+ 'role' => {
+ 'name' => 'CustomerA operator',
+ 'ref' => '/rest/config/role/23'
+ },
+ 'service_notification_options' => 'n',
+ 'servicegroups' => [],
+ 'uncommitted' => '1'
+ },
+ {
+ 'all_hostgroups' => '1',
+ 'all_keywords' => '1',
+ 'all_servicegroups' => '1',
+ 'host_notification_options' => 'u,d,r,f',
+ 'hostgroups' => [],
+ 'id' => '3',
+ 'keywords' => [],
+ 'name' => 'demorole profile 1',
+ 'notification_level' => '1',
+ 'notification_level_stop' => '0',
+ 'notification_period' => {
+ 'name' => '24x7',
+ 'ref' => '/rest/config/timeperiod/1'
+ },
+ 'notificationmethods' => [],
+ 'ref' => '/rest/config/sharednotificationprofile/3',
+ 'role' => {
+ 'name' => 'demorole',
+ 'ref' => '/rest/config/role/17'
+ },
+ 'service_notification_options' => 'w,c,r,u,f',
+ 'servicegroups' => [],
+ 'uncommitted' => '0'
+ },
+ {
+ 'all_hostgroups' => '1',
+ 'all_keywords' => '1',
+ 'all_servicegroups' => '1',
+ 'host_notification_options' => 'u,d,r,f',
+ 'hostgroups' => [],
+ 'id' => '4',
+ 'keywords' => [],
+ 'name' => 'demorole profile 2',
+ 'notification_level' => '1',
+ 'notification_level_stop' => '0',
+ 'notification_period' => {
+ 'name' => '24x7',
+ 'ref' => '/rest/config/timeperiod/1'
+ },
+ 'notificationmethods' => [],
+ 'ref' => '/rest/config/sharednotificationprofile/4',
+ 'role' => {
+ 'name' => 'demorole',
+ 'ref' => '/rest/config/role/17'
+ },
+ 'service_notification_options' => 'w,c,r,u,f',
+ 'servicegroups' => [],
+ 'uncommitted' => '0'
+ },
+ {
+ 'all_hostgroups' => '1',
+ 'all_keywords' => '1',
+ 'all_servicegroups' => '1',
+ 'host_notification_options' => 'u,d,r,f',
+ 'hostgroups' => [],
+ 'id' => '5',
+ 'keywords' => [],
+ 'name' => 'View some change some profile 1',
+ 'notification_level' => '1',
+ 'notification_level_stop' => '0',
+ 'notification_period' => {
+ 'name' => '24x7',
+ 'ref' => '/rest/config/timeperiod/1'
+ },
+ 'notificationmethods' => [],
+ 'ref' => '/rest/config/sharednotificationprofile/5',
+ 'role' => {
+ 'name' => 'View some, change some',
+ 'ref' => '/rest/config/role/12'
+ },
+ 'service_notification_options' => 'w,c,r,u,f',
+ 'servicegroups' => [],
+ 'uncommitted' => '0'
+ },
+ {
+ 'all_hostgroups' => '0',
+ 'all_keywords' => '0',
+ 'all_servicegroups' => '0',
+ 'host_notification_options' => 'u,d,r,f',
+ 'hostgroups' => [
+ {
+ 'name' => 'alphaearly',
+ 'ref' => '/rest/config/hostgroup/9'
+ },
+ {
+ 'name' => 'Leaf',
+ 'ref' => '/rest/config/hostgroup/4'
+ }
+ ],
+ 'id' => '6',
+ 'keywords' => [],
+ 'name' => 'View some change some profile 2',
+ 'notification_level' => '1',
+ 'notification_level_stop' => '0',
+ 'notification_period' => {
+ 'name' => '24x7',
+ 'ref' => '/rest/config/timeperiod/1'
+ },
+ 'notificationmethods' => [],
+ 'ref' => '/rest/config/sharednotificationprofile/6',
+ 'role' => {
+ 'name' => 'View some, change some',
+ 'ref' => '/rest/config/role/12'
+ },
+ 'service_notification_options' => 'w,c,r,u,f',
+ 'servicegroups' => [
+ {
+ 'name' => 'Operations',
+ 'ref' => '/rest/config/servicegroup/1'
+ }
+ ],
+ 'uncommitted' => '0'
+ },
+ {
+ 'all_hostgroups' => '1',
+ 'all_keywords' => '1',
+ 'all_servicegroups' => '1',
+ 'host_notification_options' => 'u,d,r,f',
+ 'hostgroups' => [],
+ 'id' => '7',
+ 'keywords' => [],
+ 'name' => 'View some change some profile 3',
+ 'notification_level' => '1',
+ 'notification_level_stop' => '0',
+ 'notification_period' => {
+ 'name' => '24x7',
+ 'ref' => '/rest/config/timeperiod/1'
+ },
+ 'notificationmethods' => [],
+ 'ref' => '/rest/config/sharednotificationprofile/7',
+ 'role' => {
+ 'name' => 'View some, change some',
+ 'ref' => '/rest/config/role/12'
+ },
+ 'service_notification_options' => 'w,c,r,u,f',
+ 'servicegroups' => [],
+ 'uncommitted' => '0'
+ }
+ ],
+ 'summary' => {
+ 'allrows' => '9',
+ 'page' => '1',
+ 'rows' => '9',
+ 'totalpages' => '1',
+ 'totalrows' => '9'
+ }
+
+ }
+ );
+ };
+
+ subtest 'primary_lists' => sub {
+ $self->mech_rest_api_login( 'customeraadmin', 'customeraadmin' );
+ $mech->get_ok($path);
+ my $got = eval { $json->decode( $mech->content ) };
+ die "Bad JSON: $@" if $@;
+ cmp_deeply(
+ $got,
+ {
+ "list" => [
+ {
+ "all_hostgroups" => "0",
+ "all_keywords" => "0",
+ "all_servicegroups" => "0",
+ "host_notification_options" => "n",
+ "hostgroups" => [],
+ "id" => "8",
+ "keywords" => [],
+ "name" => "CustomerA primary tenant SNP",
+ "notification_level" => "1",
+ "notification_level_stop" => "0",
+ "notification_period" => {
+ "name" => "24x7",
+ "ref" => "/rest/config/timeperiod/1"
+ },
+ "notificationmethods" => [],
+ "ref" => "/rest/config/sharednotificationprofile/8",
+ "role" => {
+ "name" => "CustomerA",
+ "ref" => "/rest/config/role/22"
+ },
+ "service_notification_options" => "n",
+ "servicegroups" => [],
+ "uncommitted" => "1"
+ },
+ {
+ "all_hostgroups" => "0",
+ "all_keywords" => "0",
+ "all_servicegroups" => "0",
+ "host_notification_options" => "n",
+ "hostgroups" => [],
+ "id" => "9",
+ "keywords" => [],
+ "name" => "CustomerA tenant SNP",
+ "notification_level" => "1",
+ "notification_level_stop" => "0",
+ "notification_period" => {
+ "name" => "24x7",
+ "ref" => "/rest/config/timeperiod/1"
+ },
+ "notificationmethods" => [],
+ "ref" => "/rest/config/sharednotificationprofile/9",
+ "role" => {
+ "name" => "CustomerA operator",
+ "ref" => "/rest/config/role/23"
+ },
+ "service_notification_options" => "n",
+ "servicegroups" => [],
+ "uncommitted" => "1"
+ }
+ ],
+ "summary" => {
+ "allrows" => "2",
+ "page" => "1",
+ "rows" => "2",
+ "totalpages" => "1",
+ "totalrows" => "2"
+ }
+ }
+ );
+ };
+
+ subtest 'tenant_lists' => sub {
+ $self->mech_rest_api_login( 'customeraops', 'customeraops' );
+ $mech->get_ok($path);
+ my $got = eval { $json->decode( $mech->content ) };
+ die "Bad JSON: $@" if $@;
+ cmp_deeply(
+ $got,
+ {
+ "list" => [
+ {
+ "all_hostgroups" => "0",
+ "all_keywords" => "0",
+ "all_servicegroups" => "0",
+ "host_notification_options" => "n",
+ "hostgroups" => [],
+ "id" => "9",
+ "keywords" => [],
+ "name" => "CustomerA tenant SNP",
+ "notification_level" => "1",
+ "notification_level_stop" => "0",
+ "notification_period" => {
+ "name" => "24x7",
+ "ref" => "/rest/config/timeperiod/1"
+ },
+ "notificationmethods" => [],
+ "ref" => "/rest/config/sharednotificationprofile/9",
+ "role" => {
+ "name" => "CustomerA operator",
+ "ref" => "/rest/config/role/23"
+ },
+ "service_notification_options" => "n",
+ "servicegroups" => [],
+ "uncommitted" => "1"
+ }
+ ],
+ "summary" => {
+ "allrows" => "1",
+ "page" => "1",
+ "rows" => "1",
+ "totalpages" => "1",
+ "totalrows" => "1"
+ }
+ }
+ );
+ };
+
+ # Can't delete because the role doesn't have CONFIGURESAVE.
+ subtest 'tenant_deletes' => sub {
+ $self->mech_rest_api_login( 'customeraops', 'customeraops' );
+ $mech->get( "$path/delete/9" );
+ is( $mech->status, 404 );
+ };
+
+ # Can't delete because the role doesn't have CONFIGURESAVE.
+ subtest 'primary_deletes' => sub {
+ $self->mech_rest_api_login( 'customeraadmin', 'customeraadmin' );
+ $mech->get( "$path/delete/8" );
+ is( $mech->status, 404 );
+ };
+
+}
+
+1;