diff options
Diffstat (limited to 'config-db/t')
-rw-r--r-- | config-db/t/01-basics.t | 6 | ||||
-rw-r--r-- | config-db/t/10-vendor-os.t | 166 | ||||
-rw-r--r-- | config-db/t/11-export.t | 160 | ||||
-rw-r--r-- | config-db/t/12-system.t | 304 | ||||
-rw-r--r-- | config-db/t/13-client.t | 298 | ||||
-rw-r--r-- | config-db/t/14-group.t | 282 | ||||
-rw-r--r-- | config-db/t/15-global_info.t | 18 | ||||
-rw-r--r-- | config-db/t/20-client_system_ref.t | 166 | ||||
-rw-r--r-- | config-db/t/21-group_system_ref.t | 154 | ||||
-rw-r--r-- | config-db/t/22-group_client_ref.t | 146 | ||||
-rw-r--r-- | config-db/t/25-attributes.t | 1044 | ||||
-rw-r--r-- | config-db/t/29-transaction.t | 2 | ||||
-rwxr-xr-x | config-db/t/run-all-tests.pl | 4 |
13 files changed, 1375 insertions, 1375 deletions
diff --git a/config-db/t/01-basics.t b/config-db/t/01-basics.t index 903783c4..1fb7083b 100644 --- a/config-db/t/01-basics.t +++ b/config-db/t/01-basics.t @@ -13,9 +13,9 @@ ok(my $configDB = OpenSLX::ConfigDB->new, 'can create object'); isa_ok($configDB, 'OpenSLX::ConfigDB'); { - # create a second object - should work and yield different objects - ok(my $configDB2 = OpenSLX::ConfigDB->new, 'can create another object'); - cmp_ok($configDB, 'ne', $configDB2, 'should have two different objects now'); + # create a second object - should work and yield different objects + ok(my $configDB2 = OpenSLX::ConfigDB->new, 'can create another object'); + cmp_ok($configDB, 'ne', $configDB2, 'should have two different objects now'); } ok($configDB->connect(), 'connecting'); diff --git a/config-db/t/10-vendor-os.t b/config-db/t/10-vendor-os.t index ac16becf..a71ee4ac 100644 --- a/config-db/t/10-vendor-os.t +++ b/config-db/t/10-vendor-os.t @@ -12,46 +12,46 @@ my $configDB = OpenSLX::ConfigDB->new; $configDB->connect(); is( - my $vendorOS = $configDB->fetchVendorOSByFilter, undef, - 'no vendor-OS yet (scalar context)' + my $vendorOS = $configDB->fetchVendorOSByFilter, undef, + 'no vendor-OS yet (scalar context)' ); my $wrongVendorOS = { - 'comment' => 'test', + 'comment' => 'test', }; ok( - ! eval { my $vendorOSID = $configDB->addVendorOS($wrongVendorOS); }, - 'trying to insert an unnamed vendor-OS should fail' + ! eval { my $vendorOSID = $configDB->addVendorOS($wrongVendorOS); }, + 'trying to insert an unnamed vendor-OS should fail' ); is( - my @vendorOSes = $configDB->fetchVendorOSByFilter, 0, - 'no vendor-OS yet (array context)' + my @vendorOSes = $configDB->fetchVendorOSByFilter, 0, + 'no vendor-OS yet (array context)' ); my $inVendorOS1 = { - 'name' => 'vos-1', - 'comment' => '', + 'name' => 'vos-1', + 'comment' => '', }; is( - my $vendorOS1ID = $configDB->addVendorOS($inVendorOS1), 1, - 'first vendor-OS has ID 1' + my $vendorOS1ID = $configDB->addVendorOS($inVendorOS1), 1, + 'first vendor-OS has ID 1' ); my $inVendorOS2 = { - 'name' => 'vos-2.0', - 'comment' => 'batch 2', + 'name' => 'vos-2.0', + 'comment' => 'batch 2', }; my $inVendorOS3 = { - 'name' => 'vos-3.0', - 'comment' => 'batch 2', - 'clone_source' => 'kiwi::test-vos', + 'name' => 'vos-3.0', + 'comment' => 'batch 2', + 'clone_source' => 'kiwi::test-vos', }; ok( - my ($vendorOS2ID, $vendorOS3ID) = $configDB->addVendorOS([ - $inVendorOS2, $inVendorOS3 - ]), - 'add two more vendor-OSes' + my ($vendorOS2ID, $vendorOS3ID) = $configDB->addVendorOS([ + $inVendorOS2, $inVendorOS3 + ]), + 'add two more vendor-OSes' ); is($vendorOS2ID, 2, 'vendor-OS 2 should have ID=2'); is($vendorOS3ID, 3, 'vendor-OS 3 should have ID=3'); @@ -65,8 +65,8 @@ is($vendorOS3->{clone_source}, 'kiwi::test-vos', 'vendor-OS 3 - clone_source'); # fetch vendor-OS 2 by a filter on id and check all values ok( - my $vendorOS2 = $configDB->fetchVendorOSByFilter({ id => 2 }), - 'fetch vendor-OS 2 by filter on id' + my $vendorOS2 = $configDB->fetchVendorOSByFilter({ id => 2 }), + 'fetch vendor-OS 2 by filter on id' ); is($vendorOS2->{id}, 2, 'vendor-OS 2 - id'); is($vendorOS2->{name}, 'vos-2.0', 'vendor-OS 2 - name'); @@ -75,8 +75,8 @@ is($vendorOS2->{clone_source}, undef, 'vendor-OS 2 - clone_source'); # fetch vendor-OS 1 by filter on name and check all values ok( - my $vendorOS1 = $configDB->fetchVendorOSByFilter({ name => 'vos-1' }), - 'fetch vendor-OS 1 by filter on name' + my $vendorOS1 = $configDB->fetchVendorOSByFilter({ name => 'vos-1' }), + 'fetch vendor-OS 1 by filter on name' ); is($vendorOS1->{id}, 1, 'vendor-OS 1 - id'); is($vendorOS1->{name}, 'vos-1', 'vendor-OS 1 - name'); @@ -85,9 +85,9 @@ is($vendorOS1->{clone_source}, undef, 'vendor-OS 1 - clone_source'); # fetch vendor-OSes 3 & 1 by id ok( - my @vendorOSes3And1 - = $configDB->fetchVendorOSByID([3, 1]), - 'fetch vendor-OSes 3 & 1 by id' + my @vendorOSes3And1 + = $configDB->fetchVendorOSByID([3, 1]), + 'fetch vendor-OSes 3 & 1 by id' ); is(@vendorOSes3And1, 2, 'should have got 2 vendor-OSes'); # now sort by ID and check if we have really got 3 and 1 @@ -97,22 +97,22 @@ is($vendorOSes3And1[1]->{id}, 3, 'second id should be 3'); # fetching vendor-OSes by id without giving any should yield undef is( - $configDB->fetchVendorOSByID(), undef, - 'fetch vendor-OSes by id without giving any' + $configDB->fetchVendorOSByID(), undef, + 'fetch vendor-OSes by id without giving any' ); # fetching vendor-OSes by filter without giving any should yield all of them ok( - @vendorOSes = $configDB->fetchVendorOSByFilter(), - 'fetch vendor-OSes by filter without giving any' + @vendorOSes = $configDB->fetchVendorOSByFilter(), + 'fetch vendor-OSes by filter without giving any' ); is(@vendorOSes, 3, 'should have got all three vendor-OSes'); # fetch vendor-OSes 2 & 3 by filter on comment ok( - my @vendorOSes2And3 - = $configDB->fetchVendorOSByFilter({ comment => 'batch 2' }), - 'fetch vendor-OSes 2 & 3 by filter on comment' + my @vendorOSes2And3 + = $configDB->fetchVendorOSByFilter({ comment => 'batch 2' }), + 'fetch vendor-OSes 2 & 3 by filter on comment' ); is(@vendorOSes2And3, 2, 'should have got 2 vendor-OSes'); # now sort by ID and check if we have really got 2 and 3 @@ -122,9 +122,9 @@ is($vendorOSes2And3[1]->{id}, 3, 'second id should be 3'); # try to fetch with multi-column filter ok( - ($vendorOS2, $vendorOS3) - = $configDB->fetchVendorOSByFilter({ comment => 'batch 2', id => 2 }), - 'fetching vendor-OS with comment="batch 2" and id=2 should work' + ($vendorOS2, $vendorOS3) + = $configDB->fetchVendorOSByFilter({ comment => 'batch 2', id => 2 }), + 'fetching vendor-OS with comment="batch 2" and id=2 should work' ); is($vendorOS2->{name}, 'vos-2.0', 'should have got vos-2.0'); is($vendorOS3, undef, 'should not get vos-3.0'); @@ -132,9 +132,9 @@ is($vendorOS3, undef, 'should not get vos-3.0'); # try to fetch multiple occurrences of the same vendor-OS, combined with # some unknown IDs ok( - my @vendorOSes1And3 - = $configDB->fetchVendorOSByID([ 1, 21, 4-1, 1, 0, 1, 1 ]), - 'fetch a complex set of vendor-OSes by ID' + my @vendorOSes1And3 + = $configDB->fetchVendorOSByID([ 1, 21, 4-1, 1, 0, 1, 1 ]), + 'fetch a complex set of vendor-OSes by ID' ); is(@vendorOSes1And3, 2, 'should have got 2 vendor-OSes'); # now sort by ID and check if we have really got 1 and 3 @@ -144,37 +144,37 @@ is($vendorOSes1And3[1]->{id}, 3, 'second id should be 3'); # try to fetch a couple of non-existing vendor-OSes by id is( - $configDB->fetchVendorOSByID(-1), undef, - 'vendor-OS with id -1 should not exist' + $configDB->fetchVendorOSByID(-1), undef, + 'vendor-OS with id -1 should not exist' ); is( - $configDB->fetchVendorOSByID(0), undef, - 'vendor-OS with id 0 should not exist' + $configDB->fetchVendorOSByID(0), undef, + 'vendor-OS with id 0 should not exist' ); is( - $configDB->fetchVendorOSByID(1 << 31 + 1000), undef, - 'trying to fetch another unknown vendor-OS' + $configDB->fetchVendorOSByID(1 << 31 + 1000), undef, + 'trying to fetch another unknown vendor-OS' ); # try to fetch a couple of non-existing vendor-OSes by filter is( - $configDB->fetchVendorOSByFilter({ id => 0 }), undef, - 'fetching vendor-OS with id=0 by filter should fail' + $configDB->fetchVendorOSByFilter({ id => 0 }), undef, + 'fetching vendor-OS with id=0 by filter should fail' ); is( - $configDB->fetchVendorOSByFilter({ name => 'vos-1.x' }), undef, - 'fetching vendor-OS with name="vos-1.x" should fail' + $configDB->fetchVendorOSByFilter({ name => 'vos-1.x' }), undef, + 'fetching vendor-OS with name="vos-1.x" should fail' ); is( - $configDB->fetchVendorOSByFilter({ comment => 'batch 2', id => 1 }), undef, - 'fetching vendor-OS with comment="batch 2" and id=1 should fail' + $configDB->fetchVendorOSByFilter({ comment => 'batch 2', id => 1 }), undef, + 'fetching vendor-OS with comment="batch 2" and id=1 should fail' ); # rename vendor-OS 1 and then fetch it by its new name ok($configDB->changeVendorOS(1, { name => q{VOS-'1'} }), 'changing vendor-OS 1'); ok( - $vendorOS1 = $configDB->fetchVendorOSByFilter({ name => q{VOS-'1'} }), - 'fetching renamed vendor-OS 1' + $vendorOS1 = $configDB->fetchVendorOSByFilter({ name => q{VOS-'1'} }), + 'fetching renamed vendor-OS 1' ); is($vendorOS1->{id}, 1, 'really got vendor-OS number 1'); is($vendorOS1->{name}, q{VOS-'1'}, q{really got vendor-OS named "VOS-'1'"}); @@ -184,68 +184,68 @@ ok($configDB->changeVendorOS(1), 'changing nothing at all in vendor-OS 1'); # changing a non-existing column should fail ok( - ! eval { $configDB->changeVendorOS(1, { xname => "xx" }) }, - 'changing unknown colum should fail' + ! eval { $configDB->changeVendorOS(1, { xname => "xx" }) }, + 'changing unknown colum should fail' ); ok(! $configDB->changeVendorOS(1, { id => 23 }), 'changing id should fail'); # test adding & removing of installed plugins is( - my @plugins = $configDB->fetchInstalledPlugins(3), - 0, 'there should be no installed plugins' + my @plugins = $configDB->fetchInstalledPlugins(3), + 0, 'there should be no installed plugins' ); ok($configDB->addInstalledPlugin(3, 'Example'), 'adding installed plugin'); is( - @plugins = $configDB->fetchInstalledPlugins(3), - 1, - 'should have 1 installed plugin' + @plugins = $configDB->fetchInstalledPlugins(3), + 1, + 'should have 1 installed plugin' ); is( - $configDB->addInstalledPlugin(3, 'Example'), 1, - 'adding plugin again should work (but do not harm, just update the attrs)' + $configDB->addInstalledPlugin(3, 'Example'), 1, + 'adding plugin again should work (but do not harm, just update the attrs)' ); is( - @plugins = $configDB->fetchInstalledPlugins(3), - 1, - 'should still have 1 installed plugin' + @plugins = $configDB->fetchInstalledPlugins(3), + 1, + 'should still have 1 installed plugin' ); is($plugins[0]->{plugin_name}, 'Example', 'should have got plugin "Example"'); ok($configDB->addInstalledPlugin(3, 'Test'), 'adding a second plugin'); is( - @plugins = $configDB->fetchInstalledPlugins(3), - 2, - 'should have 2 installed plugin' + @plugins = $configDB->fetchInstalledPlugins(3), + 2, + 'should have 2 installed plugin' ); ok( - !$configDB->removeInstalledPlugin(3, 'xxx'), - 'removing unknown plugin should fail' + !$configDB->removeInstalledPlugin(3, 'xxx'), + 'removing unknown plugin should fail' ); ok( - @plugins = $configDB->fetchInstalledPlugins(3, 'Example'), - 'fetching specific plugin' + @plugins = $configDB->fetchInstalledPlugins(3, 'Example'), + 'fetching specific plugin' ); is($plugins[0]->{plugin_name}, 'Example', 'should have got plugin "Example"'); ok( - @plugins = $configDB->fetchInstalledPlugins(3, 'Test'), - 'fetching another specific plugin' + @plugins = $configDB->fetchInstalledPlugins(3, 'Test'), + 'fetching another specific plugin' ); is($plugins[0]->{plugin_name}, 'Test', 'should have got plugin "Test"'); is( - @plugins = $configDB->fetchInstalledPlugins(3, 'xxx'), 0, - 'fetching unknown specific plugin' + @plugins = $configDB->fetchInstalledPlugins(3, 'xxx'), 0, + 'fetching unknown specific plugin' ); ok($configDB->removeInstalledPlugin(3, 'Example'), 'removing installed plugin'); is( - @plugins = $configDB->fetchInstalledPlugins(3), - 1, - 'should have 1 installed plugin' + @plugins = $configDB->fetchInstalledPlugins(3), + 1, + 'should have 1 installed plugin' ); ok($configDB->removeInstalledPlugin(3, 'Test'), 'removing second plugin'); is( - @plugins = $configDB->fetchInstalledPlugins(3), - 0, - 'should have no installed plugins' + @plugins = $configDB->fetchInstalledPlugins(3), + 0, + 'should have no installed plugins' ); # now remove a vendor-OS and check if that worked diff --git a/config-db/t/11-export.t b/config-db/t/11-export.t index 0cdc688c..3dd0ae6c 100644 --- a/config-db/t/11-export.t +++ b/config-db/t/11-export.t @@ -12,70 +12,70 @@ my $configDB = OpenSLX::ConfigDB->new; $configDB->connect(); is( - my $export = $configDB->fetchExportByFilter, undef, - 'no export yet (scalar context)' + my $export = $configDB->fetchExportByFilter, undef, + 'no export yet (scalar context)' ); foreach my $requiredCol (qw(name vendor_os_id type)) { - my $wrongExport = { - 'name' => 'name', - 'vendor_os_id' => 1, - 'type ' => 'nfs', - 'comment' => 'has column missing', - }; - delete $wrongExport->{$requiredCol}; - ok( - ! eval { my $exportID = $configDB->addExport($wrongExport); }, - "inserting an export without '$requiredCol' column should fail" - ); + my $wrongExport = { + 'name' => 'name', + 'vendor_os_id' => 1, + 'type ' => 'nfs', + 'comment' => 'has column missing', + }; + delete $wrongExport->{$requiredCol}; + ok( + ! eval { my $exportID = $configDB->addExport($wrongExport); }, + "inserting an export without '$requiredCol' column should fail" + ); } is( - my @exports = $configDB->fetchExportByFilter, 0, - 'no export yet (array context)' + my @exports = $configDB->fetchExportByFilter, 0, + 'no export yet (array context)' ); is( - my @exportIDs = $configDB->fetchExportIDsOfVendorOS(1), 0, - 'vendor-OS 1 has no export IDs yet' + my @exportIDs = $configDB->fetchExportIDsOfVendorOS(1), 0, + 'vendor-OS 1 has no export IDs yet' ); is( - @exportIDs = $configDB->fetchExportIDsOfVendorOS(2), 0, - 'vendor-OS 2 has no export IDs yet' + @exportIDs = $configDB->fetchExportIDsOfVendorOS(2), 0, + 'vendor-OS 2 has no export IDs yet' ); my $inExport1 = { - 'name' => 'exp-1', - 'type' => 'nfs', - 'vendor_os_id' => 1, - 'comment' => '', + 'name' => 'exp-1', + 'type' => 'nfs', + 'vendor_os_id' => 1, + 'comment' => '', }; is( - my $export1ID = $configDB->addExport($inExport1), 1, - 'first export has ID 1' + my $export1ID = $configDB->addExport($inExport1), 1, + 'first export has ID 1' ); my $inExport2 = { - 'name' => 'exp-2.0', - 'type' => 'sqfs-nbd', - 'vendor_os_id' => 1, - 'comment' => undef, + 'name' => 'exp-2.0', + 'type' => 'sqfs-nbd', + 'vendor_os_id' => 1, + 'comment' => undef, }; my $fullExport = { - 'name' => 'exp-nr-3', - 'type' => 'sqfs-nbd', - 'vendor_os_id' => 2, - 'comment' => 'nuff said', - 'server_ip' => '192.168.212.243', - 'port' => '65432', - 'uri' => 'sqfs-nbd://somehost/somepath?param=val&yes=1', + 'name' => 'exp-nr-3', + 'type' => 'sqfs-nbd', + 'vendor_os_id' => 2, + 'comment' => 'nuff said', + 'server_ip' => '192.168.212.243', + 'port' => '65432', + 'uri' => 'sqfs-nbd://somehost/somepath?param=val&yes=1', }; ok( - my ($export2ID, $export3ID) = $configDB->addExport([ - $inExport2, $fullExport - ]), - 'add two more exports' + my ($export2ID, $export3ID) = $configDB->addExport([ + $inExport2, $fullExport + ]), + 'add two more exports' ); is($export2ID, 2, 'export 2 should have ID=2'); is($export3ID, 3, 'export 3 should have ID=3'); @@ -90,15 +90,15 @@ is($export3->{comment}, 'nuff said', 'export 3 - comment'); is($export3->{server_ip}, '192.168.212.243', 'export 3 - server_ip'); is($export3->{port}, '65432', 'export 3 - port'); is( - $export3->{uri}, - 'sqfs-nbd://somehost/somepath?param=val&yes=1', - 'export 3 - uri' + $export3->{uri}, + 'sqfs-nbd://somehost/somepath?param=val&yes=1', + 'export 3 - uri' ); # fetch export 2 by a filter on id and check all values ok( - my $export2 = $configDB->fetchExportByFilter({ id => 2 }), - 'fetch export 2 by filter on id' + my $export2 = $configDB->fetchExportByFilter({ id => 2 }), + 'fetch export 2 by filter on id' ); is($export2->{id}, 2, 'export 2 - id'); is($export2->{name}, 'exp-2.0', 'export 2 - name'); @@ -108,8 +108,8 @@ is($export2->{comment}, undef, 'export 2 - comment'); # fetch export 1 by filter on name and check all values ok( - my $export1 = $configDB->fetchExportByFilter({ name => 'exp-1' }), - 'fetch export 1 by filter on name' + my $export1 = $configDB->fetchExportByFilter({ name => 'exp-1' }), + 'fetch export 1 by filter on name' ); is($export1->{id}, 1, 'export 1 - id'); is($export1->{name}, 'exp-1', 'export 1 - name'); @@ -121,22 +121,22 @@ is($export1->{server_ip}, undef, 'export 1 - server_ip'); is($export1->{uri}, undef, 'export 1 - uri'); is( - @exportIDs = sort( { $a <=> $b } $configDB->fetchExportIDsOfVendorOS(1)), - 2, 'vendor-OS 1 has two export IDs' + @exportIDs = sort( { $a <=> $b } $configDB->fetchExportIDsOfVendorOS(1)), + 2, 'vendor-OS 1 has two export IDs' ); is($exportIDs[0], 1, 'first export ID of vendor-OS 1 (1)'); is($exportIDs[1], 2, 'second export ID of vendor-OS 1 (2)'); is( - @exportIDs = sort( { $a <=> $b } $configDB->fetchExportIDsOfVendorOS(2)), - 1, 'vendor-OS 2 has one export IDs' + @exportIDs = sort( { $a <=> $b } $configDB->fetchExportIDsOfVendorOS(2)), + 1, 'vendor-OS 2 has one export IDs' ); is($exportIDs[0], 3, 'first export ID of vendor-OS 2 (3)'); # fetch exports 3 & 1 by id ok( - my @exports3And1 = $configDB->fetchExportByID([3, 1]), - 'fetch exports 3 & 1 by id' + my @exports3And1 = $configDB->fetchExportByID([3, 1]), + 'fetch exports 3 & 1 by id' ); is(@exports3And1, 2, 'should have got 2 exports'); # now sort by ID and check if we have really got 3 and 1 @@ -146,21 +146,21 @@ is($exports3And1[1]->{id}, 3, 'second id should be 3'); # fetching exports by id without giving any should yield undef is( - $configDB->fetchExportByID(), undef, - 'fetch exports by id without giving any' + $configDB->fetchExportByID(), undef, + 'fetch exports by id without giving any' ); # fetching exports by filter without giving any should yield all of them ok( - @exports = $configDB->fetchExportByFilter(), - 'fetch exports by filter without giving any' + @exports = $configDB->fetchExportByFilter(), + 'fetch exports by filter without giving any' ); is(@exports, 3, 'should have got all three exports'); # fetch exports 1 & 2 by filter on vendor_os_id ok( - my @exports1And2 = $configDB->fetchExportByFilter({ vendor_os_id => '1' }), - 'fetch exports 1 & 2 by filter on vendor_os_id' + my @exports1And2 = $configDB->fetchExportByFilter({ vendor_os_id => '1' }), + 'fetch exports 1 & 2 by filter on vendor_os_id' ); is(@exports1And2, 2, 'should have got 2 exports'); # now sort by ID and check if we have really got 1 and 2 @@ -170,9 +170,9 @@ is($exports1And2[1]->{id}, 2, 'second id should be 2'); # try to fetch with multi-column filter ok( - ($export2, $export3) - = $configDB->fetchExportByFilter({ vendor_os_id => '1', id => 2 }), - 'fetching export with vendor_os_id=1 and id=2 should work' + ($export2, $export3) + = $configDB->fetchExportByFilter({ vendor_os_id => '1', id => 2 }), + 'fetching export with vendor_os_id=1 and id=2 should work' ); is($export2->{name}, 'exp-2.0', 'should have got exp-2.0'); is($export3, undef, 'should not get exp-nr-3'); @@ -180,8 +180,8 @@ is($export3, undef, 'should not get exp-nr-3'); # try to fetch multiple occurrences of the same export, combined with # some unknown IDs ok( - my @exports1And3 = $configDB->fetchExportByID([ 1, 21, 4-1, 1, 0, 1, 1 ]), - 'fetch a complex set of exports by ID' + my @exports1And3 = $configDB->fetchExportByID([ 1, 21, 4-1, 1, 0, 1, 1 ]), + 'fetch a complex set of exports by ID' ); is(@exports1And3, 2, 'should have got 2 exports'); # now sort by ID and check if we have really got 1 and 3 @@ -191,37 +191,37 @@ is($exports1And3[1]->{id}, 3, 'second id should be 3'); # try to fetch a couple of non-existing exports by id is( - $configDB->fetchExportByID(-1), undef, - 'export with id -1 should not exist' + $configDB->fetchExportByID(-1), undef, + 'export with id -1 should not exist' ); is( - $configDB->fetchExportByID(0), undef, - 'export with id 0 should not exist' + $configDB->fetchExportByID(0), undef, + 'export with id 0 should not exist' ); is( - $configDB->fetchExportByID(1 << 31 + 1000), undef, - 'trying to fetch another unknown export' + $configDB->fetchExportByID(1 << 31 + 1000), undef, + 'trying to fetch another unknown export' ); # try to fetch a couple of non-existing exports by filter is( - $configDB->fetchExportByFilter({ id => 0 }), undef, - 'fetching export with id=0 by filter should fail' + $configDB->fetchExportByFilter({ id => 0 }), undef, + 'fetching export with id=0 by filter should fail' ); is( - $configDB->fetchExportByFilter({ name => 'exp-1.x' }), undef, - 'fetching export with name="exp-1.x" should fail' + $configDB->fetchExportByFilter({ name => 'exp-1.x' }), undef, + 'fetching export with name="exp-1.x" should fail' ); is( - $configDB->fetchExportByFilter({ vendor_os_id => '2', id => 1 }), undef, - 'fetching export with vendor_os_id=2 and id=1 should fail' + $configDB->fetchExportByFilter({ vendor_os_id => '2', id => 1 }), undef, + 'fetching export with vendor_os_id=2 and id=1 should fail' ); # rename export 1 and then fetch it by its new name ok($configDB->changeExport(1, { name => q{EXP-'1'} }), 'changing export 1'); ok( - $export1 = $configDB->fetchExportByFilter({ name => q{EXP-'1'} }), - 'fetching renamed export 1' + $export1 = $configDB->fetchExportByFilter({ name => q{EXP-'1'} }), + 'fetching renamed export 1' ); is($export1->{id}, 1, 'really got export number 1'); is($export1->{name}, q{EXP-'1'}, q{really got export named "EXP-'1'"}); @@ -231,8 +231,8 @@ ok($configDB->changeExport(1), 'changing nothing at all in export 1'); # changing a non-existing column should fail ok( - ! eval { $configDB->changeExport(1, { xname => "xx" }) }, - 'changing unknown colum should fail' + ! eval { $configDB->changeExport(1, { xname => "xx" }) }, + 'changing unknown colum should fail' ); ok(! $configDB->changeExport(1, { id => 23 }), 'changing id should fail'); diff --git a/config-db/t/12-system.t b/config-db/t/12-system.t index 17a0c0dd..7ed740a9 100644 --- a/config-db/t/12-system.t +++ b/config-db/t/12-system.t @@ -12,99 +12,99 @@ my $configDB = OpenSLX::ConfigDB->new; $configDB->connect(); ok( - my $system = $configDB->fetchSystemByFilter, - 'one system [default] should exist (scalar context)' + my $system = $configDB->fetchSystemByFilter, + 'one system [default] should exist (scalar context)' ); foreach my $requiredCol (qw(name export_id)) { - my $wrongSystem = { - 'name' => 'name', - 'export_id' => 1, - 'comment' => 'has column missing', - }; - delete $wrongSystem->{$requiredCol}; - ok( - ! eval { my $systemID = $configDB->addSystem($wrongSystem); }, - "inserting a system without '$requiredCol' column should fail" - ); + my $wrongSystem = { + 'name' => 'name', + 'export_id' => 1, + 'comment' => 'has column missing', + }; + delete $wrongSystem->{$requiredCol}; + ok( + ! eval { my $systemID = $configDB->addSystem($wrongSystem); }, + "inserting a system without '$requiredCol' column should fail" + ); } is( - my @systems = $configDB->fetchSystemByFilter, 1, - 'still just one system [default] should exist (array context)' + my @systems = $configDB->fetchSystemByFilter, 1, + 'still just one system [default] should exist (array context)' ); my $inSystem1 = { - 'name' => 'sys-1', - 'export_id' => 1, - 'comment' => '', - 'attrs' => { - 'ramfs_fsmods' => 'squashfs', - 'ramfs_nicmods' => 'e1000 forcedeth r8169', - 'start_sshd' => 'yes', - }, + 'name' => 'sys-1', + 'export_id' => 1, + 'comment' => '', + 'attrs' => { + 'ramfs_fsmods' => 'squashfs', + 'ramfs_nicmods' => 'e1000 forcedeth r8169', + 'start_sshd' => 'yes', + }, }; is( - my $system1ID = $configDB->addSystem($inSystem1), 1, - 'first system has ID 1' + my $system1ID = $configDB->addSystem($inSystem1), 1, + 'first system has ID 1' ); my $inSystem2 = { - 'name' => 'sys-2.0', - 'kernel' => 'vmlinuz', - 'export_id' => 1, - 'comment' => undef, + 'name' => 'sys-2.0', + 'kernel' => 'vmlinuz', + 'export_id' => 1, + 'comment' => undef, }; my $fullSystem = { - 'name' => 'sys-nr-3', - 'kernel' => 'vmlinuz-2.6.22.13-0.3-default', - 'export_id' => 3, - 'comment' => 'nuff said', - 'label' => 'BlingBling System - really kuul!', - 'kernel_params' => 'debug=3 console=ttyS1', - 'hidden' => '1', - 'attrs' => { - 'automnt_dir' => 'a', - 'automnt_src' => 'b', - 'country' => 'c', - 'dm_allow_shutdown' => 'd', - 'hw_graphic' => 'e', - 'hw_monitor' => 'f', - 'hw_mouse' => 'g', - 'late_dm' => 'h', - 'netbios_workgroup' => 'i', - 'nis_domain' => 'j', - 'nis_servers' => 'k', - 'ramfs_fsmods' => 'l', - 'ramfs_miscmods' => 'm', - 'ramfs_nicmods' => 'n', - 'sane_scanner' => 'p', - 'scratch' => 'q', - 'slxgrp' => 'r', - 'start_alsasound' => 's', - 'start_atd' => 't', - 'start_cron' => 'u', - 'start_dreshal' => 'v', - 'start_ntp' => 'w', - 'start_nfsv4' => 'x', - 'start_printer' => 'y', - 'start_samba' => 'z', - 'start_snmp' => 'A', - 'start_sshd' => 'B', - 'start_syslog' => 'C', - 'start_x' => 'D', - 'start_xdmcp' => 'E', - 'tex_enable' => 'F', - 'timezone' => 'G', - 'tvout' => 'H', - 'vmware' => 'I', - }, + 'name' => 'sys-nr-3', + 'kernel' => 'vmlinuz-2.6.22.13-0.3-default', + 'export_id' => 3, + 'comment' => 'nuff said', + 'label' => 'BlingBling System - really kuul!', + 'kernel_params' => 'debug=3 console=ttyS1', + 'hidden' => '1', + 'attrs' => { + 'automnt_dir' => 'a', + 'automnt_src' => 'b', + 'country' => 'c', + 'dm_allow_shutdown' => 'd', + 'hw_graphic' => 'e', + 'hw_monitor' => 'f', + 'hw_mouse' => 'g', + 'late_dm' => 'h', + 'netbios_workgroup' => 'i', + 'nis_domain' => 'j', + 'nis_servers' => 'k', + 'ramfs_fsmods' => 'l', + 'ramfs_miscmods' => 'm', + 'ramfs_nicmods' => 'n', + 'sane_scanner' => 'p', + 'scratch' => 'q', + 'slxgrp' => 'r', + 'start_alsasound' => 's', + 'start_atd' => 't', + 'start_cron' => 'u', + 'start_dreshal' => 'v', + 'start_ntp' => 'w', + 'start_nfsv4' => 'x', + 'start_printer' => 'y', + 'start_samba' => 'z', + 'start_snmp' => 'A', + 'start_sshd' => 'B', + 'start_syslog' => 'C', + 'start_x' => 'D', + 'start_xdmcp' => 'E', + 'tex_enable' => 'F', + 'timezone' => 'G', + 'tvout' => 'H', + 'vmware' => 'I', + }, }; ok( - my ($system2ID, $system3ID) = $configDB->addSystem([ - $inSystem2, $fullSystem - ]), - 'add two more systems' + my ($system2ID, $system3ID) = $configDB->addSystem([ + $inSystem2, $fullSystem + ]), + 'add two more systems' ); is($system2ID, 2, 'system 2 should have ID=2'); is($system3ID, 3, 'system 3 should have ID=3'); @@ -157,8 +157,8 @@ is(keys %{$system3->{attrs}}, 34, 'system 3 - attribu # fetch system 2 by a filter on id and check all values ok( - my $system2 = $configDB->fetchSystemByFilter({ id => 2 }), - 'fetch system 2 by filter on id' + my $system2 = $configDB->fetchSystemByFilter({ id => 2 }), + 'fetch system 2 by filter on id' ); is($system2->{id}, 2, 'system 2 - id'); is($system2->{name}, 'sys-2.0', 'system 2 - name'); @@ -169,8 +169,8 @@ is(keys %{$system2->{attrs}}, 0, 'system 2 - attribute count'); # fetch system 1 by filter on name and check all values ok( - my $system1 = $configDB->fetchSystemByFilter({ name => 'sys-1' }), - 'fetch system 1 by filter on name' + my $system1 = $configDB->fetchSystemByFilter({ name => 'sys-1' }), + 'fetch system 1 by filter on name' ); is($system1->{id}, 1, 'system 1 - id'); is($system1->{name}, 'sys-1', 'system 1 - name'); @@ -187,8 +187,8 @@ is($system1->{attrs}->{start_sshd}, 'yes', 'system 1 - att # fetch systems 3 & 1 by id ok( - my @systems3And1 = $configDB->fetchSystemByID([3, 1]), - 'fetch systems 3 & 1 by id' + my @systems3And1 = $configDB->fetchSystemByID([3, 1]), + 'fetch systems 3 & 1 by id' ); is(@systems3And1, 2, 'should have got 2 systems'); # now sort by ID and check if we have really got 3 and 1 @@ -198,21 +198,21 @@ is($systems3And1[1]->{id}, 3, 'second id should be 3'); # fetching systems by id without giving any should yield undef is( - $configDB->fetchSystemByID(), undef, - 'fetch systems by id without giving any' + $configDB->fetchSystemByID(), undef, + 'fetch systems by id without giving any' ); # fetching systems by filter without giving any should yield all of them ok( - @systems = $configDB->fetchSystemByFilter(), - 'fetch systems by filter without giving any' + @systems = $configDB->fetchSystemByFilter(), + 'fetch systems by filter without giving any' ); is(@systems, 4, 'should have got all four systems'); # fetch systems 1 & 2 by filter on export_id ok( - my @systems1And2 = $configDB->fetchSystemByFilter({ export_id => '1' }), - 'fetch systems 1 & 2 by filter on export_id' + my @systems1And2 = $configDB->fetchSystemByFilter({ export_id => '1' }), + 'fetch systems 1 & 2 by filter on export_id' ); is(@systems1And2, 2, 'should have got 2 systems'); # now sort by ID and check if we have really got 1 and 2 @@ -222,8 +222,8 @@ is($systems1And2[1]->{id}, 2, 'second id should be 2'); # fetch systems 1 & 2 by filter on hidden being undef'd ok( - @systems1And2 = $configDB->fetchSystemByFilter({ hidden => undef }), - 'fetch systems 1 & 2 by filter on hidden being undefined' + @systems1And2 = $configDB->fetchSystemByFilter({ hidden => undef }), + 'fetch systems 1 & 2 by filter on hidden being undefined' ); is(@systems1And2, 2, 'should have got 2 systems'); # now sort by ID and check if we have really got 1 and 2 @@ -233,9 +233,9 @@ is($systems1And2[1]->{id}, 2, 'second id should be 2'); # try to fetch with multi-column filter ok( - ($system2, $system3) - = $configDB->fetchSystemByFilter({ export_id => '1', id => 2 }), - 'fetching system with export_id=1 and id=2 should work' + ($system2, $system3) + = $configDB->fetchSystemByFilter({ export_id => '1', id => 2 }), + 'fetching system with export_id=1 and id=2 should work' ); is($system2->{name}, 'sys-2.0', 'should have got sys-2.0'); is($system3, undef, 'should not get sys-nr-3'); @@ -243,8 +243,8 @@ is($system3, undef, 'should not get sys-nr-3'); # try to fetch multiple occurrences of the same system, combined with # some unknown IDs ok( - my @systems1And3 = $configDB->fetchSystemByID([ 1, 21, 4-1, 1, 3, 1, 1 ]), - 'fetch a complex set of systems by ID' + my @systems1And3 = $configDB->fetchSystemByID([ 1, 21, 4-1, 1, 3, 1, 1 ]), + 'fetch a complex set of systems by ID' ); is(@systems1And3, 2, 'should have got 2 systems'); # now sort by ID and check if we have really got 1 and 3 @@ -254,74 +254,74 @@ is($systems1And3[1]->{id}, 3, 'second id should be 3'); # filter systems by different attributes & values in combination ok( - my @system1Only = $configDB->fetchSystemByFilter( {}, undef, { - ramfs_nicmods => 'e1000 forcedeth r8169' - } ), - 'fetch system 1 by filter on attribute ramfs_nicmods' + my @system1Only = $configDB->fetchSystemByFilter( {}, undef, { + ramfs_nicmods => 'e1000 forcedeth r8169' + } ), + 'fetch system 1 by filter on attribute ramfs_nicmods' ); is(@system1Only, 1, 'should have got 1 system'); is($system1Only[0]->{id}, 1, 'first id should be 1'); ok( - @system1Only = $configDB->fetchSystemByFilter( undef, 'id', { - ramfs_nicmods => 'e1000 forcedeth r8169', - slxgrp => undef, - } ), - 'fetch system 1 by filter on attribute ramfs_nicmods' + @system1Only = $configDB->fetchSystemByFilter( undef, 'id', { + ramfs_nicmods => 'e1000 forcedeth r8169', + slxgrp => undef, + } ), + 'fetch system 1 by filter on attribute ramfs_nicmods' ); is(@system1Only, 1, 'should have got 1 system'); is($system1Only[0]->{id}, 1, 'first id should be 1'); ok( - @system1Only = $configDB->fetchSystemByFilter( { - export_id => 1, - hidden => undef, - }, 'id', { - ramfs_nicmods => 'e1000 forcedeth r8169', - slxgrp => undef, - } ), - 'fetch system 1 by multiple filter on values and attributes' + @system1Only = $configDB->fetchSystemByFilter( { + export_id => 1, + hidden => undef, + }, 'id', { + ramfs_nicmods => 'e1000 forcedeth r8169', + slxgrp => undef, + } ), + 'fetch system 1 by multiple filter on values and attributes' ); is(@system1Only, 1, 'should have got 1 system'); is($system1Only[0]->{id}, 1, 'first id should be 1'); is( - $configDB->fetchSystemByFilter( { - export_id => 2, - }, 'id', { - ramfs_nicmods => 'e1000 forcedeth r8169', - slxgrp => undef, - } ), - undef, - 'mismatch system 1 by filter with incorrect value' + $configDB->fetchSystemByFilter( { + export_id => 2, + }, 'id', { + ramfs_nicmods => 'e1000 forcedeth r8169', + slxgrp => undef, + } ), + undef, + 'mismatch system 1 by filter with incorrect value' ); is( - $configDB->fetchSystemByFilter( { - export_id => 1, - }, 'id', { - ramfs_nicmods => 'xxxx', - slxgrp => undef, - } ), - undef, - 'mismatch system 1 by filter with incorrect attribute value' + $configDB->fetchSystemByFilter( { + export_id => 1, + }, 'id', { + ramfs_nicmods => 'xxxx', + slxgrp => undef, + } ), + undef, + 'mismatch system 1 by filter with incorrect attribute value' ); is( - $configDB->fetchSystemByFilter( { - name => 'sys-1', - }, 'id', { - start_sshd => undef, - } ), - undef, - 'mismatch system 1 by filter with attribute not being empty' + $configDB->fetchSystemByFilter( { + name => 'sys-1', + }, 'id', { + start_sshd => undef, + } ), + undef, + 'mismatch system 1 by filter with attribute not being empty' ); # fetch systems 1 & 2 by filter on attribute start_samba not existing ok( - @systems1And2 = $configDB->fetchSystemByFilter( {}, undef, { - start_samba => undef, - } ), - 'fetch systems 1 & 2 by filter on attribute start_samba not existing' + @systems1And2 = $configDB->fetchSystemByFilter( {}, undef, { + start_samba => undef, + } ), + 'fetch systems 1 & 2 by filter on attribute start_samba not existing' ); is(@systems1And2, 2, 'should have got 2 systems'); # now sort by ID and check if we have really got 1 and 2 @@ -331,34 +331,34 @@ is($systems1And2[1]->{id}, 2, 'second id should be 2'); # try to fetch a couple of non-existing systems by id is( - $configDB->fetchSystemByID(-1), undef, - 'system with id -1 should not exist' + $configDB->fetchSystemByID(-1), undef, + 'system with id -1 should not exist' ); ok($configDB->fetchSystemByID(0), 'system with id 0 should exist'); is( - $configDB->fetchSystemByID(1 << 31 + 1000), undef, - 'trying to fetch another unknown system' + $configDB->fetchSystemByID(1 << 31 + 1000), undef, + 'trying to fetch another unknown system' ); # try to fetch a couple of non-existing systems by filter is( - $configDB->fetchSystemByFilter({ id => 4 }), undef, - 'fetching system with id=4 by filter should fail' + $configDB->fetchSystemByFilter({ id => 4 }), undef, + 'fetching system with id=4 by filter should fail' ); is( - $configDB->fetchSystemByFilter({ name => 'sys-1.x' }), undef, - 'fetching system with name="sys-1.x" should fail' + $configDB->fetchSystemByFilter({ name => 'sys-1.x' }), undef, + 'fetching system with name="sys-1.x" should fail' ); is( - $configDB->fetchSystemByFilter({ export_id => '2', id => 1 }), undef, - 'fetching system with export_id=2 and id=1 should fail' + $configDB->fetchSystemByFilter({ export_id => '2', id => 1 }), undef, + 'fetching system with export_id=2 and id=1 should fail' ); # rename system 1 and then fetch it by its new name ok($configDB->changeSystem(1, { name => q{SYS-'1'} }), 'changing system 1'); ok( - $system1 = $configDB->fetchSystemByFilter({ name => q{SYS-'1'} }), - 'fetching renamed system 1' + $system1 = $configDB->fetchSystemByFilter({ name => q{SYS-'1'} }), + 'fetching renamed system 1' ); is($system1->{id}, 1, 'really got system number 1'); is($system1->{name}, q{SYS-'1'}, q{really got system named "SYS-'1'"}); @@ -395,8 +395,8 @@ ok(!exists $system1->{attrs}->{vmware}, 'attr vmware should be gone'); # changing a non-existing column should fail ok( - ! eval { $configDB->changeSystem(1, { xname => "xx" }) }, - 'changing unknown colum should fail' + ! eval { $configDB->changeSystem(1, { xname => "xx" }) }, + 'changing unknown colum should fail' ); ok(! $configDB->changeSystem(1, { id => 23 }), 'changing id should fail'); diff --git a/config-db/t/13-client.t b/config-db/t/13-client.t index 1c8ea99f..c9c77db9 100644 --- a/config-db/t/13-client.t +++ b/config-db/t/13-client.t @@ -12,96 +12,96 @@ my $configDB = OpenSLX::ConfigDB->new; $configDB->connect(); ok( - my $client = $configDB->fetchClientByFilter, - 'one client [default] should exist (scalar context)' + my $client = $configDB->fetchClientByFilter, + 'one client [default] should exist (scalar context)' ); foreach my $requiredCol (qw(name mac)) { - my $wrongClient = { - 'name' => 'name', - 'mac' => '01:02:03:04:05:06', - 'comment' => 'has column missing', - }; - delete $wrongClient->{$requiredCol}; - ok( - ! eval { my $clientID = $configDB->addClient($wrongClient); }, - "inserting a client without '$requiredCol' column should fail" - ); + my $wrongClient = { + 'name' => 'name', + 'mac' => '01:02:03:04:05:06', + 'comment' => 'has column missing', + }; + delete $wrongClient->{$requiredCol}; + ok( + ! eval { my $clientID = $configDB->addClient($wrongClient); }, + "inserting a client without '$requiredCol' column should fail" + ); } is( - my @clients = $configDB->fetchClientByFilter, 1, - 'still just one client [default] should exist (array context)' + my @clients = $configDB->fetchClientByFilter, 1, + 'still just one client [default] should exist (array context)' ); my $inClient1 = { - 'name' => 'cli-1', - 'mac' => '01:02:03:04:05:01', - 'comment' => '', - 'attrs' => { - 'slxgrp' => 'slxgrp', - 'start_snmp' => 'no', - 'start_sshd' => 'yes', - }, + 'name' => 'cli-1', + 'mac' => '01:02:03:04:05:01', + 'comment' => '', + 'attrs' => { + 'slxgrp' => 'slxgrp', + 'start_snmp' => 'no', + 'start_sshd' => 'yes', + }, }; is( - my $client1ID = $configDB->addClient($inClient1), 1, - 'first client has ID 1' + my $client1ID = $configDB->addClient($inClient1), 1, + 'first client has ID 1' ); my $inClient2 = { - 'name' => 'cli-2.0', - 'unbootable' => 1, - 'mac' => '01:02:03:04:05:02', - 'comment' => undef, - 'boot_type' => 'etherboot', + 'name' => 'cli-2.0', + 'unbootable' => 1, + 'mac' => '01:02:03:04:05:02', + 'comment' => undef, + 'boot_type' => 'etherboot', }; my $fullClient = { - 'name' => 'cli-nr-3', - 'mac' => '01:02:03:04:05:03', - 'comment' => 'nuff said', - 'kernel_params' => 'debug=3 console=ttyS1', - 'unbootable' => '0', - 'boot_type' => 'pxe', - 'attrs' => { - 'automnt_dir' => 'a', - 'automnt_src' => 'b', - 'country' => 'c', - 'dm_allow_shutdown' => 'd', - 'hw_graphic' => 'e', - 'hw_monitor' => 'f', - 'hw_mouse' => 'g', - 'late_dm' => 'h', - 'netbios_workgroup' => 'i', - 'nis_domain' => 'j', - 'nis_servers' => 'k', - 'sane_scanner' => 'p', - 'scratch' => 'q', - 'slxgrp' => 'r', - 'start_alsasound' => 's', - 'start_atd' => 't', - 'start_cron' => 'u', - 'start_dreshal' => 'v', - 'start_ntp' => 'w', - 'start_nfsv4' => 'x', - 'start_printer' => 'y', - 'start_samba' => 'z', - 'start_snmp' => 'A', - 'start_sshd' => 'B', - 'start_syslog' => 'C', - 'start_x' => 'D', - 'start_xdmcp' => 'E', - 'tex_enable' => 'F', - 'timezone' => 'G', - 'tvout' => 'H', - 'vmware' => 'I', - }, + 'name' => 'cli-nr-3', + 'mac' => '01:02:03:04:05:03', + 'comment' => 'nuff said', + 'kernel_params' => 'debug=3 console=ttyS1', + 'unbootable' => '0', + 'boot_type' => 'pxe', + 'attrs' => { + 'automnt_dir' => 'a', + 'automnt_src' => 'b', + 'country' => 'c', + 'dm_allow_shutdown' => 'd', + 'hw_graphic' => 'e', + 'hw_monitor' => 'f', + 'hw_mouse' => 'g', + 'late_dm' => 'h', + 'netbios_workgroup' => 'i', + 'nis_domain' => 'j', + 'nis_servers' => 'k', + 'sane_scanner' => 'p', + 'scratch' => 'q', + 'slxgrp' => 'r', + 'start_alsasound' => 's', + 'start_atd' => 't', + 'start_cron' => 'u', + 'start_dreshal' => 'v', + 'start_ntp' => 'w', + 'start_nfsv4' => 'x', + 'start_printer' => 'y', + 'start_samba' => 'z', + 'start_snmp' => 'A', + 'start_sshd' => 'B', + 'start_syslog' => 'C', + 'start_x' => 'D', + 'start_xdmcp' => 'E', + 'tex_enable' => 'F', + 'timezone' => 'G', + 'tvout' => 'H', + 'vmware' => 'I', + }, }; ok( - my ($client2ID, $client3ID) = $configDB->addClient([ - $inClient2, $fullClient - ]), - 'add two more clients' + my ($client2ID, $client3ID) = $configDB->addClient([ + $inClient2, $fullClient + ]), + 'add two more clients' ); is($client2ID, 2, 'client 2 should have ID=2'); is($client3ID, 3, 'client 3 should have ID=3'); @@ -150,8 +150,8 @@ is(keys %{$client3->{attrs}}, 31, 'client 3 - attribu # fetch client 2 by a filter on id and check all values ok( - my $client2 = $configDB->fetchClientByFilter({ id => 2 }), - 'fetch client 2 by filter on id' + my $client2 = $configDB->fetchClientByFilter({ id => 2 }), + 'fetch client 2 by filter on id' ); is($client2->{id}, 2, 'client 2 - id'); is($client2->{name}, 'cli-2.0', 'client 2 - name'); @@ -163,8 +163,8 @@ is(keys %{$client2->{attrs}}, 0, 'client 2 - attribute count') # fetch client 1 by filter on name and check all values ok( - my $client1 = $configDB->fetchClientByFilter({ name => 'cli-1' }), - 'fetch client 1 by filter on name' + my $client1 = $configDB->fetchClientByFilter({ name => 'cli-1' }), + 'fetch client 1 by filter on name' ); is($client1->{id}, 1, 'client 1 - id'); is($client1->{name}, 'cli-1', 'client 1 - name'); @@ -180,8 +180,8 @@ is($client1->{attrs}->{start_sshd}, 'yes', 'client 1 - attr start_sshd') # fetch clients 3 & 1 by id ok( - my @clients3And1 = $configDB->fetchClientByID([3, 1]), - 'fetch clients 3 & 1 by id' + my @clients3And1 = $configDB->fetchClientByID([3, 1]), + 'fetch clients 3 & 1 by id' ); is(@clients3And1, 2, 'should have got 2 clients'); # now sort by ID and check if we have really got 3 and 1 @@ -191,21 +191,21 @@ is($clients3And1[1]->{id}, 3, 'second id should be 3'); # fetching clients by id without giving any should yield undef is( - $configDB->fetchClientByID(), undef, - 'fetch clients by id without giving any' + $configDB->fetchClientByID(), undef, + 'fetch clients by id without giving any' ); # fetching clients by filter without giving any should yield all of them ok( - @clients = $configDB->fetchClientByFilter(), - 'fetch clients by filter without giving any' + @clients = $configDB->fetchClientByFilter(), + 'fetch clients by filter without giving any' ); is(@clients, 4, 'should have got all four clients'); # fetch clients 1 & 2 by filter on boot_type ok( - my @clients1And3 = $configDB->fetchClientByFilter({ boot_type => 'pxe' }), - 'fetch clients 1 & 3 by filter on boot_type' + my @clients1And3 = $configDB->fetchClientByFilter({ boot_type => 'pxe' }), + 'fetch clients 1 & 3 by filter on boot_type' ); is(@clients1And3, 2, 'should have got 2 clients'); # now sort by ID and check if we have really got 1 and 3 @@ -215,17 +215,17 @@ is($clients1And3[1]->{id}, 3, 'second id should be 3'); # try to fetch with multi-column filter ok( - ($client1, $client3) - = $configDB->fetchClientByFilter({ boot_type => 'pxe', id => 1 }), - 'fetching client with boot_type=pxe and id=1 should work' + ($client1, $client3) + = $configDB->fetchClientByFilter({ boot_type => 'pxe', id => 1 }), + 'fetching client with boot_type=pxe and id=1 should work' ); is($client1->{name}, 'cli-1', 'should have got cli-1'); is($client3, undef, 'should not get cli-nr-3'); # fetch client 1 by filter on unbootable being undef'd ok( - my @client1Only = $configDB->fetchClientByFilter({ unbootable => undef }), - 'fetch client 1 by filter on unbootable being undefined' + my @client1Only = $configDB->fetchClientByFilter({ unbootable => undef }), + 'fetch client 1 by filter on unbootable being undefined' ); is(@client1Only, 1, 'should have got 1 client'); is($client1Only[0]->{id}, 1, 'first id should be 1'); @@ -233,8 +233,8 @@ is($client1Only[0]->{id}, 1, 'first id should be 1'); # try to fetch multiple occurrences of the same client, combined with # some unknown IDs ok( - @clients1And3 = $configDB->fetchClientByID([ 1, 21, 4-1, 1, 4, 1, 1 ]), - 'fetch a complex set of clients by ID' + @clients1And3 = $configDB->fetchClientByID([ 1, 21, 4-1, 1, 4, 1, 1 ]), + 'fetch a complex set of clients by ID' ); is(@clients1And3, 2, 'should have got 2 clients'); # now sort by ID and check if we have really got 1 and 3 @@ -244,74 +244,74 @@ is($clients1And3[1]->{id}, 3, 'second id should be 3'); # filter clients by different attributes & values in combination ok( - @client1Only = $configDB->fetchClientByFilter( {}, undef, { - start_snmp => 'no', - } ), - 'fetch client 1 by filter on attribute start_snmp' + @client1Only = $configDB->fetchClientByFilter( {}, undef, { + start_snmp => 'no', + } ), + 'fetch client 1 by filter on attribute start_snmp' ); is(@client1Only, 1, 'should have got 1 client'); is($client1Only[0]->{id}, 1, 'first id should be 1'); ok( - @client1Only = $configDB->fetchClientByFilter( undef, 'id', { - start_snmp => 'no', - tex_enable => undef, - } ), - 'fetch client 1 by filter on attribute start_snmp + non-existing attr' + @client1Only = $configDB->fetchClientByFilter( undef, 'id', { + start_snmp => 'no', + tex_enable => undef, + } ), + 'fetch client 1 by filter on attribute start_snmp + non-existing attr' ); is(@client1Only, 1, 'should have got 1 client'); is($client1Only[0]->{id}, 1, 'first id should be 1'); ok( - @client1Only = $configDB->fetchClientByFilter( { - name => 'cli-1', - unbootable => undef, - }, 'id', { - start_snmp => 'no', - tex_enable => undef, - } ), - 'fetch client 1 by multiple filter on values and attributes' + @client1Only = $configDB->fetchClientByFilter( { + name => 'cli-1', + unbootable => undef, + }, 'id', { + start_snmp => 'no', + tex_enable => undef, + } ), + 'fetch client 1 by multiple filter on values and attributes' ); is(@client1Only, 1, 'should have got 1 client'); is($client1Only[0]->{id}, 1, 'first id should be 1'); is( - $configDB->fetchClientByFilter( { - comment => 'xxx', - }, 'id', { - start_snmp => 'no', - tex_enable => undef, - } ), - undef, - 'mismatch client 1 by filter with incorrect value' + $configDB->fetchClientByFilter( { + comment => 'xxx', + }, 'id', { + start_snmp => 'no', + tex_enable => undef, + } ), + undef, + 'mismatch client 1 by filter with incorrect value' ); is( - $configDB->fetchClientByFilter( { - name => 'cli-1', - }, 'id', { - start_snmp => 'yes', - tex_enable => undef, - } ), - undef, - 'mismatch client 1 by filter with incorrect attribute value' + $configDB->fetchClientByFilter( { + name => 'cli-1', + }, 'id', { + start_snmp => 'yes', + tex_enable => undef, + } ), + undef, + 'mismatch client 1 by filter with incorrect attribute value' ); is( - $configDB->fetchClientByFilter( { - name => 'cli-1', - }, 'id', { - start_sshd => undef, - } ), - undef, - 'mismatch client 1 by filter with attribute not being empty' + $configDB->fetchClientByFilter( { + name => 'cli-1', + }, 'id', { + start_sshd => undef, + } ), + undef, + 'mismatch client 1 by filter with attribute not being empty' ); # fetch clients 0, 1 & 2 by filter on attribute start_samba not existing ok( - my @clients01And2 = $configDB->fetchClientByFilter( {}, undef, { - start_samba => undef, - } ), - 'fetch clients 0,1 & 2 by filter on attribute start_samba not existing' + my @clients01And2 = $configDB->fetchClientByFilter( {}, undef, { + start_samba => undef, + } ), + 'fetch clients 0,1 & 2 by filter on attribute start_samba not existing' ); is(@clients01And2, 3, 'should have got 3 clients'); # now sort by ID and check if we have really got 0, 1 and 2 @@ -322,34 +322,34 @@ is($clients01And2[2]->{id}, 2, 'third id should be 2'); # try to fetch a couple of non-existing clients by id is( - $configDB->fetchClientByID(-1), undef, - 'client with id -1 should not exist' + $configDB->fetchClientByID(-1), undef, + 'client with id -1 should not exist' ); ok($configDB->fetchClientByID(0), 'client with id 0 should exist'); is( - $configDB->fetchClientByID(1 << 31 + 1000), undef, - 'trying to fetch another unknown client' + $configDB->fetchClientByID(1 << 31 + 1000), undef, + 'trying to fetch another unknown client' ); # try to fetch a couple of non-existing clients by filter is( - $configDB->fetchClientByFilter({ id => 4 }), undef, - 'fetching client with id=4 by filter should fail' + $configDB->fetchClientByFilter({ id => 4 }), undef, + 'fetching client with id=4 by filter should fail' ); is( - $configDB->fetchClientByFilter({ name => 'cli-1.x' }), undef, - 'fetching client with name="cli-1.x" should fail' + $configDB->fetchClientByFilter({ name => 'cli-1.x' }), undef, + 'fetching client with name="cli-1.x" should fail' ); is( - $configDB->fetchClientByFilter({ mac => '01:01:01:01:01:01', id => 1 }), undef, - 'fetching client with mac=01:01:01:01:01:01 and id=1 should fail' + $configDB->fetchClientByFilter({ mac => '01:01:01:01:01:01', id => 1 }), undef, + 'fetching client with mac=01:01:01:01:01:01 and id=1 should fail' ); # rename client 1 and then fetch it by its new name ok($configDB->changeClient(1, { name => q{CLI-'1'} }), 'changing client 1'); ok( - $client1 = $configDB->fetchClientByFilter({ name => q{CLI-'1'} }), - 'fetching renamed client 1' + $client1 = $configDB->fetchClientByFilter({ name => q{CLI-'1'} }), + 'fetching renamed client 1' ); is($client1->{id}, 1, 'really got client number 1'); is($client1->{name}, q{CLI-'1'}, q{really got client named "CLI-'1'"}); @@ -386,8 +386,8 @@ ok(!exists $client1->{attrs}->{vmware}, 'attr vmware should be gone'); # changing a non-existing column should fail ok( - ! eval { $configDB->changeClient(1, { xname => "xx" }) }, - 'changing unknown colum should fail' + ! eval { $configDB->changeClient(1, { xname => "xx" }) }, + 'changing unknown colum should fail' ); ok(! $configDB->changeClient(1, { id => 23 }), 'changing id should fail'); diff --git a/config-db/t/14-group.t b/config-db/t/14-group.t index b06620ce..5c5d0f81 100644 --- a/config-db/t/14-group.t +++ b/config-db/t/14-group.t @@ -12,90 +12,90 @@ my $configDB = OpenSLX::ConfigDB->new; $configDB->connect(); is( - my $group = $configDB->fetchGroupByFilter, undef, - 'no group should exist (scalar context)' + my $group = $configDB->fetchGroupByFilter, undef, + 'no group should exist (scalar context)' ); foreach my $requiredCol (qw(name)) { - my $wrongGroup = { - 'name' => 'name', - 'priority' => 41, - 'comment' => 'has column missing', - }; - delete $wrongGroup->{$requiredCol}; - ok( - ! eval { my $groupID = $configDB->addGroup($wrongGroup); }, - "inserting a group without '$requiredCol' column should fail" - ); + my $wrongGroup = { + 'name' => 'name', + 'priority' => 41, + 'comment' => 'has column missing', + }; + delete $wrongGroup->{$requiredCol}; + ok( + ! eval { my $groupID = $configDB->addGroup($wrongGroup); }, + "inserting a group without '$requiredCol' column should fail" + ); } is( - my @groups = $configDB->fetchGroupByFilter, 0, - 'still no group should exist (array context)' + my @groups = $configDB->fetchGroupByFilter, 0, + 'still no group should exist (array context)' ); my $inGroup1 = { - 'name' => 'grp-1', - 'comment' => '', - 'attrs' => { - 'slxgrp' => 'slxgrp', - 'start_snmp' => 'no', - 'start_sshd' => 'yes', - }, + 'name' => 'grp-1', + 'comment' => '', + 'attrs' => { + 'slxgrp' => 'slxgrp', + 'start_snmp' => 'no', + 'start_sshd' => 'yes', + }, }; is( - my $group1ID = $configDB->addGroup($inGroup1), 1, - 'first group has ID 1' + my $group1ID = $configDB->addGroup($inGroup1), 1, + 'first group has ID 1' ); my $inGroup2 = { - 'name' => 'grp-2.0', - 'priority' => 30, - 'comment' => undef, + 'name' => 'grp-2.0', + 'priority' => 30, + 'comment' => undef, }; my $fullGroup = { - 'name' => 'grp-nr-3', - 'priority' => 50, - 'comment' => 'nuff said', - 'attrs' => { - 'automnt_dir' => 'a', - 'automnt_src' => 'b', - 'country' => 'c', - 'dm_allow_shutdown' => 'd', - 'hw_graphic' => 'e', - 'hw_monitor' => 'f', - 'hw_mouse' => 'g', - 'late_dm' => 'h', - 'netbios_workgroup' => 'i', - 'nis_domain' => 'j', - 'nis_servers' => 'k', - 'sane_scanner' => 'p', - 'scratch' => 'q', - 'slxgrp' => 'r', - 'start_alsasound' => 's', - 'start_atd' => 't', - 'start_cron' => 'u', - 'start_dreshal' => 'v', - 'start_ntp' => 'w', - 'start_nfsv4' => 'x', - 'start_printer' => 'y', - 'start_samba' => 'z', - 'start_snmp' => 'A', - 'start_sshd' => 'B', - 'start_syslog' => 'C', - 'start_x' => 'D', - 'start_xdmcp' => 'E', - 'tex_enable' => 'F', - 'timezone' => 'G', - 'tvout' => 'H', - 'vmware' => 'I', - }, + 'name' => 'grp-nr-3', + 'priority' => 50, + 'comment' => 'nuff said', + 'attrs' => { + 'automnt_dir' => 'a', + 'automnt_src' => 'b', + 'country' => 'c', + 'dm_allow_shutdown' => 'd', + 'hw_graphic' => 'e', + 'hw_monitor' => 'f', + 'hw_mouse' => 'g', + 'late_dm' => 'h', + 'netbios_workgroup' => 'i', + 'nis_domain' => 'j', + 'nis_servers' => 'k', + 'sane_scanner' => 'p', + 'scratch' => 'q', + 'slxgrp' => 'r', + 'start_alsasound' => 's', + 'start_atd' => 't', + 'start_cron' => 'u', + 'start_dreshal' => 'v', + 'start_ntp' => 'w', + 'start_nfsv4' => 'x', + 'start_printer' => 'y', + 'start_samba' => 'z', + 'start_snmp' => 'A', + 'start_sshd' => 'B', + 'start_syslog' => 'C', + 'start_x' => 'D', + 'start_xdmcp' => 'E', + 'tex_enable' => 'F', + 'timezone' => 'G', + 'tvout' => 'H', + 'vmware' => 'I', + }, }; ok( - my ($group2ID, $group3ID) = $configDB->addGroup([ - $inGroup2, $fullGroup - ]), - 'add two more groups' + my ($group2ID, $group3ID) = $configDB->addGroup([ + $inGroup2, $fullGroup + ]), + 'add two more groups' ); is($group2ID, 2, 'group 2 should have ID=2'); is($group3ID, 3, 'group 3 should have ID=3'); @@ -141,8 +141,8 @@ is(keys %{$group3->{attrs}}, 31, 'group 3 - attribute coun # fetch group 2 by a filter on id and check all values ok( - my $group2 = $configDB->fetchGroupByFilter({ id => 2 }), - 'fetch group 2 by filter on id' + my $group2 = $configDB->fetchGroupByFilter({ id => 2 }), + 'fetch group 2 by filter on id' ); is($group2->{id}, 2, 'group 2 - id'); is($group2->{name}, 'grp-2.0', 'group 2 - name'); @@ -152,8 +152,8 @@ is(keys %{$group2->{attrs}}, 0, 'group 2 - attribute count'); # fetch group 1 by filter on name and check all values ok( - my $group1 = $configDB->fetchGroupByFilter({ name => 'grp-1' }), - 'fetch group 1 by filter on name' + my $group1 = $configDB->fetchGroupByFilter({ name => 'grp-1' }), + 'fetch group 1 by filter on name' ); is($group1->{id}, 1, 'group 1 - id'); is($group1->{name}, 'grp-1', 'group 1 - name'); @@ -166,8 +166,8 @@ is($group1->{attrs}->{start_sshd}, 'yes', 'group 1 - attr start_sshd'); # fetch groups 3 & 1 by id ok( - my @groups3And1 = $configDB->fetchGroupByID([3, 1]), - 'fetch groups 3 & 1 by id' + my @groups3And1 = $configDB->fetchGroupByID([3, 1]), + 'fetch groups 3 & 1 by id' ); is(@groups3And1, 2, 'should have got 2 groups'); # now sort by ID and check if we have really got 3 and 1 @@ -177,21 +177,21 @@ is($groups3And1[1]->{id}, 3, 'second id should be 3'); # fetching groups by id without giving any should yield undef is( - $configDB->fetchGroupByID(), undef, - 'fetch groups by id without giving any' + $configDB->fetchGroupByID(), undef, + 'fetch groups by id without giving any' ); # fetching groups by filter without giving any should yield all of them ok( - @groups = $configDB->fetchGroupByFilter(), - 'fetch groups by filter without giving any' + @groups = $configDB->fetchGroupByFilter(), + 'fetch groups by filter without giving any' ); is(@groups, 3, 'should have got all three groups'); # fetch groups 1 & 2 by filter on priority ok( - my @groups1And3 = $configDB->fetchGroupByFilter({ priority => 50 }), - 'fetch groups 1 & 3 by filter on priority' + my @groups1And3 = $configDB->fetchGroupByFilter({ priority => 50 }), + 'fetch groups 1 & 3 by filter on priority' ); is(@groups1And3, 2, 'should have got 2 groups'); # now sort by ID and check if we have really got 1 and 3 @@ -201,17 +201,17 @@ is($groups1And3[1]->{id}, 3, 'second id should be 3'); # fetch group 2 by filter on comment being undef'd ok( - my @group2Only = $configDB->fetchGroupByFilter({ comment => undef }), - 'fetch group 2 by filter on comment being undefined' + my @group2Only = $configDB->fetchGroupByFilter({ comment => undef }), + 'fetch group 2 by filter on comment being undefined' ); is(@group2Only, 1, 'should have got 1 group'); is($group2Only[0]->{id}, 2, 'first id should be 2'); # try to fetch with multi-column filter ok( - ($group1, $group3) - = $configDB->fetchGroupByFilter({ priority => '50', id => 1 }), - 'fetching group with priority=50 and id=1 should work' + ($group1, $group3) + = $configDB->fetchGroupByFilter({ priority => '50', id => 1 }), + 'fetching group with priority=50 and id=1 should work' ); is($group1->{name}, 'grp-1', 'should have got grp-1'); is($group3, undef, 'should not get grp-nr-3'); @@ -219,8 +219,8 @@ is($group3, undef, 'should not get grp-nr-3'); # try to fetch multiple occurrences of the same group, combined with # some unknown IDs ok( - @groups1And3 = $configDB->fetchGroupByID([ 1, 21, 4-1, 1, 4, 1, 1 ]), - 'fetch a complex set of groups by ID' + @groups1And3 = $configDB->fetchGroupByID([ 1, 21, 4-1, 1, 4, 1, 1 ]), + 'fetch a complex set of groups by ID' ); is(@groups1And3, 2, 'should have got 2 groups'); # now sort by ID and check if we have really got 1 and 3 @@ -230,74 +230,74 @@ is($groups1And3[1]->{id}, 3, 'second id should be 3'); # filter groups by different attributes & values in combination ok( - my @group1Only = $configDB->fetchGroupByFilter( {}, undef, { - start_snmp => 'no', - } ), - 'fetch group 1 by filter on attribute start_snmp' + my @group1Only = $configDB->fetchGroupByFilter( {}, undef, { + start_snmp => 'no', + } ), + 'fetch group 1 by filter on attribute start_snmp' ); is(@group1Only, 1, 'should have got 1 group'); is($group1Only[0]->{id}, 1, 'first id should be 1'); ok( - @group1Only = $configDB->fetchGroupByFilter( undef, 'id', { - start_snmp => 'no', - tex_enable => undef, - } ), - 'fetch group 1 by filter on attribute start_snmp + non-existing attr' + @group1Only = $configDB->fetchGroupByFilter( undef, 'id', { + start_snmp => 'no', + tex_enable => undef, + } ), + 'fetch group 1 by filter on attribute start_snmp + non-existing attr' ); is(@group1Only, 1, 'should have got 1 group'); is($group1Only[0]->{id}, 1, 'first id should be 1'); ok( - @group1Only = $configDB->fetchGroupByFilter( { - name => 'grp-1', - priority => 50, - }, 'id', { - start_snmp => 'no', - tex_enable => undef, - } ), - 'fetch group 1 by multiple filter on values and attributes' + @group1Only = $configDB->fetchGroupByFilter( { + name => 'grp-1', + priority => 50, + }, 'id', { + start_snmp => 'no', + tex_enable => undef, + } ), + 'fetch group 1 by multiple filter on values and attributes' ); is(@group1Only, 1, 'should have got 1 group'); is($group1Only[0]->{id}, 1, 'first id should be 1'); is( - $configDB->fetchGroupByFilter( { - comment => 'xxx', - }, 'id', { - start_snmp => 'no', - tex_enable => undef, - } ), - undef, - 'mismatch group 1 by filter with incorrect value' + $configDB->fetchGroupByFilter( { + comment => 'xxx', + }, 'id', { + start_snmp => 'no', + tex_enable => undef, + } ), + undef, + 'mismatch group 1 by filter with incorrect value' ); is( - $configDB->fetchGroupByFilter( { - name => 'grp-1', - }, 'id', { - start_snmp => 'yes', - tex_enable => undef, - } ), - undef, - 'mismatch group 1 by filter with incorrect attribute value' + $configDB->fetchGroupByFilter( { + name => 'grp-1', + }, 'id', { + start_snmp => 'yes', + tex_enable => undef, + } ), + undef, + 'mismatch group 1 by filter with incorrect attribute value' ); is( - $configDB->fetchGroupByFilter( { - name => 'grp-1', - }, 'id', { - start_sshd => undef, - } ), - undef, - 'mismatch group 1 by filter with attribute not being empty' + $configDB->fetchGroupByFilter( { + name => 'grp-1', + }, 'id', { + start_sshd => undef, + } ), + undef, + 'mismatch group 1 by filter with attribute not being empty' ); # fetch groups 1 & 2 by filter on attribute start_samba not existing ok( - my @groups1And2 = $configDB->fetchGroupByFilter( {}, undef, { - start_samba => undef, - } ), - 'fetch groups 1 & 2 by filter on attribute start_samba not existing' + my @groups1And2 = $configDB->fetchGroupByFilter( {}, undef, { + start_samba => undef, + } ), + 'fetch groups 1 & 2 by filter on attribute start_samba not existing' ); is(@groups1And2, 2, 'should have got 2 groups'); # now sort by ID and check if we have really got 1 and 2 @@ -309,29 +309,29 @@ is($groups1And2[1]->{id}, 2, 'second id should be 2'); is($configDB->fetchGroupByID(-1), undef, 'group with id -1 should not exist'); is($configDB->fetchGroupByID(0), undef, 'group with id 0 should not exist'); is( - $configDB->fetchGroupByID(1 << 31 + 1000), undef, - 'trying to fetch another unknown group' + $configDB->fetchGroupByID(1 << 31 + 1000), undef, + 'trying to fetch another unknown group' ); # try to fetch a couple of non-existing groups by filter is( - $configDB->fetchGroupByFilter({ id => 4 }), undef, - 'fetching group with id=4 by filter should fail' + $configDB->fetchGroupByFilter({ id => 4 }), undef, + 'fetching group with id=4 by filter should fail' ); is( - $configDB->fetchGroupByFilter({ name => 'grp-1.x' }), undef, - 'fetching group with name="grp-1.x" should fail' + $configDB->fetchGroupByFilter({ name => 'grp-1.x' }), undef, + 'fetching group with name="grp-1.x" should fail' ); is( - $configDB->fetchGroupByFilter({ priority => '22', id => 1 }), undef, - 'fetching group with priority=22 and id=1 should fail' + $configDB->fetchGroupByFilter({ priority => '22', id => 1 }), undef, + 'fetching group with priority=22 and id=1 should fail' ); # rename group 1 and then fetch it by its new name ok($configDB->changeGroup(1, { name => q{GRP-'1'} }), 'changing group 1'); ok( - $group1 = $configDB->fetchGroupByFilter({ name => q{GRP-'1'} }), - 'fetching renamed group 1' + $group1 = $configDB->fetchGroupByFilter({ name => q{GRP-'1'} }), + 'fetching renamed group 1' ); is($group1->{id}, 1, 'really got group number 1'); is($group1->{name}, q{GRP-'1'}, q{really got group named "GRP-'1'"}); @@ -368,8 +368,8 @@ ok(!exists $group1->{attrs}->{vmware}, 'attr vmware should be gone'); # changing a non-existing column should fail ok( - ! eval { $configDB->changeGroup(1, { xname => "xx" }) }, - 'changing unknown colum should fail' + ! eval { $configDB->changeGroup(1, { xname => "xx" }) }, + 'changing unknown colum should fail' ); ok(! $configDB->changeGroup(1, { id => 23 }), 'changing id should fail'); diff --git a/config-db/t/15-global_info.t b/config-db/t/15-global_info.t index 628b2495..8f2f8cf1 100644 --- a/config-db/t/15-global_info.t +++ b/config-db/t/15-global_info.t @@ -13,30 +13,30 @@ $configDB->connect(); # fetch global-info 'next-nbd-server-port' ok( - my $globalInfo = $configDB->fetchGlobalInfo('next-nbd-server-port'), - 'fetch global-info' + my $globalInfo = $configDB->fetchGlobalInfo('next-nbd-server-port'), + 'fetch global-info' ); is($globalInfo, '5000', 'global-info - value'); # try to fetch a couple of non-existing global-infos is( - $configDB->fetchGlobalInfo(-1), undef, - 'global-info with id -1 should not exist' + $configDB->fetchGlobalInfo(-1), undef, + 'global-info with id -1 should not exist' ); is($configDB->fetchGlobalInfo('xxx'), undef, - 'global-info with id xxx should not exist'); + 'global-info with id xxx should not exist'); # change value of global-info and then fetch and check the new value ok($configDB->changeGlobalInfo('next-nbd-server-port', '5050'), 'changing global-info'); is( - $configDB->fetchGlobalInfo('next-nbd-server-port'), '5050', - 'fetching changed global-info' + $configDB->fetchGlobalInfo('next-nbd-server-port'), '5050', + 'fetching changed global-info' ); # changing a non-existing global-info should fail ok( - ! eval { $configDB->changeGlobalInfo('xxx', 'new-value') }, - 'changing unknown global-info should fail' + ! eval { $configDB->changeGlobalInfo('xxx', 'new-value') }, + 'changing unknown global-info should fail' ); $configDB->disconnect(); diff --git a/config-db/t/20-client_system_ref.t b/config-db/t/20-client_system_ref.t index 46e56ddf..93b86950 100644 --- a/config-db/t/20-client_system_ref.t +++ b/config-db/t/20-client_system_ref.t @@ -25,184 +25,184 @@ my $system1 = shift @systems; my $system3 = shift @systems; foreach my $client ($defaultClient, $client1, $client3) { - is( - my @systemIDs = $configDB->fetchSystemIDsOfClient($client->{id}), - 0, "client $client->{id} has no system-IDs yet" - ); + is( + my @systemIDs = $configDB->fetchSystemIDsOfClient($client->{id}), + 0, "client $client->{id} has no system-IDs yet" + ); } foreach my $system ($defaultSystem, $system1, $system3) { - is( - my @clientIDs = $configDB->fetchClientIDsOfSystem($system->{id}), - 0, "system $system->{id} has no client-IDs yet" - ); + is( + my @clientIDs = $configDB->fetchClientIDsOfSystem($system->{id}), + 0, "system $system->{id} has no client-IDs yet" + ); } ok( - $configDB->addSystemIDsToClient(1, [3]), - 'system-ID 3 has been associated to client 1' + $configDB->addSystemIDsToClient(1, [3]), + 'system-ID 3 has been associated to client 1' ); is( - my @systemIDs = sort($configDB->fetchSystemIDsOfClient(0)), - 0, "default client should have no system-ID" + my @systemIDs = sort($configDB->fetchSystemIDsOfClient(0)), + 0, "default client should have no system-ID" ); is( - @systemIDs = sort($configDB->fetchSystemIDsOfClient(1)), - 1, "client 1 should have one system-ID" + @systemIDs = sort($configDB->fetchSystemIDsOfClient(1)), + 1, "client 1 should have one system-ID" ); is($systemIDs[0], 3, "first system of client 1 should have ID 3"); is( - @systemIDs = sort($configDB->fetchSystemIDsOfClient(3)), - 0, "client 3 should have no system-ID" + @systemIDs = sort($configDB->fetchSystemIDsOfClient(3)), + 0, "client 3 should have no system-ID" ); is( - my @clientIDs = sort($configDB->fetchClientIDsOfSystem(0)), - 0, "default system should have no client-IDs" + my @clientIDs = sort($configDB->fetchClientIDsOfSystem(0)), + 0, "default system should have no client-IDs" ); is( - @clientIDs = sort($configDB->fetchClientIDsOfSystem(1)), - 0, "system 1 should have no client-IDs" + @clientIDs = sort($configDB->fetchClientIDsOfSystem(1)), + 0, "system 1 should have no client-IDs" ); is( - @clientIDs = sort($configDB->fetchClientIDsOfSystem(3)), - 1, "system 3 should have one client-ID" + @clientIDs = sort($configDB->fetchClientIDsOfSystem(3)), + 1, "system 3 should have one client-ID" ); is($clientIDs[0], 1, "first client of system 3 should have ID 1"); ok( - $configDB->addSystemIDsToClient(3, [1,3,3,1,3]), - 'system-IDs 1 and 3 have been associated to client 3' + $configDB->addSystemIDsToClient(3, [1,3,3,1,3]), + 'system-IDs 1 and 3 have been associated to client 3' ); is( - @systemIDs = sort($configDB->fetchSystemIDsOfClient(0)), - 0, "default client should have no system-IDs" + @systemIDs = sort($configDB->fetchSystemIDsOfClient(0)), + 0, "default client should have no system-IDs" ); is( - @systemIDs = sort($configDB->fetchSystemIDsOfClient(1)), - 1, "client 1 should have one system-ID" + @systemIDs = sort($configDB->fetchSystemIDsOfClient(1)), + 1, "client 1 should have one system-ID" ); is($systemIDs[0], 3, "first system of client 1 should have ID 3"); is( - @systemIDs = sort($configDB->fetchSystemIDsOfClient(3)), - 2, "client 3 should have two system-IDs" + @systemIDs = sort($configDB->fetchSystemIDsOfClient(3)), + 2, "client 3 should have two system-IDs" ); is($systemIDs[0], 1, "first system of client 3 should have ID 1"); is($systemIDs[1], 3, "second system of client 3 should have ID 3"); is( - @clientIDs = sort($configDB->fetchClientIDsOfSystem(0)), - 0, "default system should have no client-ID" + @clientIDs = sort($configDB->fetchClientIDsOfSystem(0)), + 0, "default system should have no client-ID" ); is( - @clientIDs = sort($configDB->fetchClientIDsOfSystem(1)), - 1, "system 1 should have one client-ID" + @clientIDs = sort($configDB->fetchClientIDsOfSystem(1)), + 1, "system 1 should have one client-ID" ); is($clientIDs[0], 3, "first client of system 1 should have ID 3"); is( - @clientIDs = sort($configDB->fetchClientIDsOfSystem(3)), - 2, "system 3 should have two client-IDs" + @clientIDs = sort($configDB->fetchClientIDsOfSystem(3)), + 2, "system 3 should have two client-IDs" ); is($clientIDs[0], 1, "first client of system 3 should have ID 1"); is($clientIDs[1], 3, "second client of system 3 should have ID 3"); ok( - $configDB->setClientIDsOfSystem(3, []), - 'client-IDs of system 3 have been set to empty array' + $configDB->setClientIDsOfSystem(3, []), + 'client-IDs of system 3 have been set to empty array' ); is( - @clientIDs = sort($configDB->fetchClientIDsOfSystem(3)), - 0, "system 3 should have no client-IDs" + @clientIDs = sort($configDB->fetchClientIDsOfSystem(3)), + 0, "system 3 should have no client-IDs" ); is( - @systemIDs = sort($configDB->fetchSystemIDsOfClient(1)), - 0, "client 1 should have no system-IDs" + @systemIDs = sort($configDB->fetchSystemIDsOfClient(1)), + 0, "client 1 should have no system-IDs" ); is( - @systemIDs = sort($configDB->fetchSystemIDsOfClient(3)), - 1, "client 3 should have one system-ID" + @systemIDs = sort($configDB->fetchSystemIDsOfClient(3)), + 1, "client 3 should have one system-ID" ); is($systemIDs[0], 1, "first system of client 3 should have ID 1"); ok( - $configDB->addSystemIDsToClient(1, [0]), - 'associating the default system should have no effect' + $configDB->addSystemIDsToClient(1, [0]), + 'associating the default system should have no effect' ); is( - @systemIDs = sort($configDB->fetchSystemIDsOfClient(1)), - 0, "client 1 should still have no system-ID" + @systemIDs = sort($configDB->fetchSystemIDsOfClient(1)), + 0, "client 1 should still have no system-ID" ); ok( - $configDB->removeClientIDsFromSystem(1, [1]), - 'removing an unassociated client-ID should have no effect' + $configDB->removeClientIDsFromSystem(1, [1]), + 'removing an unassociated client-ID should have no effect' ); is( - @clientIDs = sort($configDB->fetchClientIDsOfSystem(1)), - 1, "system 1 should have one client-ID" + @clientIDs = sort($configDB->fetchClientIDsOfSystem(1)), + 1, "system 1 should have one client-ID" ); ok( - $configDB->removeClientIDsFromSystem(1, [3]), - 'removing an associated client-ID should work' + $configDB->removeClientIDsFromSystem(1, [3]), + 'removing an associated client-ID should work' ); is( - @clientIDs = sort($configDB->fetchClientIDsOfSystem(1)), - 0, "system 1 should have no more client-ID" + @clientIDs = sort($configDB->fetchClientIDsOfSystem(1)), + 0, "system 1 should have no more client-ID" ); $configDB->addSystem({ - 'name' => 'sys-4', - 'export_id' => 1, - 'comment' => 'shortlived', + 'name' => 'sys-4', + 'export_id' => 1, + 'comment' => 'shortlived', }); ok( - $configDB->addClientIDsToSystem(4, [0]), - 'default client has been associated to system 4' + $configDB->addClientIDsToSystem(4, [0]), + 'default client has been associated to system 4' ); is( - @systemIDs = sort($configDB->fetchSystemIDsOfClient(0)), - 1, "default client should have one system-ID" + @systemIDs = sort($configDB->fetchSystemIDsOfClient(0)), + 1, "default client should have one system-ID" ); is($systemIDs[0], 4, "first system of default client should have ID 4"); is( - @systemIDs = sort($configDB->fetchSystemIDsOfClient(1)), - 0, "client 1 should have no system-ID" + @systemIDs = sort($configDB->fetchSystemIDsOfClient(1)), + 0, "client 1 should have no system-ID" ); is( - @systemIDs = sort($configDB->fetchSystemIDsOfClient(3)), - 0, "client 3 should have no system-ID" + @systemIDs = sort($configDB->fetchSystemIDsOfClient(3)), + 0, "client 3 should have no system-ID" ); is( - @clientIDs = sort($configDB->fetchClientIDsOfSystem(0)), - 0, "default system should have no client-IDs" + @clientIDs = sort($configDB->fetchClientIDsOfSystem(0)), + 0, "default system should have no client-IDs" ); is( - @clientIDs = sort($configDB->fetchClientIDsOfSystem(1)), - 0, "system 1 should have no client-ID" + @clientIDs = sort($configDB->fetchClientIDsOfSystem(1)), + 0, "system 1 should have no client-ID" ); is( - @clientIDs = sort($configDB->fetchClientIDsOfSystem(3)), - 0, "system 3 should have no client-IDs" + @clientIDs = sort($configDB->fetchClientIDsOfSystem(3)), + 0, "system 3 should have no client-IDs" ); is( - @clientIDs = sort($configDB->fetchClientIDsOfSystem(4)), - 1, "system 4 should have one client-ID" + @clientIDs = sort($configDB->fetchClientIDsOfSystem(4)), + 1, "system 4 should have one client-ID" ); is($clientIDs[0], 0, "first client of system 4 should have ID 0"); ok( - $configDB->removeSystemIDsFromClient(0, [6]), - 'removing an unassociated system-ID should have no effect' + $configDB->removeSystemIDsFromClient(0, [6]), + 'removing an unassociated system-ID should have no effect' ); is( - @clientIDs = sort($configDB->fetchSystemIDsOfClient(0)), - 1, "default client should have one system-ID" + @clientIDs = sort($configDB->fetchSystemIDsOfClient(0)), + 1, "default client should have one system-ID" ); ok( - $configDB->removeSystem(4), - 'removing a system should drop client associations, too' + $configDB->removeSystem(4), + 'removing a system should drop client associations, too' ); is( - @clientIDs = sort($configDB->fetchSystemIDsOfClient(0)), - 0, "default client should have no more system-ID" + @clientIDs = sort($configDB->fetchSystemIDsOfClient(0)), + 0, "default client should have no more system-ID" ); $configDB->disconnect(); diff --git a/config-db/t/21-group_system_ref.t b/config-db/t/21-group_system_ref.t index 6f92a8dd..b643f7e0 100644 --- a/config-db/t/21-group_system_ref.t +++ b/config-db/t/21-group_system_ref.t @@ -24,172 +24,172 @@ my $system1 = shift @systems; my $system3 = shift @systems; foreach my $group ($group1, $group3) { - is( - my @systemIDs = $configDB->fetchSystemIDsOfGroup($group->{id}), - 0, "group $group->{id} has no system-IDs yet" - ); + is( + my @systemIDs = $configDB->fetchSystemIDsOfGroup($group->{id}), + 0, "group $group->{id} has no system-IDs yet" + ); } foreach my $system ($defaultSystem, $system1, $system3) { - is( - my @groupIDs = $configDB->fetchGroupIDsOfSystem($system->{id}), - 0, "system $system->{id} has no group-IDs yet" - ); + is( + my @groupIDs = $configDB->fetchGroupIDsOfSystem($system->{id}), + 0, "system $system->{id} has no group-IDs yet" + ); } ok( - $configDB->addSystemIDsToGroup(1, [3]), - 'system-ID 3 has been associated to group 1' + $configDB->addSystemIDsToGroup(1, [3]), + 'system-ID 3 has been associated to group 1' ); is( - my @systemIDs = sort($configDB->fetchSystemIDsOfGroup(1)), - 1, "group 1 should have one system-ID" + my @systemIDs = sort($configDB->fetchSystemIDsOfGroup(1)), + 1, "group 1 should have one system-ID" ); is($systemIDs[0], 3, "first system of group 1 should have ID 3"); is( - @systemIDs = sort($configDB->fetchSystemIDsOfGroup(3)), - 0, "group 3 should have no system-ID" + @systemIDs = sort($configDB->fetchSystemIDsOfGroup(3)), + 0, "group 3 should have no system-ID" ); is( - my @groupIDs = sort($configDB->fetchGroupIDsOfSystem(0)), - 0, "default system should have no group-IDs" + my @groupIDs = sort($configDB->fetchGroupIDsOfSystem(0)), + 0, "default system should have no group-IDs" ); is( - @groupIDs = sort($configDB->fetchGroupIDsOfSystem(1)), - 0, "system 1 should have no group-IDs" + @groupIDs = sort($configDB->fetchGroupIDsOfSystem(1)), + 0, "system 1 should have no group-IDs" ); is( - @groupIDs = sort($configDB->fetchGroupIDsOfSystem(3)), - 1, "system 3 should have one group-ID" + @groupIDs = sort($configDB->fetchGroupIDsOfSystem(3)), + 1, "system 3 should have one group-ID" ); is($groupIDs[0], 1, "first group of system 3 should have ID 1"); ok( - $configDB->addSystemIDsToGroup(3, [1,3,3,1,3]), - 'system-IDs 1 and 3 have been associated to group 3' + $configDB->addSystemIDsToGroup(3, [1,3,3,1,3]), + 'system-IDs 1 and 3 have been associated to group 3' ); is( - @systemIDs = sort($configDB->fetchSystemIDsOfGroup(1)), - 1, "group 1 should have one system-ID" + @systemIDs = sort($configDB->fetchSystemIDsOfGroup(1)), + 1, "group 1 should have one system-ID" ); is($systemIDs[0], 3, "first system of group 1 should have ID 3"); is( - @systemIDs = sort($configDB->fetchSystemIDsOfGroup(3)), - 2, "group 3 should have two system-IDs" + @systemIDs = sort($configDB->fetchSystemIDsOfGroup(3)), + 2, "group 3 should have two system-IDs" ); is($systemIDs[0], 1, "first system of group 3 should have ID 1"); is($systemIDs[1], 3, "second system of group 3 should have ID 3"); is( - @groupIDs = sort($configDB->fetchGroupIDsOfSystem(0)), - 0, "default system should have no group-ID" + @groupIDs = sort($configDB->fetchGroupIDsOfSystem(0)), + 0, "default system should have no group-ID" ); is( - @groupIDs = sort($configDB->fetchGroupIDsOfSystem(1)), - 1, "system 1 should have one group-ID" + @groupIDs = sort($configDB->fetchGroupIDsOfSystem(1)), + 1, "system 1 should have one group-ID" ); is($groupIDs[0], 3, "first group of system 1 should have ID 3"); is( - @groupIDs = sort($configDB->fetchGroupIDsOfSystem(3)), - 2, "system 3 should have two group-IDs" + @groupIDs = sort($configDB->fetchGroupIDsOfSystem(3)), + 2, "system 3 should have two group-IDs" ); is($groupIDs[0], 1, "first group of system 3 should have ID 1"); is($groupIDs[1], 3, "second group of system 3 should have ID 3"); ok( - $configDB->setGroupIDsOfSystem(3, []), - 'group-IDs of system 3 have been set to empty array' + $configDB->setGroupIDsOfSystem(3, []), + 'group-IDs of system 3 have been set to empty array' ); is( - @groupIDs = sort($configDB->fetchGroupIDsOfSystem(3)), - 0, "system 3 should have no group-IDs" + @groupIDs = sort($configDB->fetchGroupIDsOfSystem(3)), + 0, "system 3 should have no group-IDs" ); is( - @systemIDs = sort($configDB->fetchSystemIDsOfGroup(1)), - 0, "group 1 should have no more system-IDs" + @systemIDs = sort($configDB->fetchSystemIDsOfGroup(1)), + 0, "group 1 should have no more system-IDs" ); is( - @systemIDs = sort($configDB->fetchSystemIDsOfGroup(3)), - 1, "group 3 should have one system-ID" + @systemIDs = sort($configDB->fetchSystemIDsOfGroup(3)), + 1, "group 3 should have one system-ID" ); is($systemIDs[0], 1, "first system of group 3 should have ID 1"); ok( - $configDB->addSystemIDsToGroup(1, [0]), - 'associating the default system should have no effect' + $configDB->addSystemIDsToGroup(1, [0]), + 'associating the default system should have no effect' ); is( - @systemIDs = sort($configDB->fetchSystemIDsOfGroup(1)), - 0, "group 1 should still have no system-ID" + @systemIDs = sort($configDB->fetchSystemIDsOfGroup(1)), + 0, "group 1 should still have no system-ID" ); ok( - $configDB->removeGroupIDsFromSystem(1, [1]), - 'removing an unassociated group-ID should have no effect' + $configDB->removeGroupIDsFromSystem(1, [1]), + 'removing an unassociated group-ID should have no effect' ); is( - @groupIDs = sort($configDB->fetchGroupIDsOfSystem(1)), - 1, "system 1 should have one group-ID" + @groupIDs = sort($configDB->fetchGroupIDsOfSystem(1)), + 1, "system 1 should have one group-ID" ); ok( - $configDB->removeGroupIDsFromSystem(1, [3]), - 'removing an associated group-ID should work' + $configDB->removeGroupIDsFromSystem(1, [3]), + 'removing an associated group-ID should work' ); is( - @groupIDs = sort($configDB->fetchGroupIDsOfSystem(1)), - 0, "system 1 should have no more group-ID" + @groupIDs = sort($configDB->fetchGroupIDsOfSystem(1)), + 0, "system 1 should have no more group-ID" ); $configDB->addSystem({ - 'name' => 'sys-5', - 'export_id' => 1, - 'comment' => 'shortlived', + 'name' => 'sys-5', + 'export_id' => 1, + 'comment' => 'shortlived', }); ok( - $configDB->addGroupIDsToSystem(5, [3]), - 'default group has been associated to system 5' + $configDB->addGroupIDsToSystem(5, [3]), + 'default group has been associated to system 5' ); is( - @systemIDs = sort($configDB->fetchSystemIDsOfGroup(1)), - 0, "group 1 should have no system-ID" + @systemIDs = sort($configDB->fetchSystemIDsOfGroup(1)), + 0, "group 1 should have no system-ID" ); is( - @systemIDs = sort($configDB->fetchSystemIDsOfGroup(3)), - 1, "group 3 should have no system-ID" + @systemIDs = sort($configDB->fetchSystemIDsOfGroup(3)), + 1, "group 3 should have no system-ID" ); is($systemIDs[0], 5, "first system of group 3 should have ID 5"); is( - @groupIDs = sort($configDB->fetchGroupIDsOfSystem(0)), - 0, "default system should have no group-IDs" + @groupIDs = sort($configDB->fetchGroupIDsOfSystem(0)), + 0, "default system should have no group-IDs" ); is( - @groupIDs = sort($configDB->fetchGroupIDsOfSystem(1)), - 0, "system 1 should have no group-ID" + @groupIDs = sort($configDB->fetchGroupIDsOfSystem(1)), + 0, "system 1 should have no group-ID" ); is( - @groupIDs = sort($configDB->fetchGroupIDsOfSystem(3)), - 0, "system 3 should have no group-IDs" + @groupIDs = sort($configDB->fetchGroupIDsOfSystem(3)), + 0, "system 3 should have no group-IDs" ); is( - @groupIDs = sort($configDB->fetchGroupIDsOfSystem(5)), - 1, "system 5 should have one group-ID" + @groupIDs = sort($configDB->fetchGroupIDsOfSystem(5)), + 1, "system 5 should have one group-ID" ); is($groupIDs[0], 3, "first group of system 5 should have ID 3"); ok( - $configDB->removeSystemIDsFromGroup(3, [6]), - 'removing an unassociated system-ID should have no effect' + $configDB->removeSystemIDsFromGroup(3, [6]), + 'removing an unassociated system-ID should have no effect' ); is( - @groupIDs = sort($configDB->fetchSystemIDsOfGroup(3)), - 1, "group 3 should have one system-ID" + @groupIDs = sort($configDB->fetchSystemIDsOfGroup(3)), + 1, "group 3 should have one system-ID" ); ok( - $configDB->removeSystem(5), - 'removing a system should drop group associations, too' + $configDB->removeSystem(5), + 'removing a system should drop group associations, too' ); is( - @groupIDs = sort($configDB->fetchSystemIDsOfGroup(3)), - 0, "group 3 should have no more system-ID" + @groupIDs = sort($configDB->fetchSystemIDsOfGroup(3)), + 0, "group 3 should have no more system-ID" ); $configDB->disconnect(); diff --git a/config-db/t/22-group_client_ref.t b/config-db/t/22-group_client_ref.t index d330bc23..ff9d6ca7 100644 --- a/config-db/t/22-group_client_ref.t +++ b/config-db/t/22-group_client_ref.t @@ -24,163 +24,163 @@ my $client1 = shift @clients; my $client3 = shift @clients; foreach my $group ($group1, $group3) { - is( - my @clientIDs = $configDB->fetchClientIDsOfGroup($group->{id}), - 0, "group $group->{id} has no client-IDs yet" - ); + is( + my @clientIDs = $configDB->fetchClientIDsOfGroup($group->{id}), + 0, "group $group->{id} has no client-IDs yet" + ); } foreach my $client ($defaultClient, $client1, $client3) { - is( - my @groupIDs = $configDB->fetchGroupIDsOfClient($client->{id}), - 0, "client $client->{id} has no group-IDs yet" - ); + is( + my @groupIDs = $configDB->fetchGroupIDsOfClient($client->{id}), + 0, "client $client->{id} has no group-IDs yet" + ); } ok( - $configDB->addClientIDsToGroup(1, [3]), - 'client-ID 3 has been associated to group 1' + $configDB->addClientIDsToGroup(1, [3]), + 'client-ID 3 has been associated to group 1' ); is( - my @clientIDs = sort($configDB->fetchClientIDsOfGroup(1)), - 1, "group 1 should have one client-ID" + my @clientIDs = sort($configDB->fetchClientIDsOfGroup(1)), + 1, "group 1 should have one client-ID" ); is($clientIDs[0], 3, "first client of group 1 should have ID 3"); is( - @clientIDs = sort($configDB->fetchClientIDsOfGroup(3)), - 0, "group 3 should have no client-ID" + @clientIDs = sort($configDB->fetchClientIDsOfGroup(3)), + 0, "group 3 should have no client-ID" ); is( - my @groupIDs = sort($configDB->fetchGroupIDsOfClient(0)), - 0, "default client should have no group-IDs" + my @groupIDs = sort($configDB->fetchGroupIDsOfClient(0)), + 0, "default client should have no group-IDs" ); is( - @groupIDs = sort($configDB->fetchGroupIDsOfClient(1)), - 0, "client 1 should have no group-IDs" + @groupIDs = sort($configDB->fetchGroupIDsOfClient(1)), + 0, "client 1 should have no group-IDs" ); is( - @groupIDs = sort($configDB->fetchGroupIDsOfClient(3)), - 1, "client 3 should have one group-ID" + @groupIDs = sort($configDB->fetchGroupIDsOfClient(3)), + 1, "client 3 should have one group-ID" ); is($groupIDs[0], 1, "first group of client 3 should have ID 1"); ok( - $configDB->addClientIDsToGroup(3, [1,3,3,1,3]), - 'client-IDs 1 and 3 have been associated to group 3' + $configDB->addClientIDsToGroup(3, [1,3,3,1,3]), + 'client-IDs 1 and 3 have been associated to group 3' ); is( - @clientIDs = sort($configDB->fetchClientIDsOfGroup(1)), - 1, "group 1 should have one client-ID" + @clientIDs = sort($configDB->fetchClientIDsOfGroup(1)), + 1, "group 1 should have one client-ID" ); is($clientIDs[0], 3, "first client of group 1 should have ID 3"); is( - @clientIDs = sort($configDB->fetchClientIDsOfGroup(3)), - 2, "group 3 should have two client-IDs" + @clientIDs = sort($configDB->fetchClientIDsOfGroup(3)), + 2, "group 3 should have two client-IDs" ); is($clientIDs[0], 1, "first client of group 3 should have ID 1"); is($clientIDs[1], 3, "second client of group 3 should have ID 3"); is( - @groupIDs = sort($configDB->fetchGroupIDsOfClient(0)), - 0, "default client should have no group-ID" + @groupIDs = sort($configDB->fetchGroupIDsOfClient(0)), + 0, "default client should have no group-ID" ); is( - @groupIDs = sort($configDB->fetchGroupIDsOfClient(1)), - 1, "client 1 should have one group-ID" + @groupIDs = sort($configDB->fetchGroupIDsOfClient(1)), + 1, "client 1 should have one group-ID" ); is($groupIDs[0], 3, "first group of client 1 should have ID 3"); is( - @groupIDs = sort($configDB->fetchGroupIDsOfClient(3)), - 2, "client 3 should have two group-IDs" + @groupIDs = sort($configDB->fetchGroupIDsOfClient(3)), + 2, "client 3 should have two group-IDs" ); is($groupIDs[0], 1, "first group of client 3 should have ID 1"); is($groupIDs[1], 3, "second group of client 3 should have ID 3"); ok( - $configDB->setGroupIDsOfClient(3, []), - 'group-IDs of client 3 have been set to empty array' + $configDB->setGroupIDsOfClient(3, []), + 'group-IDs of client 3 have been set to empty array' ); is( - @groupIDs = sort($configDB->fetchGroupIDsOfClient(3)), - 0, "client 3 should have no group-IDs" + @groupIDs = sort($configDB->fetchGroupIDsOfClient(3)), + 0, "client 3 should have no group-IDs" ); is( - @clientIDs = sort($configDB->fetchClientIDsOfGroup(1)), - 0, "group 1 should have no more client-IDs" + @clientIDs = sort($configDB->fetchClientIDsOfGroup(1)), + 0, "group 1 should have no more client-IDs" ); is( - @clientIDs = sort($configDB->fetchClientIDsOfGroup(3)), - 1, "group 3 should have one client-ID" + @clientIDs = sort($configDB->fetchClientIDsOfGroup(3)), + 1, "group 3 should have one client-ID" ); is($clientIDs[0], 1, "first client of group 3 should have ID 1"); ok( - $configDB->removeGroupIDsFromClient(1, [1]), - 'removing an unassociated group-ID should have no effect' + $configDB->removeGroupIDsFromClient(1, [1]), + 'removing an unassociated group-ID should have no effect' ); is( - @groupIDs = sort($configDB->fetchGroupIDsOfClient(1)), - 1, "client 1 should have one group-ID" + @groupIDs = sort($configDB->fetchGroupIDsOfClient(1)), + 1, "client 1 should have one group-ID" ); ok( - $configDB->removeGroupIDsFromClient(1, [3]), - 'removing an associated group-ID should work' + $configDB->removeGroupIDsFromClient(1, [3]), + 'removing an associated group-ID should work' ); is( - @groupIDs = sort($configDB->fetchGroupIDsOfClient(1)), - 0, "client 1 should have no more group-ID" + @groupIDs = sort($configDB->fetchGroupIDsOfClient(1)), + 0, "client 1 should have no more group-ID" ); $configDB->addClient({ - 'name' => 'cli-4', - 'mac' => '01:01:01:02:02:02', - 'comment' => 'shortlived', + 'name' => 'cli-4', + 'mac' => '01:01:01:02:02:02', + 'comment' => 'shortlived', }); ok( - $configDB->addGroupIDsToClient(4, [3]), - 'default group has been associated to client 4' + $configDB->addGroupIDsToClient(4, [3]), + 'default group has been associated to client 4' ); is( - @clientIDs = sort($configDB->fetchClientIDsOfGroup(1)), - 0, "group 1 should have no client-ID" + @clientIDs = sort($configDB->fetchClientIDsOfGroup(1)), + 0, "group 1 should have no client-ID" ); is( - @clientIDs = sort($configDB->fetchClientIDsOfGroup(3)), - 1, "group 3 should have one client-ID" + @clientIDs = sort($configDB->fetchClientIDsOfGroup(3)), + 1, "group 3 should have one client-ID" ); is($clientIDs[0], 4, "first client of group 3 should have ID 1"); is( - @groupIDs = sort($configDB->fetchGroupIDsOfClient(0)), - 0, "default client should have no group-IDs" + @groupIDs = sort($configDB->fetchGroupIDsOfClient(0)), + 0, "default client should have no group-IDs" ); is( - @groupIDs = sort($configDB->fetchGroupIDsOfClient(1)), - 0, "client 1 should have no group-ID" + @groupIDs = sort($configDB->fetchGroupIDsOfClient(1)), + 0, "client 1 should have no group-ID" ); is( - @groupIDs = sort($configDB->fetchGroupIDsOfClient(3)), - 0, "client 3 should have no group-IDs" + @groupIDs = sort($configDB->fetchGroupIDsOfClient(3)), + 0, "client 3 should have no group-IDs" ); is( - @groupIDs = sort($configDB->fetchGroupIDsOfClient(4)), - 1, "client 4 should have one group-ID" + @groupIDs = sort($configDB->fetchGroupIDsOfClient(4)), + 1, "client 4 should have one group-ID" ); is($groupIDs[0], 3, "first group of client 4 should have ID 3"); ok( - $configDB->removeClientIDsFromGroup(3, [6]), - 'removing an unassociated client-ID should have no effect' + $configDB->removeClientIDsFromGroup(3, [6]), + 'removing an unassociated client-ID should have no effect' ); is( - @groupIDs = sort($configDB->fetchClientIDsOfGroup(3)), - 1, "group 3 should have one client-ID" + @groupIDs = sort($configDB->fetchClientIDsOfGroup(3)), + 1, "group 3 should have one client-ID" ); ok( - $configDB->removeClient(4), - 'removing a client should drop group associations, too' + $configDB->removeClient(4), + 'removing a client should drop group associations, too' ); is( - @groupIDs = sort($configDB->fetchClientIDsOfGroup(3)), - 0, "group 3 should have no more client-ID" + @groupIDs = sort($configDB->fetchClientIDsOfGroup(3)), + 0, "group 3 should have no more client-ID" ); $configDB->disconnect(); diff --git a/config-db/t/25-attributes.t b/config-db/t/25-attributes.t index 469d330c..32c1b0fb 100644 --- a/config-db/t/25-attributes.t +++ b/config-db/t/25-attributes.t @@ -13,350 +13,350 @@ use OpenSLX::ConfigDB qw(:support); my $configDB = OpenSLX::ConfigDB->new; $configDB->connect(); -my $defaultAttrs = { # mostly copied from DBSchema - 'ramfs_fsmods' => undef, - 'ramfs_miscmods' => undef, - 'ramfs_nicmods' => 'forcedeth e1000 e100 tg3 via-rhine r8169 pcnet32', - - 'automnt_dir' => undef, - 'automnt_src' => undef, - 'country' => 'de', - 'dm_allow_shutdown' => 'user', - 'hw_graphic' => undef, - 'hw_monitor' => undef, - 'hw_mouse' => undef, - 'late_dm' => 'no', - 'netbios_workgroup' => 'slx-network', - 'nis_domain' => undef, - 'nis_servers' => undef, - 'sane_scanner' => undef, - 'scratch' => undef, - 'slxgrp' => undef, - 'start_alsasound' => 'yes', - 'start_atd' => 'no', - 'start_cron' => 'no', - 'start_dreshal' => 'yes', - 'start_ntp' => 'initial', - 'start_nfsv4' => 'no', - 'start_printer' => 'no', - 'start_samba' => 'may', - 'start_snmp' => 'no', - 'start_sshd' => 'yes', - 'start_syslog' => 'yes', - 'start_x' => 'yes', - 'start_xdmcp' => 'kdm', - 'tex_enable' => 'no', - 'timezone' => 'Europe/Berlin', - 'tvout' => 'no', - 'vmware' => 'no', +my $defaultAttrs = { # mostly copied from DBSchema + 'ramfs_fsmods' => undef, + 'ramfs_miscmods' => undef, + 'ramfs_nicmods' => 'forcedeth e1000 e100 tg3 via-rhine r8169 pcnet32', + + 'automnt_dir' => undef, + 'automnt_src' => undef, + 'country' => 'de', + 'dm_allow_shutdown' => 'user', + 'hw_graphic' => undef, + 'hw_monitor' => undef, + 'hw_mouse' => undef, + 'late_dm' => 'no', + 'netbios_workgroup' => 'slx-network', + 'nis_domain' => undef, + 'nis_servers' => undef, + 'sane_scanner' => undef, + 'scratch' => undef, + 'slxgrp' => undef, + 'start_alsasound' => 'yes', + 'start_atd' => 'no', + 'start_cron' => 'no', + 'start_dreshal' => 'yes', + 'start_ntp' => 'initial', + 'start_nfsv4' => 'no', + 'start_printer' => 'no', + 'start_samba' => 'may', + 'start_snmp' => 'no', + 'start_sshd' => 'yes', + 'start_syslog' => 'yes', + 'start_x' => 'yes', + 'start_xdmcp' => 'kdm', + 'tex_enable' => 'no', + 'timezone' => 'Europe/Berlin', + 'tvout' => 'no', + 'vmware' => 'no', }; ok( - $configDB->changeSystem(0, { attrs => $defaultAttrs } ), - 'attributes of default system have been set' + $configDB->changeSystem(0, { attrs => $defaultAttrs } ), + 'attributes of default system have been set' ); my $defaultSystem = $configDB->fetchSystemByID(0); my $system1 = $configDB->fetchSystemByID(1); my $sys1Attrs = { - 'ramfs_fsmods' => 'squashfs', - 'ramfs_nicmods' => 'forcedeth e1000 r8169', - 'start_x' => 'no', - 'start_xdmcp' => '', + 'ramfs_fsmods' => 'squashfs', + 'ramfs_nicmods' => 'forcedeth e1000 r8169', + 'start_x' => 'no', + 'start_xdmcp' => '', }; ok( - $configDB->changeSystem(1, { attrs => $sys1Attrs } ), - 'attributes of system 1 have been set' + $configDB->changeSystem(1, { attrs => $sys1Attrs } ), + 'attributes of system 1 have been set' ); my $system3 = $configDB->fetchSystemByID(3); my $sys3Attrs = { - 'ramfs_fsmods' => '-4', - 'ramfs_miscmods' => '-3', - 'ramfs_nicmods' => '-2', - - 'automnt_dir' => '1', - 'automnt_src' => '2', - 'country' => '3', - 'dm_allow_shutdown' => '4', - 'hw_graphic' => '5', - 'hw_monitor' => '6', - 'hw_mouse' => '7', - 'late_dm' => '8', - 'netbios_workgroup' => '9', - 'nis_domain' => '10', - 'nis_servers' => '11', - 'sane_scanner' => '12', - 'scratch' => '13', - 'slxgrp' => '14', - 'start_alsasound' => '15', - 'start_atd' => '16', - 'start_cron' => '17', - 'start_dreshal' => '18', - 'start_ntp' => '19', - 'start_nfsv4' => '20', - 'start_printer' => '21', - 'start_samba' => '22', - 'start_snmp' => '23', - 'start_sshd' => '24', - 'start_syslog' => '25', - 'start_x' => '26', - 'start_xdmcp' => '27', - 'tex_enable' => '28', - 'timezone' => '29', - 'tvout' => '30', - 'vmware' => '31', + 'ramfs_fsmods' => '-4', + 'ramfs_miscmods' => '-3', + 'ramfs_nicmods' => '-2', + + 'automnt_dir' => '1', + 'automnt_src' => '2', + 'country' => '3', + 'dm_allow_shutdown' => '4', + 'hw_graphic' => '5', + 'hw_monitor' => '6', + 'hw_mouse' => '7', + 'late_dm' => '8', + 'netbios_workgroup' => '9', + 'nis_domain' => '10', + 'nis_servers' => '11', + 'sane_scanner' => '12', + 'scratch' => '13', + 'slxgrp' => '14', + 'start_alsasound' => '15', + 'start_atd' => '16', + 'start_cron' => '17', + 'start_dreshal' => '18', + 'start_ntp' => '19', + 'start_nfsv4' => '20', + 'start_printer' => '21', + 'start_samba' => '22', + 'start_snmp' => '23', + 'start_sshd' => '24', + 'start_syslog' => '25', + 'start_x' => '26', + 'start_xdmcp' => '27', + 'tex_enable' => '28', + 'timezone' => '29', + 'tvout' => '30', + 'vmware' => '31', }; ok( - $configDB->changeSystem(3, { attrs => $sys3Attrs } ), - 'attributes of system 3 have been set' + $configDB->changeSystem(3, { attrs => $sys3Attrs } ), + 'attributes of system 3 have been set' ); my $defaultClient = $configDB->fetchClientByID(0); my $defaultClientAttrs = { - # pretend the whole computer centre has been warped to London ;-) - 'timezone' => 'Europe/London', - # pretend we wanted to activate snmp globally (e.g. for testing) - 'start_snmp' => 'yes', + # pretend the whole computer centre has been warped to London ;-) + 'timezone' => 'Europe/London', + # pretend we wanted to activate snmp globally (e.g. for testing) + 'start_snmp' => 'yes', }; ok( - $configDB->changeClient(0, { attrs => $defaultClientAttrs } ), - 'attributes of default client have been set' + $configDB->changeClient(0, { attrs => $defaultClientAttrs } ), + 'attributes of default client have been set' ); # check merging of default attributes, the order should be: # default system attributes overruled by system attributes overruled by # default client attributes: my $shouldBeAttrs1 = { - 'ramfs_fsmods' => 'squashfs', - 'ramfs_miscmods' => undef, - 'ramfs_nicmods' => 'forcedeth e1000 r8169', - - 'automnt_dir' => undef, - 'automnt_src' => undef, - 'country' => 'de', - 'dm_allow_shutdown' => 'user', - 'hw_graphic' => undef, - 'hw_monitor' => undef, - 'hw_mouse' => undef, - 'late_dm' => 'no', - 'netbios_workgroup' => 'slx-network', - 'nis_domain' => undef, - 'nis_servers' => undef, - 'sane_scanner' => undef, - 'scratch' => undef, - 'slxgrp' => undef, - 'start_alsasound' => 'yes', - 'start_atd' => 'no', - 'start_cron' => 'no', - 'start_dreshal' => 'yes', - 'start_ntp' => 'initial', - 'start_nfsv4' => 'no', - 'start_printer' => 'no', - 'start_samba' => 'may', - 'start_snmp' => 'yes', - 'start_sshd' => 'yes', - 'start_syslog' => 'yes', - 'start_x' => 'no', - 'start_xdmcp' => '', - 'tex_enable' => 'no', - 'timezone' => 'Europe/London', - 'tvout' => 'no', - 'vmware' => 'no', + 'ramfs_fsmods' => 'squashfs', + 'ramfs_miscmods' => undef, + 'ramfs_nicmods' => 'forcedeth e1000 r8169', + + 'automnt_dir' => undef, + 'automnt_src' => undef, + 'country' => 'de', + 'dm_allow_shutdown' => 'user', + 'hw_graphic' => undef, + 'hw_monitor' => undef, + 'hw_mouse' => undef, + 'late_dm' => 'no', + 'netbios_workgroup' => 'slx-network', + 'nis_domain' => undef, + 'nis_servers' => undef, + 'sane_scanner' => undef, + 'scratch' => undef, + 'slxgrp' => undef, + 'start_alsasound' => 'yes', + 'start_atd' => 'no', + 'start_cron' => 'no', + 'start_dreshal' => 'yes', + 'start_ntp' => 'initial', + 'start_nfsv4' => 'no', + 'start_printer' => 'no', + 'start_samba' => 'may', + 'start_snmp' => 'yes', + 'start_sshd' => 'yes', + 'start_syslog' => 'yes', + 'start_x' => 'no', + 'start_xdmcp' => '', + 'tex_enable' => 'no', + 'timezone' => 'Europe/London', + 'tvout' => 'no', + 'vmware' => 'no', }; my $mergedSystem1 = $configDB->fetchSystemByID(1); ok( - $configDB->mergeDefaultAttributesIntoSystem($mergedSystem1), - 'merging default attributes into system 1' + $configDB->mergeDefaultAttributesIntoSystem($mergedSystem1), + 'merging default attributes into system 1' ); foreach my $key (sort keys %$shouldBeAttrs1) { - is( - $mergedSystem1->{attrs}->{$key}, $shouldBeAttrs1->{$key}, - "checking merged attribute $key for system 1" - ); + is( + $mergedSystem1->{attrs}->{$key}, $shouldBeAttrs1->{$key}, + "checking merged attribute $key for system 1" + ); } # check merging code for completeness (using all attributes): my $shouldBeAttrs3 = { - 'ramfs_fsmods' => '-4', - 'ramfs_miscmods' => '-3', - 'ramfs_nicmods' => '-2', - - 'automnt_dir' => '1', - 'automnt_src' => '2', - 'country' => '3', - 'dm_allow_shutdown' => '4', - 'hw_graphic' => '5', - 'hw_monitor' => '6', - 'hw_mouse' => '7', - 'late_dm' => '8', - 'netbios_workgroup' => '9', - 'nis_domain' => '10', - 'nis_servers' => '11', - 'sane_scanner' => '12', - 'scratch' => '13', - 'slxgrp' => '14', - 'start_alsasound' => '15', - 'start_atd' => '16', - 'start_cron' => '17', - 'start_dreshal' => '18', - 'start_ntp' => '19', - 'start_nfsv4' => '20', - 'start_printer' => '21', - 'start_samba' => '22', - 'start_snmp' => 'yes', - 'start_sshd' => '24', - 'start_syslog' => '25', - 'start_x' => '26', - 'start_xdmcp' => '27', - 'tex_enable' => '28', - 'timezone' => 'Europe/London', - 'tvout' => '30', - 'vmware' => '31', + 'ramfs_fsmods' => '-4', + 'ramfs_miscmods' => '-3', + 'ramfs_nicmods' => '-2', + + 'automnt_dir' => '1', + 'automnt_src' => '2', + 'country' => '3', + 'dm_allow_shutdown' => '4', + 'hw_graphic' => '5', + 'hw_monitor' => '6', + 'hw_mouse' => '7', + 'late_dm' => '8', + 'netbios_workgroup' => '9', + 'nis_domain' => '10', + 'nis_servers' => '11', + 'sane_scanner' => '12', + 'scratch' => '13', + 'slxgrp' => '14', + 'start_alsasound' => '15', + 'start_atd' => '16', + 'start_cron' => '17', + 'start_dreshal' => '18', + 'start_ntp' => '19', + 'start_nfsv4' => '20', + 'start_printer' => '21', + 'start_samba' => '22', + 'start_snmp' => 'yes', + 'start_sshd' => '24', + 'start_syslog' => '25', + 'start_x' => '26', + 'start_xdmcp' => '27', + 'tex_enable' => '28', + 'timezone' => 'Europe/London', + 'tvout' => '30', + 'vmware' => '31', }; my $mergedSystem3 = $configDB->fetchSystemByID(3); ok( - $configDB->mergeDefaultAttributesIntoSystem($mergedSystem3), - 'merging default attributes into system 3' + $configDB->mergeDefaultAttributesIntoSystem($mergedSystem3), + 'merging default attributes into system 3' ); foreach my $key (sort keys %$shouldBeAttrs3) { - is( - $mergedSystem3->{attrs}->{$key}, $shouldBeAttrs3->{$key}, - "checking merged attribute $key for system 3" - ); + is( + $mergedSystem3->{attrs}->{$key}, $shouldBeAttrs3->{$key}, + "checking merged attribute $key for system 3" + ); } # setup client / group relations my $group1 = $configDB->fetchGroupByID(1); my $group1Attrs = { - 'priority' => '50', - # this group of clients is connected via underwater cable ... - 'timezone' => 'America/New_York', - # ... and use a local scratch partition - 'scratch' => '/dev/sdd1', - # the following should be a noop (as that attribute is system-specific) -# 'ramfs_nicmods' => 'e1000', + 'priority' => '50', + # this group of clients is connected via underwater cable ... + 'timezone' => 'America/New_York', + # ... and use a local scratch partition + 'scratch' => '/dev/sdd1', + # the following should be a noop (as that attribute is system-specific) +# 'ramfs_nicmods' => 'e1000', }; ok( - $configDB->changeGroup(1, { attrs => $group1Attrs } ), - 'attributes of group 1 have been set' + $configDB->changeGroup(1, { attrs => $group1Attrs } ), + 'attributes of group 1 have been set' ); my $group3 = $configDB->fetchGroupByID(3); my $group3Attrs = { - 'priority' => '30', - # this specific client group is older and thus has a different scratch - 'scratch' => '/dev/hdd1', - 'vmware' => 'yes', + 'priority' => '30', + # this specific client group is older and thus has a different scratch + 'scratch' => '/dev/hdd1', + 'vmware' => 'yes', }; ok( - $configDB->changeGroup(3, { attrs => $group3Attrs } ), - 'attributes of group 3 have been set' + $configDB->changeGroup(3, { attrs => $group3Attrs } ), + 'attributes of group 3 have been set' ); my $client1 = $configDB->fetchClientByID(1); my $client1Attrs = { - # this specific client uses yet another local scratch partition - 'scratch' => '/dev/sdx3', + # this specific client uses yet another local scratch partition + 'scratch' => '/dev/sdx3', }; ok( - $configDB->changeClient(1, { attrs => $client1Attrs } ), - 'attributes of client 1 have been set' + $configDB->changeClient(1, { attrs => $client1Attrs } ), + 'attributes of client 1 have been set' ); ok( - $configDB->setGroupIDsOfClient(1, [1]), - 'group-IDs of client 1 have been set' + $configDB->setGroupIDsOfClient(1, [1]), + 'group-IDs of client 1 have been set' ); ok( - $configDB->setGroupIDsOfClient(3, []), - 'group-IDs of client 3 have been set' + $configDB->setGroupIDsOfClient(3, []), + 'group-IDs of client 3 have been set' ); # check merging of attributes into client, the order should be: # default client attributes overruled by group attributes (ordered by priority) # overruled by specific client attributes: $shouldBeAttrs1 = { - 'ramfs_fsmods' => undef, - 'ramfs_miscmods' => undef, - 'ramfs_nicmods' => undef, - - 'automnt_dir' => undef, - 'automnt_src' => undef, - 'country' => undef, - 'dm_allow_shutdown' => undef, - 'hw_graphic' => undef, - 'hw_monitor' => undef, - 'hw_mouse' => undef, - 'late_dm' => undef, - 'netbios_workgroup' => undef, - 'nis_domain' => undef, - 'nis_servers' => undef, - 'sane_scanner' => undef, - 'scratch' => '/dev/sdx3', - 'slxgrp' => undef, - 'start_alsasound' => undef, - 'start_atd' => undef, - 'start_cron' => undef, - 'start_dreshal' => undef, - 'start_ntp' => undef, - 'start_nfsv4' => undef, - 'start_printer' => undef, - 'start_samba' => undef, - 'start_snmp' => 'yes', - 'start_sshd' => undef, - 'start_syslog' => undef, - 'start_x' => undef, - 'start_xdmcp' => undef, - 'tex_enable' => undef, - 'timezone' => 'America/New_York', - 'tvout' => undef, - 'vmware' => undef, + 'ramfs_fsmods' => undef, + 'ramfs_miscmods' => undef, + 'ramfs_nicmods' => undef, + + 'automnt_dir' => undef, + 'automnt_src' => undef, + 'country' => undef, + 'dm_allow_shutdown' => undef, + 'hw_graphic' => undef, + 'hw_monitor' => undef, + 'hw_mouse' => undef, + 'late_dm' => undef, + 'netbios_workgroup' => undef, + 'nis_domain' => undef, + 'nis_servers' => undef, + 'sane_scanner' => undef, + 'scratch' => '/dev/sdx3', + 'slxgrp' => undef, + 'start_alsasound' => undef, + 'start_atd' => undef, + 'start_cron' => undef, + 'start_dreshal' => undef, + 'start_ntp' => undef, + 'start_nfsv4' => undef, + 'start_printer' => undef, + 'start_samba' => undef, + 'start_snmp' => 'yes', + 'start_sshd' => undef, + 'start_syslog' => undef, + 'start_x' => undef, + 'start_xdmcp' => undef, + 'tex_enable' => undef, + 'timezone' => 'America/New_York', + 'tvout' => undef, + 'vmware' => undef, }; my $mergedClient1 = $configDB->fetchClientByID(1); ok( - $configDB->mergeDefaultAndGroupAttributesIntoClient($mergedClient1), - 'merging default and group attributes into client 1' + $configDB->mergeDefaultAndGroupAttributesIntoClient($mergedClient1), + 'merging default and group attributes into client 1' ); foreach my $key (sort keys %$shouldBeAttrs1) { - is( - $mergedClient1->{attrs}->{$key}, $shouldBeAttrs1->{$key}, - "checking merged attribute $key for client 1" - ); + is( + $mergedClient1->{attrs}->{$key}, $shouldBeAttrs1->{$key}, + "checking merged attribute $key for client 1" + ); } $shouldBeAttrs3 = { - 'ramfs_fsmods' => undef, - 'ramfs_miscmods' => undef, - 'ramfs_nicmods' => undef, - - 'automnt_dir' => undef, - 'automnt_src' => undef, - 'country' => undef, - 'dm_allow_shutdown' => undef, - 'hw_graphic' => undef, - 'hw_monitor' => undef, - 'hw_mouse' => undef, - 'late_dm' => undef, - 'netbios_workgroup' => undef, - 'nis_domain' => undef, - 'nis_servers' => undef, - 'sane_scanner' => undef, - 'scratch' => undef, - 'slxgrp' => undef, - 'start_alsasound' => undef, - 'start_atd' => undef, - 'start_cron' => undef, - 'start_dreshal' => undef, - 'start_ntp' => undef, - 'start_nfsv4' => undef, - 'start_printer' => undef, - 'start_samba' => undef, - 'start_snmp' => 'yes', - 'start_sshd' => undef, - 'start_syslog' => undef, - 'start_x' => undef, - 'start_xdmcp' => undef, - 'tex_enable' => undef, - 'timezone' => 'Europe/London', - 'tvout' => undef, - 'vmware' => undef, + 'ramfs_fsmods' => undef, + 'ramfs_miscmods' => undef, + 'ramfs_nicmods' => undef, + + 'automnt_dir' => undef, + 'automnt_src' => undef, + 'country' => undef, + 'dm_allow_shutdown' => undef, + 'hw_graphic' => undef, + 'hw_monitor' => undef, + 'hw_mouse' => undef, + 'late_dm' => undef, + 'netbios_workgroup' => undef, + 'nis_domain' => undef, + 'nis_servers' => undef, + 'sane_scanner' => undef, + 'scratch' => undef, + 'slxgrp' => undef, + 'start_alsasound' => undef, + 'start_atd' => undef, + 'start_cron' => undef, + 'start_dreshal' => undef, + 'start_ntp' => undef, + 'start_nfsv4' => undef, + 'start_printer' => undef, + 'start_samba' => undef, + 'start_snmp' => 'yes', + 'start_sshd' => undef, + 'start_syslog' => undef, + 'start_x' => undef, + 'start_xdmcp' => undef, + 'tex_enable' => undef, + 'timezone' => 'Europe/London', + 'tvout' => undef, + 'vmware' => undef, }; # remove all attributes from client 3 @@ -364,314 +364,314 @@ $configDB->changeClient(3, { attrs => {} } ); my $mergedClient3 = $configDB->fetchClientByID(3); ok( - $configDB->mergeDefaultAndGroupAttributesIntoClient($mergedClient3), - 'merging default and group attributes into client 3' + $configDB->mergeDefaultAndGroupAttributesIntoClient($mergedClient3), + 'merging default and group attributes into client 3' ); foreach my $key (sort keys %$shouldBeAttrs1) { - is( - $mergedClient3->{attrs}->{$key}, $shouldBeAttrs3->{$key}, - "checking merged attribute $key for client 3" - ); + is( + $mergedClient3->{attrs}->{$key}, $shouldBeAttrs3->{$key}, + "checking merged attribute $key for client 3" + ); } # now associate default client with group 3 and try again ok( - $configDB->setGroupIDsOfClient(0, [3]), - 'group-IDs of default client have been set' + $configDB->setGroupIDsOfClient(0, [3]), + 'group-IDs of default client have been set' ); $shouldBeAttrs1 = { - 'ramfs_fsmods' => undef, - 'ramfs_miscmods' => undef, - 'ramfs_nicmods' => undef, - - 'automnt_dir' => undef, - 'automnt_src' => undef, - 'country' => undef, - 'dm_allow_shutdown' => undef, - 'hw_graphic' => undef, - 'hw_monitor' => undef, - 'hw_mouse' => undef, - 'late_dm' => undef, - 'netbios_workgroup' => undef, - 'nis_domain' => undef, - 'nis_servers' => undef, - 'sane_scanner' => undef, - 'scratch' => '/dev/sdx3', - 'slxgrp' => undef, - 'start_alsasound' => undef, - 'start_atd' => undef, - 'start_cron' => undef, - 'start_dreshal' => undef, - 'start_ntp' => undef, - 'start_nfsv4' => undef, - 'start_printer' => undef, - 'start_samba' => undef, - 'start_snmp' => 'yes', - 'start_sshd' => undef, - 'start_syslog' => undef, - 'start_x' => undef, - 'start_xdmcp' => undef, - 'tex_enable' => undef, - 'timezone' => 'America/New_York', - 'tvout' => undef, - 'vmware' => 'yes', + 'ramfs_fsmods' => undef, + 'ramfs_miscmods' => undef, + 'ramfs_nicmods' => undef, + + 'automnt_dir' => undef, + 'automnt_src' => undef, + 'country' => undef, + 'dm_allow_shutdown' => undef, + 'hw_graphic' => undef, + 'hw_monitor' => undef, + 'hw_mouse' => undef, + 'late_dm' => undef, + 'netbios_workgroup' => undef, + 'nis_domain' => undef, + 'nis_servers' => undef, + 'sane_scanner' => undef, + 'scratch' => '/dev/sdx3', + 'slxgrp' => undef, + 'start_alsasound' => undef, + 'start_atd' => undef, + 'start_cron' => undef, + 'start_dreshal' => undef, + 'start_ntp' => undef, + 'start_nfsv4' => undef, + 'start_printer' => undef, + 'start_samba' => undef, + 'start_snmp' => 'yes', + 'start_sshd' => undef, + 'start_syslog' => undef, + 'start_x' => undef, + 'start_xdmcp' => undef, + 'tex_enable' => undef, + 'timezone' => 'America/New_York', + 'tvout' => undef, + 'vmware' => 'yes', }; $mergedClient1 = $configDB->fetchClientByID(1); ok( - $configDB->mergeDefaultAndGroupAttributesIntoClient($mergedClient1), - 'merging default and group attributes into client 1' + $configDB->mergeDefaultAndGroupAttributesIntoClient($mergedClient1), + 'merging default and group attributes into client 1' ); foreach my $key (sort keys %$shouldBeAttrs1) { - is( - $mergedClient1->{attrs}->{$key}, $shouldBeAttrs1->{$key}, - "checking merged attribute $key for client 1" - ); + is( + $mergedClient1->{attrs}->{$key}, $shouldBeAttrs1->{$key}, + "checking merged attribute $key for client 1" + ); } $shouldBeAttrs3 = { - 'ramfs_fsmods' => undef, - 'ramfs_miscmods' => undef, - 'ramfs_nicmods' => undef, - - 'automnt_dir' => undef, - 'automnt_src' => undef, - 'country' => undef, - 'dm_allow_shutdown' => undef, - 'hw_graphic' => undef, - 'hw_monitor' => undef, - 'hw_mouse' => undef, - 'late_dm' => undef, - 'netbios_workgroup' => undef, - 'nis_domain' => undef, - 'nis_servers' => undef, - 'sane_scanner' => undef, - 'scratch' => '/dev/hdd1', - 'slxgrp' => undef, - 'start_alsasound' => undef, - 'start_atd' => undef, - 'start_cron' => undef, - 'start_dreshal' => undef, - 'start_ntp' => undef, - 'start_nfsv4' => undef, - 'start_printer' => undef, - 'start_samba' => undef, - 'start_snmp' => 'yes', - 'start_sshd' => undef, - 'start_syslog' => undef, - 'start_x' => undef, - 'start_xdmcp' => undef, - 'tex_enable' => undef, - 'timezone' => 'Europe/London', - 'tvout' => undef, - 'vmware' => 'yes', + 'ramfs_fsmods' => undef, + 'ramfs_miscmods' => undef, + 'ramfs_nicmods' => undef, + + 'automnt_dir' => undef, + 'automnt_src' => undef, + 'country' => undef, + 'dm_allow_shutdown' => undef, + 'hw_graphic' => undef, + 'hw_monitor' => undef, + 'hw_mouse' => undef, + 'late_dm' => undef, + 'netbios_workgroup' => undef, + 'nis_domain' => undef, + 'nis_servers' => undef, + 'sane_scanner' => undef, + 'scratch' => '/dev/hdd1', + 'slxgrp' => undef, + 'start_alsasound' => undef, + 'start_atd' => undef, + 'start_cron' => undef, + 'start_dreshal' => undef, + 'start_ntp' => undef, + 'start_nfsv4' => undef, + 'start_printer' => undef, + 'start_samba' => undef, + 'start_snmp' => 'yes', + 'start_sshd' => undef, + 'start_syslog' => undef, + 'start_x' => undef, + 'start_xdmcp' => undef, + 'tex_enable' => undef, + 'timezone' => 'Europe/London', + 'tvout' => undef, + 'vmware' => 'yes', }; $mergedClient3 = $configDB->fetchClientByID(3); ok( - $configDB->mergeDefaultAndGroupAttributesIntoClient($mergedClient3), - 'merging default and group attributes into client 3' + $configDB->mergeDefaultAndGroupAttributesIntoClient($mergedClient3), + 'merging default and group attributes into client 3' ); foreach my $key (sort keys %$shouldBeAttrs1) { - is( - $mergedClient3->{attrs}->{$key}, $shouldBeAttrs3->{$key}, - "checking merged attribute $key for client 3" - ); + is( + $mergedClient3->{attrs}->{$key}, $shouldBeAttrs3->{$key}, + "checking merged attribute $key for client 3" + ); } # finally we merge systems into clients and check the outcome of that my $fullMerge11 = dclone($mergedClient1); ok( - mergeAttributes($fullMerge11, $mergedSystem1), - 'merging system 1 into client 1' + mergeAttributes($fullMerge11, $mergedSystem1), + 'merging system 1 into client 1' ); my $shouldBeAttrs11 = { - 'ramfs_fsmods' => 'squashfs', - 'ramfs_miscmods' => undef, - 'ramfs_nicmods' => 'forcedeth e1000 r8169', - - 'automnt_dir' => undef, - 'automnt_src' => undef, - 'country' => 'de', - 'dm_allow_shutdown' => 'user', - 'hw_graphic' => undef, - 'hw_monitor' => undef, - 'hw_mouse' => undef, - 'late_dm' => 'no', - 'netbios_workgroup' => 'slx-network', - 'nis_domain' => undef, - 'nis_servers' => undef, - 'sane_scanner' => undef, - 'scratch' => '/dev/sdx3', - 'slxgrp' => undef, - 'start_alsasound' => 'yes', - 'start_atd' => 'no', - 'start_cron' => 'no', - 'start_dreshal' => 'yes', - 'start_ntp' => 'initial', - 'start_nfsv4' => 'no', - 'start_printer' => 'no', - 'start_samba' => 'may', - 'start_snmp' => 'yes', - 'start_sshd' => 'yes', - 'start_syslog' => 'yes', - 'start_x' => 'no', - 'start_xdmcp' => '', - 'tex_enable' => 'no', - 'timezone' => 'America/New_York', - 'tvout' => 'no', - 'vmware' => 'yes', + 'ramfs_fsmods' => 'squashfs', + 'ramfs_miscmods' => undef, + 'ramfs_nicmods' => 'forcedeth e1000 r8169', + + 'automnt_dir' => undef, + 'automnt_src' => undef, + 'country' => 'de', + 'dm_allow_shutdown' => 'user', + 'hw_graphic' => undef, + 'hw_monitor' => undef, + 'hw_mouse' => undef, + 'late_dm' => 'no', + 'netbios_workgroup' => 'slx-network', + 'nis_domain' => undef, + 'nis_servers' => undef, + 'sane_scanner' => undef, + 'scratch' => '/dev/sdx3', + 'slxgrp' => undef, + 'start_alsasound' => 'yes', + 'start_atd' => 'no', + 'start_cron' => 'no', + 'start_dreshal' => 'yes', + 'start_ntp' => 'initial', + 'start_nfsv4' => 'no', + 'start_printer' => 'no', + 'start_samba' => 'may', + 'start_snmp' => 'yes', + 'start_sshd' => 'yes', + 'start_syslog' => 'yes', + 'start_x' => 'no', + 'start_xdmcp' => '', + 'tex_enable' => 'no', + 'timezone' => 'America/New_York', + 'tvout' => 'no', + 'vmware' => 'yes', }; foreach my $key (sort keys %$shouldBeAttrs11) { - is( - $fullMerge11->{attrs}->{$key}, $shouldBeAttrs11->{$key}, - "checking merged attribute $key for client 1 / system 1" - ); + is( + $fullMerge11->{attrs}->{$key}, $shouldBeAttrs11->{$key}, + "checking merged attribute $key for client 1 / system 1" + ); } my $fullMerge31 = dclone($mergedClient3); ok( - mergeAttributes($fullMerge31, $mergedSystem1), - 'merging system 1 into client 3' + mergeAttributes($fullMerge31, $mergedSystem1), + 'merging system 1 into client 3' ); my $shouldBeAttrs31 = { - 'ramfs_fsmods' => 'squashfs', - 'ramfs_miscmods' => undef, - 'ramfs_nicmods' => 'forcedeth e1000 r8169', - - 'automnt_dir' => undef, - 'automnt_src' => undef, - 'country' => 'de', - 'dm_allow_shutdown' => 'user', - 'hw_graphic' => undef, - 'hw_monitor' => undef, - 'hw_mouse' => undef, - 'late_dm' => 'no', - 'netbios_workgroup' => 'slx-network', - 'nis_domain' => undef, - 'nis_servers' => undef, - 'sane_scanner' => undef, - 'scratch' => '/dev/hdd1', - 'slxgrp' => undef, - 'start_alsasound' => 'yes', - 'start_atd' => 'no', - 'start_cron' => 'no', - 'start_dreshal' => 'yes', - 'start_ntp' => 'initial', - 'start_nfsv4' => 'no', - 'start_printer' => 'no', - 'start_samba' => 'may', - 'start_snmp' => 'yes', - 'start_sshd' => 'yes', - 'start_syslog' => 'yes', - 'start_x' => 'no', - 'start_xdmcp' => '', - 'tex_enable' => 'no', - 'timezone' => 'Europe/London', - 'tvout' => 'no', - 'vmware' => 'yes', + 'ramfs_fsmods' => 'squashfs', + 'ramfs_miscmods' => undef, + 'ramfs_nicmods' => 'forcedeth e1000 r8169', + + 'automnt_dir' => undef, + 'automnt_src' => undef, + 'country' => 'de', + 'dm_allow_shutdown' => 'user', + 'hw_graphic' => undef, + 'hw_monitor' => undef, + 'hw_mouse' => undef, + 'late_dm' => 'no', + 'netbios_workgroup' => 'slx-network', + 'nis_domain' => undef, + 'nis_servers' => undef, + 'sane_scanner' => undef, + 'scratch' => '/dev/hdd1', + 'slxgrp' => undef, + 'start_alsasound' => 'yes', + 'start_atd' => 'no', + 'start_cron' => 'no', + 'start_dreshal' => 'yes', + 'start_ntp' => 'initial', + 'start_nfsv4' => 'no', + 'start_printer' => 'no', + 'start_samba' => 'may', + 'start_snmp' => 'yes', + 'start_sshd' => 'yes', + 'start_syslog' => 'yes', + 'start_x' => 'no', + 'start_xdmcp' => '', + 'tex_enable' => 'no', + 'timezone' => 'Europe/London', + 'tvout' => 'no', + 'vmware' => 'yes', }; foreach my $key (sort keys %$shouldBeAttrs31) { - is( - $fullMerge31->{attrs}->{$key}, $shouldBeAttrs31->{$key}, - "checking merged attribute $key for client 3 / system 1" - ); + is( + $fullMerge31->{attrs}->{$key}, $shouldBeAttrs31->{$key}, + "checking merged attribute $key for client 3 / system 1" + ); } my $fullMerge13 = dclone($mergedClient1); ok( - mergeAttributes($fullMerge13, $mergedSystem3), - 'merging system 3 into client 1' + mergeAttributes($fullMerge13, $mergedSystem3), + 'merging system 3 into client 1' ); my $shouldBeAttrs13 = { - 'ramfs_fsmods' => '-4', - 'ramfs_miscmods' => '-3', - 'ramfs_nicmods' => '-2', - - 'automnt_dir' => '1', - 'automnt_src' => '2', - 'country' => '3', - 'dm_allow_shutdown' => '4', - 'hw_graphic' => '5', - 'hw_monitor' => '6', - 'hw_mouse' => '7', - 'late_dm' => '8', - 'netbios_workgroup' => '9', - 'nis_domain' => '10', - 'nis_servers' => '11', - 'sane_scanner' => '12', - 'scratch' => '/dev/sdx3', - 'slxgrp' => '14', - 'start_alsasound' => '15', - 'start_atd' => '16', - 'start_cron' => '17', - 'start_dreshal' => '18', - 'start_ntp' => '19', - 'start_nfsv4' => '20', - 'start_printer' => '21', - 'start_samba' => '22', - 'start_snmp' => 'yes', - 'start_sshd' => '24', - 'start_syslog' => '25', - 'start_x' => '26', - 'start_xdmcp' => '27', - 'tex_enable' => '28', - 'timezone' => 'America/New_York', - 'tvout' => '30', - 'vmware' => 'yes', + 'ramfs_fsmods' => '-4', + 'ramfs_miscmods' => '-3', + 'ramfs_nicmods' => '-2', + + 'automnt_dir' => '1', + 'automnt_src' => '2', + 'country' => '3', + 'dm_allow_shutdown' => '4', + 'hw_graphic' => '5', + 'hw_monitor' => '6', + 'hw_mouse' => '7', + 'late_dm' => '8', + 'netbios_workgroup' => '9', + 'nis_domain' => '10', + 'nis_servers' => '11', + 'sane_scanner' => '12', + 'scratch' => '/dev/sdx3', + 'slxgrp' => '14', + 'start_alsasound' => '15', + 'start_atd' => '16', + 'start_cron' => '17', + 'start_dreshal' => '18', + 'start_ntp' => '19', + 'start_nfsv4' => '20', + 'start_printer' => '21', + 'start_samba' => '22', + 'start_snmp' => 'yes', + 'start_sshd' => '24', + 'start_syslog' => '25', + 'start_x' => '26', + 'start_xdmcp' => '27', + 'tex_enable' => '28', + 'timezone' => 'America/New_York', + 'tvout' => '30', + 'vmware' => 'yes', }; foreach my $key (sort keys %$shouldBeAttrs13) { - is( - $fullMerge13->{attrs}->{$key}, $shouldBeAttrs13->{$key}, - "checking merged attribute $key for client 1 / system 3" - ); + is( + $fullMerge13->{attrs}->{$key}, $shouldBeAttrs13->{$key}, + "checking merged attribute $key for client 1 / system 3" + ); } my $fullMerge33 = dclone($mergedClient3); ok( - mergeAttributes($fullMerge33, $mergedSystem3), - 'merging system 3 into client 3' + mergeAttributes($fullMerge33, $mergedSystem3), + 'merging system 3 into client 3' ); my $shouldBeAttrs33 = { - 'ramfs_fsmods' => '-4', - 'ramfs_miscmods' => '-3', - 'ramfs_nicmods' => '-2', - - 'automnt_dir' => '1', - 'automnt_src' => '2', - 'country' => '3', - 'dm_allow_shutdown' => '4', - 'hw_graphic' => '5', - 'hw_monitor' => '6', - 'hw_mouse' => '7', - 'late_dm' => '8', - 'netbios_workgroup' => '9', - 'nis_domain' => '10', - 'nis_servers' => '11', - 'sane_scanner' => '12', - 'scratch' => '/dev/hdd1', - 'slxgrp' => '14', - 'start_alsasound' => '15', - 'start_atd' => '16', - 'start_cron' => '17', - 'start_dreshal' => '18', - 'start_ntp' => '19', - 'start_nfsv4' => '20', - 'start_printer' => '21', - 'start_samba' => '22', - 'start_snmp' => 'yes', - 'start_sshd' => '24', - 'start_syslog' => '25', - 'start_x' => '26', - 'start_xdmcp' => '27', - 'tex_enable' => '28', - 'timezone' => 'Europe/London', - 'tvout' => '30', - 'vmware' => 'yes', + 'ramfs_fsmods' => '-4', + 'ramfs_miscmods' => '-3', + 'ramfs_nicmods' => '-2', + + 'automnt_dir' => '1', + 'automnt_src' => '2', + 'country' => '3', + 'dm_allow_shutdown' => '4', + 'hw_graphic' => '5', + 'hw_monitor' => '6', + 'hw_mouse' => '7', + 'late_dm' => '8', + 'netbios_workgroup' => '9', + 'nis_domain' => '10', + 'nis_servers' => '11', + 'sane_scanner' => '12', + 'scratch' => '/dev/hdd1', + 'slxgrp' => '14', + 'start_alsasound' => '15', + 'start_atd' => '16', + 'start_cron' => '17', + 'start_dreshal' => '18', + 'start_ntp' => '19', + 'start_nfsv4' => '20', + 'start_printer' => '21', + 'start_samba' => '22', + 'start_snmp' => 'yes', + 'start_sshd' => '24', + 'start_syslog' => '25', + 'start_x' => '26', + 'start_xdmcp' => '27', + 'tex_enable' => '28', + 'timezone' => 'Europe/London', + 'tvout' => '30', + 'vmware' => 'yes', }; foreach my $key (sort keys %$shouldBeAttrs33) { - is( - $fullMerge33->{attrs}->{$key}, $shouldBeAttrs33->{$key}, - "checking merged attribute $key for client 3 / system 3" - ); + is( + $fullMerge33->{attrs}->{$key}, $shouldBeAttrs33->{$key}, + "checking merged attribute $key for client 3 / system 3" + ); } $configDB->disconnect(); diff --git a/config-db/t/29-transaction.t b/config-db/t/29-transaction.t index 2088a16c..1f1566bf 100644 --- a/config-db/t/29-transaction.t +++ b/config-db/t/29-transaction.t @@ -30,7 +30,7 @@ my @clients2 = $configDB->fetchClientByFilter(); my @groups2 = $configDB->fetchGroupByFilter(); is( - scalar @vendorOSes2, scalar @vendorOSes, "should still have all vendor-OSes" + scalar @vendorOSes2, scalar @vendorOSes, "should still have all vendor-OSes" ); is(scalar @exports2, scalar @exports, "should still have all exports"); is(scalar @systems2, scalar @systems, "should still have all systems"); diff --git a/config-db/t/run-all-tests.pl b/config-db/t/run-all-tests.pl index c082052d..4ae59a7d 100755 --- a/config-db/t/run-all-tests.pl +++ b/config-db/t/run-all-tests.pl @@ -28,8 +28,8 @@ $Test::Harness::Verbose = 1 if $openslxConfig{'verbose-level'}; # remove the test-db if it already exists my $metaDB = OpenSLX::MetaDB::SQLite->new(); if ($metaDB->databaseExists()) { - print "removing leftovers of slx-test-db\n"; - $metaDB->dropDatabase(); + print "removing leftovers of slx-test-db\n"; + $metaDB->dropDatabase(); } runtests(glob("*.t")); |