Imported Upstream version 1.4.0
[platform/upstream/augeas.git] / lenses / tests / test_passwd.aug
1 module Test_Passwd =
2
3 let conf = "root:x:0:0:root:/root:/bin/bash
4 libuuid:x:100:101::/var/lib/libuuid:/bin/sh
5 free:x:1000:1000:Free Ekanayaka,,,:/home/free:/bin/bash
6 root:*:0:0:Charlie &:/root:/bin/csh
7 "
8
9 test Passwd.lns get conf =
10    { "root"
11      { "password" = "x" }
12      { "uid" = "0" }
13      { "gid" = "0" }
14      { "name" = "root" }
15      { "home" = "/root" }
16      { "shell" = "/bin/bash" } }
17    { "libuuid"
18      { "password" = "x" }
19      { "uid" = "100" }
20      { "gid" = "101" }
21      { "name" }
22      { "home" = "/var/lib/libuuid" }
23      { "shell" = "/bin/sh" } }
24    { "free"
25      { "password" = "x" }
26      { "uid" = "1000" }
27      { "gid" = "1000" }
28      { "name" = "Free Ekanayaka,,," }
29      { "home" = "/home/free" }
30      { "shell" = "/bin/bash" } }
31    { "root"
32      { "password" = "*" }
33      { "uid" = "0" }
34      { "gid" = "0" }
35      { "name" = "Charlie &" }
36      { "home" = "/root" }
37      { "shell" = "/bin/csh" } }
38
39 (* Popular on Solaris *)
40 test Passwd.lns get "+@some-nis-group::::::\n" =
41   { "@nis" = "some-nis-group" }
42
43 test Passwd.lns get "+\n" =
44   { "@nisdefault" }
45
46 test Passwd.lns get "+::::::\n" =
47   { "@nisdefault"
48       { "password" = "" }
49       { "uid" = "" }
50       { "gid" = "" }
51       { "name" }
52       { "home" }
53       { "shell" } }
54
55 test Passwd.lns get "+::::::/sbin/nologin\n" =
56   { "@nisdefault"
57     { "password" = "" }
58     { "uid" = "" }
59     { "gid" = "" }
60     { "name" }
61     { "home" }
62     { "shell" = "/sbin/nologin" } }
63
64 test Passwd.lns get "+:*:0:0:::\n" =
65   { "@nisdefault"
66     { "password" = "*" }
67     { "uid" = "0" }
68     { "gid" = "0" }
69     { "name" }
70     { "home" }
71     { "shell" } }
72
73 (* NIS entries with overrides, ticket #339 *)
74 test Passwd.lns get "+@bob:::::/home/bob:/bin/bash\n" =
75  { "@nis" = "bob"
76    { "home" = "/home/bob" }
77    { "shell" = "/bin/bash" } }
78
79 (* NIS user entries *)
80 test Passwd.lns get "+bob::::::\n" =
81  { "@+nisuser" = "bob" }
82
83 test Passwd.lns get "+bob::::User Comment:/home/bob:/bin/bash\n" =
84  { "@+nisuser" = "bob"
85    { "name" = "User Comment" }
86    { "home" = "/home/bob" }
87    { "shell" = "/bin/bash" } }
88
89 test Passwd.lns put "+bob::::::\n" after
90   set "@+nisuser" "alice"
91 = "+alice::::::\n"
92
93 test Passwd.lns put "+bob::::::\n" after
94   set "@+nisuser/name" "User Comment";
95   set "@+nisuser/home" "/home/bob";
96   set "@+nisuser/shell" "/bin/bash"
97 = "+bob::::User Comment:/home/bob:/bin/bash\n"
98
99 test Passwd.lns get "-bob::::::\n" =
100  { "@-nisuser" = "bob" }
101
102 test Passwd.lns put "-bob::::::\n" after
103   set "@-nisuser" "alice"
104 = "-alice::::::\n"