Changeset 13 for LATMOS-Accounts


Ignore:
Timestamp:
03/02/09 22:02:23 (15 years ago)
Author:
nanardon
Message:
  • add set/get functions to unix objects
Location:
LATMOS-Accounts
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Unix.pm

    r10 r13  
    5454} 
    5555 
     56sub _canonicals_fields { 
     57    my ($self, $type) = @_; 
     58    $type = lc($type); 
     59    { 
     60        user => { 
     61            uidNumber       => 'uid', 
     62            gidNumber       => 'gid', 
     63            gecos           => 'gecos', 
     64            homeDirectory   => 'home', 
     65            loginShell      => 'shell', 
     66            userPassword    => ($self->{use_shadow} ? 'spassword' : 'password'), 
     67        }, 
     68        group => { 
     69            gidNumber       => 'gid', 
     70            memberUID       => 'user_list', 
     71        }, 
     72    }->{$type} 
     73} 
     74 
     75sub list_canonicals_fields { 
     76    my ($self, $type) = @_; 
     77    keys %{ $self->_canonicals_fields($type) || {} } 
     78} 
     79 
     80sub get_field_name { 
     81    my ($self, $type, $cfield) = @_; 
     82    ($self->_canonicals_fields($type) || {})->{$cfield} 
     83} 
     84 
     85 
    5686my @password_fields = qw(account password uid gid gecos home shell); 
    5787my @shadow_fields =   qw(account spassword last_changed before_ch after_ch exp_warn exp_disable disable res); 
  • LATMOS-Accounts/t/11_bases_unix.t

    r10 r13  
    11use strict; 
    22use warnings; 
    3 use Test::More tests =>  8; 
     3use Test::More tests => 14; 
    44use File::Temp; 
    55 
     
    77use_ok('LATMOS::Accounts::Bases::Objects'); 
    88use_ok('LATMOS::Accounts::Bases::Unix'); 
     9use_ok('LATMOS::Accounts::Bases::Unix::User'); 
     10use_ok('LATMOS::Accounts::Bases::Unix::Group'); 
    911 
    1012my $dir = File::Temp::tempdir; 
     
    2325isa_ok($unixb, 'LATMOS::Accounts::Bases'); 
    2426isa_ok($unixb, 'LATMOS::Accounts::Bases::Unix'); 
     27ok($unixb->load,   "Can load unix base"); 
    2528 
    26 ok($unixb->load,   "Can load unix base"); 
     29is( $unixb->get_field_name('user', 'homeDirectory'), "home", "can call get_fields_name"); 
     30 
     31ok(my $user =  $unixb->get_object('user', 'root'),  "Can get root user"); 
     32ok(my $group = $unixb->get_object('group', 'root'), "Can get root group"); 
     33 
     34is($user->get_c_field('homeDirectory'), '/root', 'Can get home directory'); 
     35 
    2736ok($unixb->commit, "Can save unix base"); 
    2837 
Note: See TracChangeset for help on using the changeset viewer.