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