[pve-devel] [PATCH container 2/4] Add setup tests for authorized keys

Fabian Grünbichler f.gruenbichler at proxmox.com
Tue Apr 5 13:17:01 CEST 2016


include ssh keys in previous test cases, add one extra test
case for a non-default $HOME read from /etc/passwd
---
 src/test/run_setup_tests.pl                         | 10 ++++++++--
 .../test-centos6-001/root/.ssh/authorized_keys.exp  |  3 +++
 .../test-debian-001/root/.ssh/authorized_keys.exp   |  3 +++
 .../test-debian-002/root/.ssh/authorized_keys.exp   |  3 +++
 .../test-debian-003/root/.ssh/authorized_keys.exp   |  3 +++
 .../test-debian-004/root/.ssh/authorized_keys.exp   |  3 +++
 .../test-debian-005/root/.ssh/authorized_keys.exp   |  3 +++
 .../test-debian-006/root/.ssh/authorized_keys.exp   |  3 +++
 .../test-debian-007/root/.ssh/authorized_keys.exp   |  3 +++
 .../test-debian-008/root/.ssh/authorized_keys.exp   |  3 +++
 .../test-debian-009/root/.ssh/authorized_keys.exp   |  3 +++
 .../test-debian-010/root/.ssh/authorized_keys.exp   |  3 +++
 .../test-debian-011/root/.ssh/authorized_keys.exp   |  3 +++
 .../test-debian-012/root/.ssh/authorized_keys.exp   |  3 +++
 .../test-debian-013/root/.ssh/authorized_keys.exp   |  3 +++
 src/test/test-debian-014/config                     |  1 +
 src/test/test-debian-014/etc/debian_version         |  1 +
 src/test/test-debian-014/etc/hostname.exp           |  1 +
 src/test/test-debian-014/etc/hosts.exp              |  5 +++++
 src/test/test-debian-014/etc/passwd                 | 21 +++++++++++++++++++++
 src/test/test-debian-014/etc/passwd.exp             | 21 +++++++++++++++++++++
 src/test/test-debian-014/etc/shadow                 | 21 +++++++++++++++++++++
 src/test/test-debian-014/etc/shadow.exp             | 21 +++++++++++++++++++++
 .../roothome/.ssh/authorized_keys.exp               |  3 +++
 .../test-opensuse-001/root/.ssh/authorized_keys.exp |  3 +++
 .../test-opensuse-002/root/.ssh/authorized_keys.exp |  3 +++
 .../test-opensuse-003/root/.ssh/authorized_keys.exp |  3 +++
 27 files changed, 154 insertions(+), 2 deletions(-)
 create mode 100644 src/test/test-centos6-001/root/.ssh/authorized_keys.exp
 create mode 100644 src/test/test-debian-001/root/.ssh/authorized_keys.exp
 create mode 100644 src/test/test-debian-002/root/.ssh/authorized_keys.exp
 create mode 100644 src/test/test-debian-003/root/.ssh/authorized_keys.exp
 create mode 100644 src/test/test-debian-004/root/.ssh/authorized_keys.exp
 create mode 100644 src/test/test-debian-005/root/.ssh/authorized_keys.exp
 create mode 100644 src/test/test-debian-006/root/.ssh/authorized_keys.exp
 create mode 100644 src/test/test-debian-007/root/.ssh/authorized_keys.exp
 create mode 100644 src/test/test-debian-008/root/.ssh/authorized_keys.exp
 create mode 100644 src/test/test-debian-009/root/.ssh/authorized_keys.exp
 create mode 100644 src/test/test-debian-010/root/.ssh/authorized_keys.exp
 create mode 100644 src/test/test-debian-011/root/.ssh/authorized_keys.exp
 create mode 100644 src/test/test-debian-012/root/.ssh/authorized_keys.exp
 create mode 100644 src/test/test-debian-013/root/.ssh/authorized_keys.exp
 create mode 100644 src/test/test-debian-014/config
 create mode 100644 src/test/test-debian-014/etc/debian_version
 create mode 100644 src/test/test-debian-014/etc/hostname.exp
 create mode 100644 src/test/test-debian-014/etc/hosts.exp
 create mode 100644 src/test/test-debian-014/etc/passwd
 create mode 100644 src/test/test-debian-014/etc/passwd.exp
 create mode 100644 src/test/test-debian-014/etc/shadow
 create mode 100644 src/test/test-debian-014/etc/shadow.exp
 create mode 100644 src/test/test-debian-014/roothome/.ssh/authorized_keys.exp
 create mode 100644 src/test/test-opensuse-001/root/.ssh/authorized_keys.exp
 create mode 100644 src/test/test-opensuse-002/root/.ssh/authorized_keys.exp
 create mode 100644 src/test/test-opensuse-003/root/.ssh/authorized_keys.exp

diff --git a/src/test/run_setup_tests.pl b/src/test/run_setup_tests.pl
index 8214838..fc92dbb 100755
--- a/src/test/run_setup_tests.pl
+++ b/src/test/run_setup_tests.pl
@@ -41,7 +41,7 @@ sub run_test {
 	# run tests twice, to make sure scripts are idempotent
 	
 	srand(0);
-	$lxc_setup->post_create_hook('$TEST$ABCDEF');
+	$lxc_setup->post_create_hook('$TEST$ABCDEF','ssh-rsa ABCDEFG ABC at DEF');
 
 	my @testfiles = qw(/etc/hostname
 	                   /etc/hosts
@@ -71,7 +71,13 @@ sub run_test {
 	                   /etc/init/tty.conf
 	                   /etc/init/power-status-changed.conf
 	                   /etc/securetty
-	                   /etc/crontab);
+	                   /etc/crontab
+	                   /root
+	                   /root/.ssh
+	                   /root/.ssh/authorized_keys
+	                   /roothome
+	                   /roothome/.ssh
+	                   /roothome/.ssh/authorized_keys);
 	foreach my $fn (@testfiles) {
 	    next if !-f "$testdir/$fn.exp";
 	    test_file("$testdir/$fn.exp", "$rootfs/$fn");
diff --git a/src/test/test-centos6-001/root/.ssh/authorized_keys.exp b/src/test/test-centos6-001/root/.ssh/authorized_keys.exp
new file mode 100644
index 0000000..1cb3ec3
--- /dev/null
+++ b/src/test/test-centos6-001/root/.ssh/authorized_keys.exp
@@ -0,0 +1,3 @@
+# --- BEGIN PVE ---
+ssh-rsa ABCDEFG ABC at DEF
+# --- END PVE ---
diff --git a/src/test/test-debian-001/root/.ssh/authorized_keys.exp b/src/test/test-debian-001/root/.ssh/authorized_keys.exp
new file mode 100644
index 0000000..1cb3ec3
--- /dev/null
+++ b/src/test/test-debian-001/root/.ssh/authorized_keys.exp
@@ -0,0 +1,3 @@
+# --- BEGIN PVE ---
+ssh-rsa ABCDEFG ABC at DEF
+# --- END PVE ---
diff --git a/src/test/test-debian-002/root/.ssh/authorized_keys.exp b/src/test/test-debian-002/root/.ssh/authorized_keys.exp
new file mode 100644
index 0000000..1cb3ec3
--- /dev/null
+++ b/src/test/test-debian-002/root/.ssh/authorized_keys.exp
@@ -0,0 +1,3 @@
+# --- BEGIN PVE ---
+ssh-rsa ABCDEFG ABC at DEF
+# --- END PVE ---
diff --git a/src/test/test-debian-003/root/.ssh/authorized_keys.exp b/src/test/test-debian-003/root/.ssh/authorized_keys.exp
new file mode 100644
index 0000000..1cb3ec3
--- /dev/null
+++ b/src/test/test-debian-003/root/.ssh/authorized_keys.exp
@@ -0,0 +1,3 @@
+# --- BEGIN PVE ---
+ssh-rsa ABCDEFG ABC at DEF
+# --- END PVE ---
diff --git a/src/test/test-debian-004/root/.ssh/authorized_keys.exp b/src/test/test-debian-004/root/.ssh/authorized_keys.exp
new file mode 100644
index 0000000..1cb3ec3
--- /dev/null
+++ b/src/test/test-debian-004/root/.ssh/authorized_keys.exp
@@ -0,0 +1,3 @@
+# --- BEGIN PVE ---
+ssh-rsa ABCDEFG ABC at DEF
+# --- END PVE ---
diff --git a/src/test/test-debian-005/root/.ssh/authorized_keys.exp b/src/test/test-debian-005/root/.ssh/authorized_keys.exp
new file mode 100644
index 0000000..1cb3ec3
--- /dev/null
+++ b/src/test/test-debian-005/root/.ssh/authorized_keys.exp
@@ -0,0 +1,3 @@
+# --- BEGIN PVE ---
+ssh-rsa ABCDEFG ABC at DEF
+# --- END PVE ---
diff --git a/src/test/test-debian-006/root/.ssh/authorized_keys.exp b/src/test/test-debian-006/root/.ssh/authorized_keys.exp
new file mode 100644
index 0000000..1cb3ec3
--- /dev/null
+++ b/src/test/test-debian-006/root/.ssh/authorized_keys.exp
@@ -0,0 +1,3 @@
+# --- BEGIN PVE ---
+ssh-rsa ABCDEFG ABC at DEF
+# --- END PVE ---
diff --git a/src/test/test-debian-007/root/.ssh/authorized_keys.exp b/src/test/test-debian-007/root/.ssh/authorized_keys.exp
new file mode 100644
index 0000000..1cb3ec3
--- /dev/null
+++ b/src/test/test-debian-007/root/.ssh/authorized_keys.exp
@@ -0,0 +1,3 @@
+# --- BEGIN PVE ---
+ssh-rsa ABCDEFG ABC at DEF
+# --- END PVE ---
diff --git a/src/test/test-debian-008/root/.ssh/authorized_keys.exp b/src/test/test-debian-008/root/.ssh/authorized_keys.exp
new file mode 100644
index 0000000..1cb3ec3
--- /dev/null
+++ b/src/test/test-debian-008/root/.ssh/authorized_keys.exp
@@ -0,0 +1,3 @@
+# --- BEGIN PVE ---
+ssh-rsa ABCDEFG ABC at DEF
+# --- END PVE ---
diff --git a/src/test/test-debian-009/root/.ssh/authorized_keys.exp b/src/test/test-debian-009/root/.ssh/authorized_keys.exp
new file mode 100644
index 0000000..1cb3ec3
--- /dev/null
+++ b/src/test/test-debian-009/root/.ssh/authorized_keys.exp
@@ -0,0 +1,3 @@
+# --- BEGIN PVE ---
+ssh-rsa ABCDEFG ABC at DEF
+# --- END PVE ---
diff --git a/src/test/test-debian-010/root/.ssh/authorized_keys.exp b/src/test/test-debian-010/root/.ssh/authorized_keys.exp
new file mode 100644
index 0000000..1cb3ec3
--- /dev/null
+++ b/src/test/test-debian-010/root/.ssh/authorized_keys.exp
@@ -0,0 +1,3 @@
+# --- BEGIN PVE ---
+ssh-rsa ABCDEFG ABC at DEF
+# --- END PVE ---
diff --git a/src/test/test-debian-011/root/.ssh/authorized_keys.exp b/src/test/test-debian-011/root/.ssh/authorized_keys.exp
new file mode 100644
index 0000000..1cb3ec3
--- /dev/null
+++ b/src/test/test-debian-011/root/.ssh/authorized_keys.exp
@@ -0,0 +1,3 @@
+# --- BEGIN PVE ---
+ssh-rsa ABCDEFG ABC at DEF
+# --- END PVE ---
diff --git a/src/test/test-debian-012/root/.ssh/authorized_keys.exp b/src/test/test-debian-012/root/.ssh/authorized_keys.exp
new file mode 100644
index 0000000..1cb3ec3
--- /dev/null
+++ b/src/test/test-debian-012/root/.ssh/authorized_keys.exp
@@ -0,0 +1,3 @@
+# --- BEGIN PVE ---
+ssh-rsa ABCDEFG ABC at DEF
+# --- END PVE ---
diff --git a/src/test/test-debian-013/root/.ssh/authorized_keys.exp b/src/test/test-debian-013/root/.ssh/authorized_keys.exp
new file mode 100644
index 0000000..1cb3ec3
--- /dev/null
+++ b/src/test/test-debian-013/root/.ssh/authorized_keys.exp
@@ -0,0 +1,3 @@
+# --- BEGIN PVE ---
+ssh-rsa ABCDEFG ABC at DEF
+# --- END PVE ---
diff --git a/src/test/test-debian-014/config b/src/test/test-debian-014/config
new file mode 100644
index 0000000..8f09fd8
--- /dev/null
+++ b/src/test/test-debian-014/config
@@ -0,0 +1 @@
+hostname: test9
diff --git a/src/test/test-debian-014/etc/debian_version b/src/test/test-debian-014/etc/debian_version
new file mode 100644
index 0000000..4fedf1d
--- /dev/null
+++ b/src/test/test-debian-014/etc/debian_version
@@ -0,0 +1 @@
+7.0
diff --git a/src/test/test-debian-014/etc/hostname.exp b/src/test/test-debian-014/etc/hostname.exp
new file mode 100644
index 0000000..c372db4
--- /dev/null
+++ b/src/test/test-debian-014/etc/hostname.exp
@@ -0,0 +1 @@
+test9
diff --git a/src/test/test-debian-014/etc/hosts.exp b/src/test/test-debian-014/etc/hosts.exp
new file mode 100644
index 0000000..ac7ee16
--- /dev/null
+++ b/src/test/test-debian-014/etc/hosts.exp
@@ -0,0 +1,5 @@
+# --- BEGIN PVE ---
+127.0.0.1 localhost.localnet localhost
+::1 localhost.localnet localhost
+127.0.1.1 test9
+# --- END PVE ---
diff --git a/src/test/test-debian-014/etc/passwd b/src/test/test-debian-014/etc/passwd
new file mode 100644
index 0000000..9fc110f
--- /dev/null
+++ b/src/test/test-debian-014/etc/passwd
@@ -0,0 +1,21 @@
+root:x:0:0:root:/roothome:/bin/bash
+daemon:x:1:1:daemon:/usr/sbin:/bin/sh
+bin:x:2:2:bin:/bin:/bin/sh
+sys:x:3:3:sys:/dev:/bin/sh
+sync:x:4:65534:sync:/bin:/bin/sync
+games:x:5:60:games:/usr/games:/bin/sh
+man:x:6:12:man:/var/cache/man:/bin/sh
+lp:x:7:7:lp:/var/spool/lpd:/bin/sh
+mail:x:8:8:mail:/var/mail:/bin/sh
+news:x:9:9:news:/var/spool/news:/bin/sh
+uucp:x:10:10:uucp:/var/spool/uucp:/bin/sh
+proxy:x:13:13:proxy:/bin:/bin/sh
+www-data:x:33:33:www-data:/var/www:/bin/sh
+backup:x:34:34:backup:/var/backups:/bin/sh
+list:x:38:38:Mailing List Manager:/var/list:/bin/sh
+irc:x:39:39:ircd:/var/run/ircd:/bin/sh
+gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/bin/sh
+nobody:x:65534:65534:nobody:/nonexistent:/bin/sh
+libuuid:x:100:101::/var/lib/libuuid:/bin/sh
+postfix:x:101:104::/var/spool/postfix:/bin/false
+sshd:x:102:65534::/var/run/sshd:/usr/sbin/nologin
diff --git a/src/test/test-debian-014/etc/passwd.exp b/src/test/test-debian-014/etc/passwd.exp
new file mode 100644
index 0000000..9fc110f
--- /dev/null
+++ b/src/test/test-debian-014/etc/passwd.exp
@@ -0,0 +1,21 @@
+root:x:0:0:root:/roothome:/bin/bash
+daemon:x:1:1:daemon:/usr/sbin:/bin/sh
+bin:x:2:2:bin:/bin:/bin/sh
+sys:x:3:3:sys:/dev:/bin/sh
+sync:x:4:65534:sync:/bin:/bin/sync
+games:x:5:60:games:/usr/games:/bin/sh
+man:x:6:12:man:/var/cache/man:/bin/sh
+lp:x:7:7:lp:/var/spool/lpd:/bin/sh
+mail:x:8:8:mail:/var/mail:/bin/sh
+news:x:9:9:news:/var/spool/news:/bin/sh
+uucp:x:10:10:uucp:/var/spool/uucp:/bin/sh
+proxy:x:13:13:proxy:/bin:/bin/sh
+www-data:x:33:33:www-data:/var/www:/bin/sh
+backup:x:34:34:backup:/var/backups:/bin/sh
+list:x:38:38:Mailing List Manager:/var/list:/bin/sh
+irc:x:39:39:ircd:/var/run/ircd:/bin/sh
+gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/bin/sh
+nobody:x:65534:65534:nobody:/nonexistent:/bin/sh
+libuuid:x:100:101::/var/lib/libuuid:/bin/sh
+postfix:x:101:104::/var/spool/postfix:/bin/false
+sshd:x:102:65534::/var/run/sshd:/usr/sbin/nologin
diff --git a/src/test/test-debian-014/etc/shadow b/src/test/test-debian-014/etc/shadow
new file mode 100644
index 0000000..7d4be16
--- /dev/null
+++ b/src/test/test-debian-014/etc/shadow
@@ -0,0 +1,21 @@
+root:!*:15908:0:99999:7:::
+daemon:*:15908:0:99999:7:::
+bin:*:15908:0:99999:7:::
+sys:*:15908:0:99999:7:::
+sync:*:15908:0:99999:7:::
+games:*:15908:0:99999:7:::
+man:*:15908:0:99999:7:::
+lp:*:15908:0:99999:7:::
+mail:*:15908:0:99999:7:::
+news:*:15908:0:99999:7:::
+uucp:*:15908:0:99999:7:::
+proxy:*:15908:0:99999:7:::
+www-data:*:15908:0:99999:7:::
+backup:*:15908:0:99999:7:::
+list:*:15908:0:99999:7:::
+irc:*:15908:0:99999:7:::
+gnats:*:15908:0:99999:7:::
+nobody:*:15908:0:99999:7:::
+libuuid:!:15908:0:99999:7:::
+postfix:*:15908:0:99999:7:::
+sshd:*:15908:0:99999:7:::
diff --git a/src/test/test-debian-014/etc/shadow.exp b/src/test/test-debian-014/etc/shadow.exp
new file mode 100644
index 0000000..deb9e2d
--- /dev/null
+++ b/src/test/test-debian-014/etc/shadow.exp
@@ -0,0 +1,21 @@
+root:$TEST$ABCDEF:12345:0:99999:7:::
+daemon:*:15908:0:99999:7:::
+bin:*:15908:0:99999:7:::
+sys:*:15908:0:99999:7:::
+sync:*:15908:0:99999:7:::
+games:*:15908:0:99999:7:::
+man:*:15908:0:99999:7:::
+lp:*:15908:0:99999:7:::
+mail:*:15908:0:99999:7:::
+news:*:15908:0:99999:7:::
+uucp:*:15908:0:99999:7:::
+proxy:*:15908:0:99999:7:::
+www-data:*:15908:0:99999:7:::
+backup:*:15908:0:99999:7:::
+list:*:15908:0:99999:7:::
+irc:*:15908:0:99999:7:::
+gnats:*:15908:0:99999:7:::
+nobody:*:15908:0:99999:7:::
+libuuid:!:15908:0:99999:7:::
+postfix:*:15908:0:99999:7:::
+sshd:*:15908:0:99999:7:::
diff --git a/src/test/test-debian-014/roothome/.ssh/authorized_keys.exp b/src/test/test-debian-014/roothome/.ssh/authorized_keys.exp
new file mode 100644
index 0000000..1cb3ec3
--- /dev/null
+++ b/src/test/test-debian-014/roothome/.ssh/authorized_keys.exp
@@ -0,0 +1,3 @@
+# --- BEGIN PVE ---
+ssh-rsa ABCDEFG ABC at DEF
+# --- END PVE ---
diff --git a/src/test/test-opensuse-001/root/.ssh/authorized_keys.exp b/src/test/test-opensuse-001/root/.ssh/authorized_keys.exp
new file mode 100644
index 0000000..1cb3ec3
--- /dev/null
+++ b/src/test/test-opensuse-001/root/.ssh/authorized_keys.exp
@@ -0,0 +1,3 @@
+# --- BEGIN PVE ---
+ssh-rsa ABCDEFG ABC at DEF
+# --- END PVE ---
diff --git a/src/test/test-opensuse-002/root/.ssh/authorized_keys.exp b/src/test/test-opensuse-002/root/.ssh/authorized_keys.exp
new file mode 100644
index 0000000..1cb3ec3
--- /dev/null
+++ b/src/test/test-opensuse-002/root/.ssh/authorized_keys.exp
@@ -0,0 +1,3 @@
+# --- BEGIN PVE ---
+ssh-rsa ABCDEFG ABC at DEF
+# --- END PVE ---
diff --git a/src/test/test-opensuse-003/root/.ssh/authorized_keys.exp b/src/test/test-opensuse-003/root/.ssh/authorized_keys.exp
new file mode 100644
index 0000000..1cb3ec3
--- /dev/null
+++ b/src/test/test-opensuse-003/root/.ssh/authorized_keys.exp
@@ -0,0 +1,3 @@
+# --- BEGIN PVE ---
+ssh-rsa ABCDEFG ABC at DEF
+# --- END PVE ---
-- 
2.1.4





More information about the pve-devel mailing list