1 | use strict; |
---|
2 | use warnings; |
---|
3 | use Test::More tests => 25; |
---|
4 | |
---|
5 | use_ok('LATMOS::Accounts::Bases'); |
---|
6 | use_ok('LATMOS::Accounts::Bases::Objects'); |
---|
7 | use_ok('LATMOS::Accounts::Bases::Dummy'); |
---|
8 | use_ok('LATMOS::Accounts::Bases::Dummy::User'); |
---|
9 | |
---|
10 | ok(my $dummyb = LATMOS::Accounts::Bases->new('dummy'), "Can get dummy base"); |
---|
11 | isa_ok($dummyb, 'LATMOS::Accounts::Bases'); |
---|
12 | isa_ok($dummyb, 'LATMOS::Accounts::Bases::Dummy'); |
---|
13 | |
---|
14 | ok(my $user = $dummyb->get_object('user', 'foo'), "Can get user object"); |
---|
15 | isa_ok($user, 'LATMOS::Accounts::Bases::Objects'); |
---|
16 | isa_ok($user, 'LATMOS::Accounts::Bases::Dummy::User'); |
---|
17 | |
---|
18 | ok(eq_set( |
---|
19 | [ $dummyb->list_canonical_fields('user') ], |
---|
20 | [qw( username homeDirectory shell gecos uidNumber gidNumber ) ], |
---|
21 | ), "Can get canonicals fields"); |
---|
22 | is( $dummyb->attribute('user', 'homeDirectory')->iname, "home", "can call get_fields_name"); |
---|
23 | ok(!$dummyb->is_transactionnal, 'Dummy driver is not transactionnal'); |
---|
24 | |
---|
25 | ok($dummyb->create_c_object( |
---|
26 | 'user', 'toto', |
---|
27 | homeDirectory => '/home/toto', |
---|
28 | ), "Can create object"); |
---|
29 | ok(!$dummyb->create_c_object('user', '1toto'), "Can't create object with wrong id"); |
---|
30 | |
---|
31 | ok(my $tuser = $dummyb->get_object('user', 'toto'), 'Can get user'); |
---|
32 | is($tuser->id, 'toto', 'Can get user id'); |
---|
33 | is($tuser->get_attributes('homeDirectory'), '/home/toto', 'Can get homeDirectory'); |
---|
34 | |
---|
35 | |
---|
36 | # Testing queryformat |
---|
37 | is($tuser->queryformat('%{username}'), 'toto', 'qf %{username}'); |
---|
38 | is($tuser->queryformat('%{?username:IS}'), 'IS', 'qf %{?username}'); |
---|
39 | is($tuser->queryformat('%{?gidNumber:IS}'), '', 'qf %{?gidNumber}'); |
---|
40 | is($tuser->queryformat('%{?!username:IS}'), '', 'qf %{?!username}'); |
---|
41 | is($tuser->queryformat('%{?!gidNumber:IS NOT}'), 'IS NOT', 'qf %{?!gidNumber}'); |
---|
42 | is($tuser->queryformat('%{?homeDirectory:%{username}}'), 'toto', 'qf %{?username:%{}}'); |
---|
43 | is($tuser->queryformat('%{?homeDirectory:%{?username:IS}}'), 'IS', 'qf %{?username:%{?:IS}}'); |
---|