1 | use strict; |
---|
2 | use warnings; |
---|
3 | use Test::More tests => 16; |
---|
4 | use File::Temp qw(mkstemp); |
---|
5 | |
---|
6 | use_ok('LATMOS::Accounts::Utils'); |
---|
7 | use_ok('LATMOS::Accounts::Mail'); |
---|
8 | use LATMOS::Accounts::Log; |
---|
9 | |
---|
10 | ok(la_log(LA_NOTICE, "a notice"), "can run la_log"); |
---|
11 | |
---|
12 | my ($fh, $file) = mkstemp( "tmpfileXXXXX" ); |
---|
13 | print $fh <<EOF; |
---|
14 | attr1: attr1 |
---|
15 | attr: val1 |
---|
16 | attr: val2 |
---|
17 | EOF |
---|
18 | |
---|
19 | seek($fh, 0, 0); |
---|
20 | |
---|
21 | my %attributes = LATMOS::Accounts::Utils::parse_obj_file($fh); |
---|
22 | $fh = undef; |
---|
23 | unlink($file); |
---|
24 | |
---|
25 | # now testing |
---|
26 | is($attributes{'attr1'}, 'attr1', "can get attribute from file"); |
---|
27 | ok(eq_set($attributes{'attr'}, [ qw(val1 val2) ]), |
---|
28 | "can get multiple values attribute"); |
---|
29 | |
---|
30 | $ENV{EDITOR} = 'sleep 1; /bin/touch'; |
---|
31 | |
---|
32 | ok(LATMOS::Accounts::Utils::dump_read_temp_file( |
---|
33 | sub { 1; }, sub { 1; }), "Can edit temp file"); |
---|
34 | |
---|
35 | ok(!LATMOS::Accounts::Utils::check_oid_validity('toto'), '"toto" is valid oid'); |
---|
36 | ok(!LATMOS::Accounts::Utils::check_oid_validity('toTo'), '"toTo" is valid oid'); |
---|
37 | ok(LATMOS::Accounts::Utils::check_oid_validity('to to'), '"to to" is invalid oid'); |
---|
38 | ok(LATMOS::Accounts::Utils::check_oid_validity(' toto'), '" toto" is invalid oid'); |
---|
39 | |
---|
40 | ok(!LATMOS::Accounts::Utils::check_ug_validity('toto'), '"toto" is valid username'); |
---|
41 | ok(LATMOS::Accounts::Utils::check_ug_validity('toTo'), '"toTo" is invalid username'); |
---|
42 | ok(LATMOS::Accounts::Utils::check_ug_validity('to to'), '"to to" is invalid username'); |
---|
43 | ok(LATMOS::Accounts::Utils::check_ug_validity(' toto'), '" toto" is invalid username'); |
---|
44 | ok(LATMOS::Accounts::Utils::check_ug_validity('5toto'), '"5toto" is invalid username'); |
---|
45 | ok(!LATMOS::Accounts::Utils::check_ug_validity('t5oto'), '"t5oto" is valid username'); |
---|