source: trunk/LATMOS-Accounts/t/25_la_synchro.t @ 2380

Last change on this file since 2380 was 1071, checked in by nanardon, 12 years ago
  • rename options() to config() to clarify its role
  • Property svn:keywords set to Id Rev
File size: 1.9 KB
Line 
1use strict;
2use warnings;
3use Test::More tests => 15;
4use File::Temp;
5use File::Path;
6use Config::IniFiles;
7
8use_ok('LATMOS::Accounts::Synchro');
9use_ok('LATMOS::Accounts');
10
11my $workdir = File::Temp::tempdir();
12
13my $config = Config::IniFiles->new();
14
15$config->AddSection('source');
16$config->newval('source', 'type', 'unix');
17$config->newval('source', 'use_shadow', 1);
18$config->AddSection('dest');
19$config->newval('dest', 'type', 'unix');
20$config->newval('dest', 'use_shadow', 1);
21
22foreach (qw(passwd shadow group gshadow)) {
23    system('cp', "testdata/synchro/dest/$_", "$workdir/$_");
24    $config->newval('source', $_, "testdata/synchro/source/$_");
25    $config->newval('dest', $_, "$workdir/$_");
26}
27
28ok($config->WriteConfig("$workdir/latmos-accounts.ini"), "can write config file for test");
29
30diag("Write test done in $workdir/");
31
32isa_ok(
33    my $accounts = LATMOS::Accounts->new($workdir),
34    'LATMOS::Accounts'
35);
36
37ok($accounts->base('source'), "can get source base");
38ok($accounts->base('dest'),   "can get dest   base");
39
40my $synchro = LATMOS::Accounts::Synchro->new(
41    $accounts->base('source'), $accounts->base('dest'),
42    state_file => "$workdir/status.ini",
43);
44
45isa_ok($synchro, 'LATMOS::Accounts::Synchro');
46
47ok($synchro->process, "process get succefull");
48
49ok(my $unixb = LATMOS::Accounts::Bases->new(
50        'unix',
51        {
52        params => {
53            passwd  => "$workdir/passwd",
54            shadow  => "$workdir/shadow",
55            group   => "$workdir/group",
56            gshadow => "$workdir/gshadow",
57        }
58        }
59    ), "Can get unix base");
60isa_ok($unixb, 'LATMOS::Accounts::Bases::Unix');
61ok($unixb->load,   "Can load unix base");
62
63{
64ok(my $user =  $unixb->get_object('user', 'bin'),  "Can get bin user");
65is($user->get_c_field('homeDirectory'), '/bin', 'Can get homeDirectory directory');
66}
67{
68ok(my $user =  $unixb->get_object('user', 'adm'),  "Can get adm user");
69is($user->get_field('gecos'), 'adm', 'Can get home directory');
70}
71
72rmtree($workdir);
Note: See TracBrowser for help on using the repository browser.