source: LATMOS-Accounts/t/25_la_synchro.t @ 861

Last change on this file since 861 was 861, checked in by nanardon, 13 years ago
  • reimport missing files from previous svn
  • 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        passwd  => "$workdir/passwd",
52        shadow  => "$workdir/shadow",
53        group   => "$workdir/group",
54        gshadow => "$workdir/gshadow",
55    ), "Can get unix base");
56isa_ok($unixb, 'LATMOS::Accounts::Bases::Unix');
57ok($unixb->load,   "Can load unix base");
58
59{
60ok(my $user =  $unixb->get_object('user', 'bin'),  "Can get bin user");
61is($user->get_c_field('homeDirectory'), '/bin', 'Can get homeDirectory directory');
62}
63{
64ok(my $user =  $unixb->get_object('user', 'adm'),  "Can get adm user");
65is($user->get_field('gecos'), 'adm', 'Can get home directory');
66}
67
68rmtree($workdir);
Note: See TracBrowser for help on using the repository browser.