Imported Upstream version 1.7.0
[platform/upstream/augeas.git] / lenses / tests / test_authorized_keys.aug
1 (*
2 Module: Test_Authorized_Keys
3   Provides unit tests and examples for the <Authorized_Keys> lens.
4 *)
5
6 module Test_Authorized_Keys =
7
8 (* Test: Authorized_Keys *)
9 test Authorized_Keys.lns get "tunnel=\"0\",no-agent-forwarding,command=\"sh /etc/netstart tun0\",permitopen=\"192.0.2.1:80\",permitopen=\"192.0.2.2:25\" ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA3RC8whKGFx+b7BMTFtnIWl6t/qyvOvnuqIrMNI9J8+1sEYv8Y/pJRh0vAe2RaSKAgB2hyzXwSJ1Fh+ooraUAJ+q7P2gg2kQF1nCFeGVjtV9m4ZrV5kZARcQMhp0Bp67tPo2TCtnthPYZS/YQG6u/6Aco1XZjPvuKujAQMGSgqNskhKBO9zfhhkAMIcKVryjKYHDfqbDUCCSNzlwFLts3nJ0Hfno6Hz+XxuBIfKOGjHfbzFyUQ7smYnzF23jFs4XhvnjmIGQJcZT4kQAsRwQubyuyDuqmQXqa+2SuQfkKTaPOlVqyuEWJdG2weIF8g3YP12czsBgNppz3jsnhEgstnQ== rpinson on rpinson\n" =
10   { "key" = "AAAAB3NzaC1yc2EAAAABIwAAAQEA3RC8whKGFx+b7BMTFtnIWl6t/qyvOvnuqIrMNI9J8+1sEYv8Y/pJRh0vAe2RaSKAgB2hyzXwSJ1Fh+ooraUAJ+q7P2gg2kQF1nCFeGVjtV9m4ZrV5kZARcQMhp0Bp67tPo2TCtnthPYZS/YQG6u/6Aco1XZjPvuKujAQMGSgqNskhKBO9zfhhkAMIcKVryjKYHDfqbDUCCSNzlwFLts3nJ0Hfno6Hz+XxuBIfKOGjHfbzFyUQ7smYnzF23jFs4XhvnjmIGQJcZT4kQAsRwQubyuyDuqmQXqa+2SuQfkKTaPOlVqyuEWJdG2weIF8g3YP12czsBgNppz3jsnhEgstnQ=="
11     { "options"
12       { "tunnel" = "0" }
13       { "no-agent-forwarding" }
14       { "command" = "sh /etc/netstart tun0" }
15       { "permitopen" = "192.0.2.1:80" }
16       { "permitopen" = "192.0.2.2:25" }
17     }
18     { "type" = "ssh-rsa" }
19     { "comment" = "rpinson on rpinson" } } 
20
21 (* Variable: keys *)
22 let keys = "# Example keys, one of each type
23 #
24 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDpWrKYsEsVUyuwMN4ReBN/TMGsaUWzDKDz/uQr6MlNNM95MDK/BPyJ+DiBiNMFVLpRt3gH3eCJBLJKMuUDaTNy5uym2zNgAaAIVct6M2GHI68W3iY3Ja8/MaRPbyTpMh1O74S+McpAW1SGL2YzFchYMjTnu/kOD3lxiWNiDLvdLFZu0wPOi7CYG37VXR4Thb0cC92zqnCjaP1TwfhpEYUZoowElYkoV2vG+19O6cRm/zduYcf8hmegZKB4GFUJTtZ2gZ18XJDSQd0ykK3KPt/+bKskdrtfiOwSZAmUZmd2YuAlY6+CBn1T3UBdQntueukd0z1xhd6SX7Bl8+qyqLQ3 user@example
25 ssh-dsa AAAA user@example
26 ecdsa-sha2-nistp256 AAAA user@example
27 ssh-ed25519 AAAA user@example
28
29 # Example comments
30 ssh-dsa AAAA
31 ssh-dsa AAAA user@example
32 "
33
34 (* Test: Authorized_Keys.lns *)
35 test Authorized_Keys.lns get keys =
36   { "#comment" = "Example keys, one of each type" }
37   {  }
38   { "key" =
39 "AAAAB3NzaC1yc2EAAAADAQABAAABAQDpWrKYsEsVUyuwMN4ReBN/TMGsaUWzDKDz/uQr6MlNNM95MDK/BPyJ+DiBiNMFVLpRt3gH3eCJBLJKMuUDaTNy5uym2zNgAaAIVct6M2GHI68W3iY3Ja8/MaRPbyTpMh1O74S+McpAW1SGL2YzFchYMjTnu/kOD3lxiWNiDLvdLFZu0wPOi7CYG37VXR4Thb0cC92zqnCjaP1TwfhpEYUZoowElYkoV2vG+19O6cRm/zduYcf8hmegZKB4GFUJTtZ2gZ18XJDSQd0ykK3KPt/+bKskdrtfiOwSZAmUZmd2YuAlY6+CBn1T3UBdQntueukd0z1xhd6SX7Bl8+qyqLQ3"
40     { "type" = "ssh-rsa" }
41     { "comment" = "user@example" }
42   }
43   { "key" = "AAAA"
44     { "type" = "ssh-dsa" }
45     { "comment" = "user@example" }
46   }
47   { "key" = "AAAA"
48     { "type" = "ecdsa-sha2-nistp256" }
49     { "comment" = "user@example" }
50   }
51   { "key" = "AAAA"
52     { "type" = "ssh-ed25519" }
53     { "comment" = "user@example" }
54   }
55   {  }
56   { "#comment" = "Example comments" }
57   { "key" = "AAAA"
58     { "type" = "ssh-dsa" }
59   }
60   { "key" = "AAAA"
61     { "type" = "ssh-dsa" }
62     { "comment" = "user@example" }
63   }
64
65 (* Variable: options *)
66 let options = "# Example options
67 no-pty ssh-dsa AAAA
68 no-pty ssh-ed25519 AAAA
69 no-pty,command=\"foo\" ssh-dsa AAAA
70 no-pty,command=\"foo bar\" ssh-dsa AAAA
71 no-pty,from=\"example.com,10.1.1.0/16\" ssh-dsa AAAA
72 no-pty,environment=\"LANG=en_GB.UTF8\" ssh-dsa AAAA
73 "
74
75 (* Test: Authorized_Keys.lns *)
76 test Authorized_Keys.lns get options =
77   { "#comment" = "Example options" }
78   { "key" = "AAAA"
79     { "options"
80       { "no-pty" }
81     }
82     { "type" = "ssh-dsa" }
83   }
84   { "key" = "AAAA"
85     { "options"
86       { "no-pty" }
87     }
88     { "type" = "ssh-ed25519" }
89   }
90   { "key" = "AAAA"
91     { "options"
92       { "no-pty" }
93       { "command" = "foo" }
94     }
95     { "type" = "ssh-dsa" }
96   }
97   { "key" = "AAAA"
98     { "options"
99       { "no-pty" }
100       { "command" = "foo bar" }
101     }
102     { "type" = "ssh-dsa" }
103   }
104   { "key" = "AAAA"
105     { "options"
106       { "no-pty" }
107       { "from" = "example.com,10.1.1.0/16" }
108     }
109     { "type" = "ssh-dsa" }
110   }
111   { "key" = "AAAA"
112     { "options"
113       { "no-pty" }
114       { "environment" = "LANG=en_GB.UTF8" }
115     }
116     { "type" = "ssh-dsa" }
117   }
118
119 (* Test: Authorized_keys.lns
120      GH 165 *)
121 test Authorized_keys.lns get "command=\"echo 'Please login as the user \\\"blaauser\\\" rather than the user \\\"root\\\".';echo;sleep 10\" ssh-rsa DEADBEEF== username1\n" =
122   { "key" = "DEADBEEF=="
123     { "options"
124       { "command" = "echo 'Please login as the user \\\"blaauser\\\" rather than the user \\\"root\\\".';echo;sleep 10" }
125     }
126     { "type" = "ssh-rsa" }
127     { "comment" = "username1" }
128   }