diff --git a/tests/p_ipa-server/0-preclean.sh b/tests/p_ipa-server/0-preclean.sh index f0ff32f..bce49d4 100755 --- a/tests/p_ipa-server/0-preclean.sh +++ b/tests/p_ipa-server/0-preclean.sh @@ -6,7 +6,7 @@ if (t_GetPkgRel basesystem | grep -q el6) then t_Log "Running $0 - Stopping and removing httpd if present" -if /sbin/service httpd status | grep 'is running...' &> /dev/null +if /sbin/service httpd status 2>&1 | grep 'is running...' &> /dev/null then /sbin/service httpd stop &> /dev/null fi @@ -17,7 +17,7 @@ rm -rf /etc/httpd fi t_Log "Running $0 - Stopping and removing bind if present" -if /sbin/service named status | grep 'is running...' &> /dev/null +if /sbin/service named status 2>&1 | grep 'is running...' &> /dev/null then /sbin/service named stop &> /dev/null fi diff --git a/tests/p_ipa-server/1-install_freeipa.sh b/tests/p_ipa-server/1-install_freeipa.sh index d20fb5a..f2301f1 100755 --- a/tests/p_ipa-server/1-install_freeipa.sh +++ b/tests/p_ipa-server/1-install_freeipa.sh @@ -5,7 +5,7 @@ if (t_GetPkgRel basesystem | grep -q el6) then t_Log "Running $0 - Installing packages" -t_InstallPackage ipa-server bind-dyndb-ldap +t_InstallPackage ipa-server bind-dyndb-ldap libsss_sudo &> /dev/null else echo "Skipped on CentOS 5" fi diff --git a/tests/p_ipa-server/2-configure_freeipa.sh b/tests/p_ipa-server/2-configure_freeipa.sh index 799d6b4..0cddcc5 100755 --- a/tests/p_ipa-server/2-configure_freeipa.sh +++ b/tests/p_ipa-server/2-configure_freeipa.sh @@ -6,9 +6,16 @@ then t_Log "Configuring IPA server" -ipa-server-install -U --hostname=c6test.c6ipa.local --ip-address=$(ip a s dev eth0 | awk '$0 ~ /scope global eth0/ {print $2}' | cut -d'/' -f 1) -r C6IPA.LOCAL -n c6ipa.local -p p455w0rd -a p455w0rd --ssh-trust-dns --setup-dns --forwarder=$(awk '$0 ~ /nameserver/ {print $2}' /etc/resolv.conf | head -n 1) +ipa-server-install -U --hostname=c6test.c6ipa.local --ip-address=$(ip a s dev eth0 | awk '$0 ~ /scope global eth0/ {print $2}' | cut -d'/' -f 1) -r C6IPA.LOCAL -n c6ipa.local -p p455w0rd -a p455w0rd --ssh-trust-dns --setup-dns --forwarder=$(awk '$0 ~ /nameserver/ {print $2}' /etc/resolv.conf | head -n 1) &> /dev/null t_CheckExitStatus $? +authconfig --enablemkhomedir --enablesssd --update +t_CheckExitStatus $? + +if /sbin/service sssd status | grep 'is stopped' &> /dev/null +then +/sbin/service sssd start &> /dev/null +fi else echo "Skipped on CentOS 5" diff --git a/tests/p_ipa-server/4-adduser.sh b/tests/p_ipa-server/4-adduser.sh index 78b6e02..48a42e4 100755 --- a/tests/p_ipa-server/4-adduser.sh +++ b/tests/p_ipa-server/4-adduser.sh @@ -29,8 +29,8 @@ t_CheckExitStatus $? t_Log "Running $0 - test adding user" -userdetails="$(ipa user-add --first=test --last=user --random testuser)" -echo "$userdetails" | grep 'Added user "testuser"' &> /dev/null +userdetails="$(ipa user-add --first=test --last=user --random ipatestuser)" +echo "$userdetails" | grep 'Added user "ipatestuser"' &> /dev/null t_CheckExitStatus $? @@ -48,7 +48,7 @@ echo "$userdetails" | grep 'Full name: test user' &> /dev/null t_CheckExitStatus $? -echo "$userdetails" | grep 'Home directory: /home/testuser' &> /dev/null +echo "$userdetails" | grep 'Home directory: /home/ipatestuser' &> /dev/null t_CheckExitStatus $? @@ -57,9 +57,9 @@ kdestroy &> /dev/null expect -f - &> /dev/null < /dev/null +klist | grep "ipatestuser@C6IPA.LOCAL" &> /dev/null t_CheckExitStatus $? diff --git a/tests/p_ipa-server/5-addservice.sh b/tests/p_ipa-server/5-addservice.sh index f539627..5af6d4b 100755 --- a/tests/p_ipa-server/5-addservice.sh +++ b/tests/p_ipa-server/5-addservice.sh @@ -28,16 +28,16 @@ t_CheckExitStatus $? t_Log "Running $0 - Adding test service" -ipa service-add testservice/c6test.c6ipa.local +ipa service-add testservice/c6test.c6ipa.local &> /dev/null t_CheckExitStatus $? t_Log "Running $0 - getting keytab for service" -ipa-getkeytab -s c6test.c6ipa.local -p testservice/c6test.c6ipa.local -k /tmp/testservice.keytab +ipa-getkeytab -s c6test.c6ipa.local -p testservice/c6test.c6ipa.local -k /tmp/testservice.keytab &> /dev/null t_CheckExitStatus $? t_Log "Running $0 - getting certificate for service" -ipa-getcert request -K testservice/c6test.c6ipa.local -D c6test.c6ipa.local -f /etc/pki/tls/certs/testservice.crt -k /etc/pki/tls/private/testservice.key +ipa-getcert request -K testservice/c6test.c6ipa.local -D c6test.c6ipa.local -f /etc/pki/tls/certs/testservice.crt -k /etc/pki/tls/private/testservice.key &> /dev/null t_CheckExitStatus $? while true diff --git a/tests/p_ipa-server/6-dnsdetails.sh b/tests/p_ipa-server/6-dnsdetails.sh index b8ed6f3..5eb71bf 100755 --- a/tests/p_ipa-server/6-dnsdetails.sh +++ b/tests/p_ipa-server/6-dnsdetails.sh @@ -28,14 +28,14 @@ t_CheckExitStatus $? #Add zone t_Log "Running $0 - Adding a subdomain 'testzone'" -ipa dnszone-add --name-server=c6test.c6ipa.local. --admin-email=hostmaster.testzone.c6ipa.local. testzone.c6ipa.local +ipa dnszone-add --name-server=c6test.c6ipa.local. --admin-email=hostmaster.testzone.c6ipa.local. testzone.c6ipa.local &> /dev/null t_CheckExitStatus $? #Can get SOA for new zone from DNS #Add record to standard zone t_Log "Running $0 - Adding a testrecord to main domain" -ipa dnsrecord-add c6ipa.local testrecord --cname-hostname=c6test +ipa dnsrecord-add c6ipa.local testrecord --cname-hostname=c6test &> /dev/null t_CheckExitStatus $? #Can get record from DNS @@ -45,7 +45,7 @@ t_CheckExitStatus $? #Add record to new zone t_Log "Running $0 - Adding a testrecord to subdomain" -ipa dnsrecord-add testzone.c6ipa.local testrecord --cname-hostname=c6test.c6ipa.local. +ipa dnsrecord-add testzone.c6ipa.local testrecord --cname-hostname=c6test.c6ipa.local. &> /dev/null t_CheckExitStatus $? #Can get record from DNS for new zone @@ -59,7 +59,7 @@ forwarder="$(sed -n '1,/forwarders/!{ /};/,/forwarders/!s/^//p;}' /etc/named.con sed -i '/forwarders/{N ; s/\n.*// }' /etc/named.conf service named restart t_CheckExitStatus $? -ipa dnsconfig-mod --forwarder=${forwarder} +ipa dnsconfig-mod --forwarder=${forwarder} &> /dev/null t_CheckExitStatus $? #Regression test of RHBA-2103-0739 diff --git a/tests/p_ipa-server/7-addsudo.sh b/tests/p_ipa-server/7-addsudo.sh index d5ae082..fdd0a3d 100755 --- a/tests/p_ipa-server/7-addsudo.sh +++ b/tests/p_ipa-server/7-addsudo.sh @@ -26,17 +26,59 @@ klist | grep "admin@C6IPA.LOCAL" &> /dev/null t_CheckExitStatus $? - - t_Log "Running $0 - test adding sudo command" -## add sudo command here to ipa +ipa sudorule-add test_rule --desc="Test rule in ipa testing" --hostcat=all --cmdcat=all --runasusercat=all --runasgroupcat=all &> /dev/null +t_CheckExitStatus $? +ipa sudorule-add-user test_rule --users="ipatestuser" &> /dev/null +t_CheckExitStatus $? + +t_Log "Running $0 - verifying sudo command is in freeipa" +sudodetails="$(ipa sudorule-show test_rule)" +echo "$sudodetails" | grep 'Rule name: test_rule' &> /dev/null +t_CheckExitStatus $? +echo "$sudodetails" | grep 'Description: Test rule in ipa testing' &> /dev/null +t_CheckExitStatus $? +echo "$sudodetails" | grep 'Enabled: TRUE' &> /dev/null +t_CheckExitStatus $? +echo "$sudodetails" | grep 'Host category: all' &> /dev/null +t_CheckExitStatus $? +echo "$sudodetails" | grep 'Command category: all' &> /dev/null +t_CheckExitStatus $? +echo "$sudodetails" | grep 'RunAs User category: all' &> /dev/null +t_CheckExitStatus $? +echo "$sudodetails" | grep 'RunAs Group category: all' &> /dev/null +t_CheckExitStatus $? +echo "$sudodetails" | grep 'Users: ipatestuser' &> /dev/null +t_CheckExitStatus $? t_Log "Running $0 - test adding sudo configuration" -## configure sssd and nsswitch for sudo here +echo "sudoers: files sss" >> /etc/nsswitch.conf +sed -i 's/services = nss, pam, ssh/services = nss, pam, ssh, sudo/' /etc/sssd/sssd.conf +sed -i 's/id_provider = ipa/id_provider = ipa\nsudo_provider = ldap\nldap_sudo_search_base = ou=sudoers,dc=c6ipa,dc=local\nldap_sasl_mech = GSSAPI/' /etc/sssd/sssd.conf +/sbin/service sssd restart &> /dev/null +/sbin/service sssd status | grep 'is running' &> /dev/null +t_CheckExitStatus $? + t_Log "Running $0 - test sudo works" -## do a sudo -l as a user here to verify it works +expect -f - &> /tmp/sudotestoutput.ipa-test < /dev/null +t_CheckExitStatus $? +grep '(ALL) ALL' /tmp/sudotestoutput.ipa-test &> /dev/null +t_CheckExitStatus $? else echo "Skipped on CentOS 5"