source: trunk/LATMOS-Accounts/live-test/10_sql.t @ 1251

Last change on this file since 1251 was 1031, checked in by nanardon, 12 years ago
  • more test for sql base
  • Property svn:keywords set to Id
File size: 2.8 KB
Line 
1# -*- indent-tabs-mode: nil; tab-width: 4; -*-
2# vim:ft=perl:et:sw=4
3# $Id$
4
5use strict;
6use warnings;
7use Test::More;
8use FindBin qw($Bin);
9
10require "$Bin/common.pl";
11eval "require '$Bin/config.pl'";
12
13if ($@) {
14    plan skip_all => 'no config found' if ($@);
15} elsif (!$LA::T::SQLBASE) {
16    plan skip_all => 'No SQL base defined';
17} else {
18    plan tests => 32; # Number of test
19}
20
21use_ok('LATMOS::Accounts');
22use_ok('LATMOS::Accounts::Bases::Sql');
23
24ok(my $la = LATMOS::Accounts->new(undef, noacl => 1), "Can get LATMOS::Accounts");
25ok(my $base = $la->base($LA::T::SQLBASE), "can get SQL base $LA::T::SQLBASE");
26
27{ # test: user
28my $oid = genid();
29
30use_ok('LATMOS::Accounts::Bases::Sql::User');
31ok($base->create_c_object('user', $oid,
32    sn => "snUser",
33    givenName => "givenNameUser",
34    ), "Can create user $oid");
35ok(my $obj = $base->get_object('user', $oid), "user $oid is actually deleted");
36is($obj->get_attributes('sn'), "snUser");
37
38my $passwd = genid();
39ok($obj->set_password($passwd), "Can set password");
40ok($base->authenticate_user($oid, $passwd), "can authenticate user");
41ok(!$base->authenticate_user($oid, '----'),
42    "don't authenticate with invalid password");
43
44ok($base->delete_object('user', $oid), "Can delete user $oid");
45ok(!$base->get_object('user', $oid), "user $oid is actually deleted");
46}
47
48
49{ # test: group
50my $oid = genid();
51
52use_ok('LATMOS::Accounts::Bases::Sql::Group');
53ok($base->create_c_object('group', $oid,
54    description => 'Group Test'
55), "Can create group $oid");
56ok(my $obj = $base->get_object('group', $oid), "group $oid is actually deleted");
57is($obj->get_attributes('description'), "Group Test");
58
59ok($base->delete_object('group', $oid), "Can delete group $oid");
60ok(!$base->get_object('group', $oid), "group $oid is actually deleted");
61}
62
63{ # test: nethost
64my $oid = genid();
65
66use_ok('LATMOS::Accounts::Bases::Sql::Nethost');
67ok($base->create_c_object('nethost', $oid,
68    description => 'Nethost Test',
69    ip => '255.255.255.255', # widely improbable to conflict with existing one
70), "Can create nethost $oid");
71ok(my $obj = $base->get_object('nethost', $oid), "nethost $oid is actually deleted");
72is($obj->get_attributes('description'), "Nethost Test");
73is($obj->get_attributes('ip'), '255.255.255.255');
74
75ok($base->delete_object('nethost', $oid), "Can delete nethost $oid");
76ok(!$base->get_object('nethost', $oid), "nethost $oid is actually deleted");
77}
78
79{ # test: netzone
80my $oid = genid();
81
82use_ok('LATMOS::Accounts::Bases::Sql::Netzone');
83ok($base->create_c_object('netzone', $oid,
84    description => 'Netzone Test',
85    type => 'dhcp',
86), "Can create netzone $oid");
87ok(my $obj = $base->get_object('netzone', $oid), "netzone $oid is actually deleted");
88is($obj->get_attributes('description'), "Netzone Test");
89
90ok($base->delete_object('netzone', $oid), "Can delete netzone $oid");
91ok(!$base->get_object('netzone', $oid), "netzone $oid is actually deleted");
92}
Note: See TracBrowser for help on using the repository browser.