diff --git a/Authors b/Authors index 46ee575..303913a 100644 --- a/Authors +++ b/Authors @@ -1,3 +1,5 @@ Please add your name to this list with your first commit request Karanbir Singh +Fabian diff --git a/readme b/readme index 8a8f607..e8bfa44 100644 --- a/readme +++ b/readme @@ -44,3 +44,13 @@ notes... - all files named 'readme', or starting with an underscore are ignored by the test harness ( so one can use the _ to host metadata or any config that might be needed for a test. + +ToDo: +- At the moment the tests are not distro / arch specific, we might need a way + to clearly mark a test as -only-for-c4- or -only-for-c5- etc ( specially + when there are kickstart files involved, there are some non trivial changes + in that area moving towards c6 ) + +- We also need a way to dictate if a role_ should be run on realiron, + virtual machine host, virtual machine ( and maybe even the type of virt + being used! ) diff --git a/tests/p_dovecot/0-install_dovecot.sh b/tests/p_dovecot/0-install_dovecot.sh new file mode 100755 index 0000000..380f386 --- /dev/null +++ b/tests/p_dovecot/0-install_dovecot.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# Author: Athmane Madjoudj + +# Dovecot +yum -y install dovecot +chkconfig dovecot on +service dovecot start diff --git a/tests/p_dovecot/dovecot_imap_login.sh b/tests/p_dovecot/dovecot_imap_login.sh new file mode 100755 index 0000000..bf6ff4b --- /dev/null +++ b/tests/p_dovecot/dovecot_imap_login.sh @@ -0,0 +1,14 @@ +#!/bin/sh +# Author: Athmane Madjoudj + +echo "Adding a new test user ..." +userdel imaptest; useradd imaptest && echo imaptest | passwd --stdin imaptest + +echo -n "Dovecot IMAP login test: " +echo -e "01 LOGIN imaptest imaptest\n" | nc localhost 143 | grep "01 OK Logged in." > /dev/null 2>&1 +if [ $? -eq 0 ]; then + echo 'PASS' +else + echo 'FAIL' + exit 1 +fi diff --git a/tests/p_dovecot/dovecot_pop3_login.sh b/tests/p_dovecot/dovecot_pop3_login.sh new file mode 100755 index 0000000..4c152e3 --- /dev/null +++ b/tests/p_dovecot/dovecot_pop3_login.sh @@ -0,0 +1,14 @@ +#!/bin/sh +# Author: Athmane Madjoudj + +echo "Adding a new test user ..." +userdel pop3test; useradd pop3test && echo pop3test | passwd --stdin pop3test + +echo -n "Dovecot POP3 login test: " +echo -e "user pop3test\npass pop3test\n" | nc localhost 110 | grep "+OK Logged in." > /dev/null 2>&1 +if [ $? -eq 0 ]; then + echo 'PASS' +else + echo 'FAIL' + exit 1 +fi diff --git a/tests/p_httpd/0-install_httpd.sh b/tests/p_httpd/0-install_httpd.sh new file mode 100755 index 0000000..0bfd612 --- /dev/null +++ b/tests/p_httpd/0-install_httpd.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# Author: Athmane Madjoudj + +# HTTPD / PHP +yum -y install httpd mod_ssl php php-mysql +chkconfig httpd on +service httpd start diff --git a/tests/p_httpd/httpd_php.sh b/tests/p_httpd/httpd_php.sh new file mode 100755 index 0000000..cf02dd7 --- /dev/null +++ b/tests/p_httpd/httpd_php.sh @@ -0,0 +1,12 @@ +#!/bin/sh +# Author: Athmane Madjoudj + +echo "" > /var/www/html/test.php +echo -n "HTTPD handle PHP test: " +echo -e "GET /test.php HTTP/1.0\r\n" | nc localhost 80 | grep 'PHP Version' > /dev/null 2>&1 +if [ $? -eq 0 ]; then + echo 'PASS' +else + echo 'FAIL' + exit 1 +fi diff --git a/tests/p_httpd/httpd_servehtml.sh b/tests/p_httpd/httpd_servehtml.sh new file mode 100755 index 0000000..1d95128 --- /dev/null +++ b/tests/p_httpd/httpd_servehtml.sh @@ -0,0 +1,11 @@ +#!/bin/sh +# Author: Athmane Madjoudj + +echo -n "HTTPD serve html page test: " +echo -e "GET / HTTP/1.0\r\n" | nc localhost 80 | grep 'Test Page' > /dev/null 2>&1 +if [ $? -eq 0 ]; then + echo 'PASS' +else + echo 'FAIL' + exit 1 +fi diff --git a/tests/p_httpd/httpd_vhost.sh b/tests/p_httpd/httpd_vhost.sh new file mode 100755 index 0000000..b6927ef --- /dev/null +++ b/tests/p_httpd/httpd_vhost.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# Author: Athmane Madjoudj + +echo "127.0.0.1 test" >> /etc/hosts +cat > /etc/httpd/conf.d/vhost-test.conf < + ServerAdmin webmaster@test + DocumentRoot /var/www/vhosts/test/ + ServerName test + +EOF + +mkdir -p /var/www/vhosts/test/ +echo "Virtual Host Test Page" > /var/www/vhosts/test/index.html +service httpd restart +echo -n "HTTPD Virtual Host test: " +echo -e "GET / HTTP/1.0\r\n" | nc test 80 | grep 'Virtual Host Test Page' > /dev/null 2>&1 +if [ $? -eq 0 ]; then + echo 'PASS' +else + echo 'FAIL' + exit 1 +fi diff --git a/tests/p_mdadm/readme b/tests/p_mdadm/readme new file mode 100644 index 0000000..a50901c --- /dev/null +++ b/tests/p_mdadm/readme @@ -0,0 +1 @@ +we just need to make sure that the packages are sane, most of the mdadm testing is done in the role tests diff --git a/tests/p_mysql/0-install_mysqld.sh b/tests/p_mysql/0-install_mysqld.sh new file mode 100755 index 0000000..aafadba --- /dev/null +++ b/tests/p_mysql/0-install_mysqld.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# Author: Athmane Madjoudj + +# MySQL +yum -y install mysql-server +chkconfig mysqld on +service mysqld start diff --git a/tests/p_mysql/mysqld_conn_test.sh b/tests/p_mysql/mysqld_conn_test.sh new file mode 100755 index 0000000..7b51350 --- /dev/null +++ b/tests/p_mysql/mysqld_conn_test.sh @@ -0,0 +1,17 @@ +#!/bin/sh +# Author: Athmane Madjoudj + +# FIXME: Test is very basic +echo -n "MySQL is listening test: " +nc -w 1 localhost 3306 > /dev/null 2>&1 +if [ $? -eq 0 ]; then + echo 'PASS' +else + echo 'FAIL' + exit 1 +fi + +# kb: Can we do something like : +# hn=$(mysql -N -B -u root -e "show variables like 'hostname'" | cut -f 2) +# then compare ${hn} to the real machine hostname ( `fqdn` ? ) to make sure +# they are identical diff --git a/tests/p_mysql/mysqld_create_db.sh b/tests/p_mysql/mysqld_create_db.sh new file mode 100755 index 0000000..7831e85 --- /dev/null +++ b/tests/p_mysql/mysqld_create_db.sh @@ -0,0 +1,11 @@ +#!/bin/sh +# Author: Athmane Madjoudj + +echo -n "MySQL create database test: " +mysql -u root -e 'create database mysql_test' > /dev/null 2>&1 +if [ $? -eq 0 ]; then + echo 'PASS' +else + echo 'FAIL' + exit 1 +fi diff --git a/tests/p_mysql/mysqld_drop_db.sh b/tests/p_mysql/mysqld_drop_db.sh new file mode 100755 index 0000000..b4b75c2 --- /dev/null +++ b/tests/p_mysql/mysqld_drop_db.sh @@ -0,0 +1,11 @@ +#!/bin/sh +# Author: Athmane Madjoudj + +echo -n "MySQL drop database test: " +mysql -u root -e 'drop database mysql_test' > /dev/null 2>&1 +if [ $? -eq 0 ]; then + echo 'PASS' +else + echo 'FAIL' + exit 1 +fi diff --git a/tests/p_openssh/0-install_sshd.sh b/tests/p_openssh/0-install_sshd.sh new file mode 100755 index 0000000..085659e --- /dev/null +++ b/tests/p_openssh/0-install_sshd.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# Author: Athmane Madjoudj + +# SSH +yum -y openssh-server +chkconfig sshd on +service sshd start diff --git a/tests/p_openssh/sshd_conn_test.sh b/tests/p_openssh/sshd_conn_test.sh new file mode 100755 index 0000000..4a5cdae --- /dev/null +++ b/tests/p_openssh/sshd_conn_test.sh @@ -0,0 +1,12 @@ +#!/bin/sh +# Author: Athmane Madjoudj + +# FIXME: Test is very basic +echo -n "SSHD is listening test: " +nc -w 1 localhost 22 > /dev/null 2>&1 +if [ $? -eq 0 ]; then + echo 'PASS' +else + echo 'FAIL' + exit 1 +fi diff --git a/tests/p_openssh/sshd_user_login.py b/tests/p_openssh/sshd_user_login.py new file mode 100755 index 0000000..15efa49 --- /dev/null +++ b/tests/p_openssh/sshd_user_login.py @@ -0,0 +1,50 @@ +#!/usr/bin/python +# Author: Athmane Madjoudj + +import os,sys + +def install_pexpect(): + if os.system("rpm -q pexpect") == 0: + return 0 + else: + return os.system("yum -y install pexpect") + +def ssh_command (user, host, password, command): + import pexpect + ssh_newkey = 'Are you sure you want to continue connecting' + child = pexpect.spawn('ssh -l %s %s %s'%(user, host, command)) + i = child.expect([pexpect.TIMEOUT, ssh_newkey, 'password: ']) + if i == 0: # Timeout + print child.before, child.after + return None + if i == 1: # SSH does not have the public key. Just accept it. + child.sendline ('yes') + child.expect ('password: ') + i = child.expect([pexpect.TIMEOUT, 'password: ']) + if i == 0: # Timeout + print child.before, child.after + return None + child.sendline(password) + child.expect(pexpect.EOF) + print child.before + return child.before + +if __name__ == '__main__': + if not os.geteuid()==0: + sys.exit("root privileges are required to run this script") + else: + print "[INFO] Trying to install pexpect ..." + if install_pexpect() != 0: + sys.exit("[FAIL] pexpect installation failed") + print "[INFO] Adding new user ..." + if os.system("userdel sshtest; useradd sshtest && echo sshtest | passwd --stdin sshtest") != 0: + sys.exit("[FAIL] can't add new user") + try: + ssh_command('sshtest','localhost','sshtest','/bin/ls') + except Exception, e: + sys.exit("[FAIL] SSH could not login") + else: + print "[INFO] SSH user login test: PASS" + + + diff --git a/tests/p_postfix/0-install_postfix.sh b/tests/p_postfix/0-install_postfix.sh new file mode 100755 index 0000000..ca4c382 --- /dev/null +++ b/tests/p_postfix/0-install_postfix.sh @@ -0,0 +1,8 @@ +#!/bin/bash +# Author: Athmane Madjoudj + +# Postfix +yum -y install postfix +yum -y remove sendmail +service postfix start + diff --git a/tests/p_postfix/postfix_smtp.sh b/tests/p_postfix/postfix_smtp.sh new file mode 100755 index 0000000..0150aed --- /dev/null +++ b/tests/p_postfix/postfix_smtp.sh @@ -0,0 +1,11 @@ +#!/bin/sh +# Author: Athmane Madjoudj + +echo -n "Postfix SMTP test: " +echo "helo test" | nc localhost 25 | grep '250' > /dev/null 2>&1 +if [ $? -eq 0 ]; then + echo 'PASS' +else + echo 'FAIL' + exit 1 +fi diff --git a/tests/p_vsftpd/0-install_vsftpd.sh b/tests/p_vsftpd/0-install_vsftpd.sh new file mode 100755 index 0000000..7fe8eb5 --- /dev/null +++ b/tests/p_vsftpd/0-install_vsftpd.sh @@ -0,0 +1,8 @@ +#!/bin/bash +# Author: Athmane Madjoudj + +# vsFTPd +yum -y install vsftpd +chkconfig vsftpd on +service vsftpd start + diff --git a/tests/p_vsftpd/vsftpd_anonymous_login.sh b/tests/p_vsftpd/vsftpd_anonymous_login.sh new file mode 100755 index 0000000..6c136e7 --- /dev/null +++ b/tests/p_vsftpd/vsftpd_anonymous_login.sh @@ -0,0 +1,11 @@ +#!/bin/sh +# Author: Athmane Madjoudj + +echo -n "vsFTPd anonymous can login test: " +echo -e "user anonymous\npass password\nquit" | nc localhost 21 | grep "230 Login successful." > /dev/null 2>&1 +if [ $? -eq 0 ]; then + echo 'PASS' +else + echo 'FAIL' + exit 1 +fi