diff --git a/demo/complex/tests/main.bats b/demo/complex/tests/main.bats index 9daa28e..6ec5782 100755 --- a/demo/complex/tests/main.bats +++ b/demo/complex/tests/main.bats @@ -21,8 +21,8 @@ load ../../../library touch $BATS_TMPDIR/not-started wait_for_midpoint_start complex_midpoint-server_1 complex_midpoint-data_1 wait_for_shibboleth_idp_start complex_idp_1 + wait_for_grouper_ui_start complex_grouper-ui_1 rm $BATS_TMPDIR/not-started -# TODO wait for shibboleth, grouper-ui, (also something other?) } @test "040 Check midPoint health" { @@ -61,11 +61,26 @@ load ../../../library check_health pwd >&2 ./upload-objects + search_and_check_object objectTemplates template-org-course search_and_check_object objectTemplates template-org-department search_and_check_object objectTemplates template-role-affiliation search_and_check_object objectTemplates template-role-generic-group -# TODO check other objects that were uploaded + + search_and_check_object orgs courses + search_and_check_object orgs departments + + search_and_check_object resources "OpenLDAP (directory)" + search_and_check_object resources "Grouper SQL/MQ" + search_and_check_object resources "SQL SIS courses (sources)" + search_and_check_object resources "SQL SIS persons (sources)" + + search_and_check_object roles metarole-affiliation + search_and_check_object roles metarole-course + search_and_check_object roles metarole-department + search_and_check_object roles metarole-generic-group + search_and_check_object roles role-grouper-sysadmin + search_and_check_object roles role-ldap-basic } @test "210 Test resource" { @@ -94,7 +109,18 @@ load ../../../library search_and_check_object users amorrison search_and_check_object users wprice search_and_check_object users mroberts - # TODO check in LDAP, check assignments etc + + check_ldap_account_by_user_name jsmith complex_directory_1 + check_ldap_account_by_user_name banderson complex_directory_1 + check_ldap_account_by_user_name kwhite complex_directory_1 + check_ldap_account_by_user_name whenderson complex_directory_1 + check_ldap_account_by_user_name ddavis complex_directory_1 + check_ldap_account_by_user_name cmorrison complex_directory_1 + check_ldap_account_by_user_name danderson complex_directory_1 + check_ldap_account_by_user_name amorrison complex_directory_1 + check_ldap_account_by_user_name wprice complex_directory_1 + check_ldap_account_by_user_name mroberts complex_directory_1 + # TODO check assignments etc } @test "230 Check 'TestUser230' in Midpoint and LDAP" { diff --git a/demo/shibboleth/test.sh b/demo/shibboleth/test.sh deleted file mode 100755 index c23693b..0000000 --- a/demo/shibboleth/test.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -trap 'exitcode=$? ; error "Exiting $0 because of an error ($exitcode) occurred" ; exit $exitcode' ERR - -cd "$(dirname "$0")" -. ../../test/common.sh - -heading "Cleaning up containers and volumes if they exist" -docker-compose down -v || true -ok "Done" -echo - -heading "Composing and starting Shibboleth..." -docker-compose up --build -d -ok "OK" -echo - -# TODO wait for Shib to start - -heading "Composing and starting midPoint..." -pushd ../../midpoint -MPDIR=`pwd` -docker-compose down -v || true -env AUTHENTICATION=shibboleth docker-compose up --build -d -popd -$MPDIR/test/t010-wait-for-start.sh -ok "OK" -echo - -heading "Test 100: Checking health via HTTP..." -$MPDIR/test/t100-check-health.sh -ok "Health check passed" -echo diff --git a/library.bash b/library.bash index a61e833..f22a759 100644 --- a/library.bash +++ b/library.bash @@ -45,11 +45,17 @@ function wait_for_midpoint_start () { generic_wait_for_log $1 "INFO (com.evolveum.midpoint.web.boot.MidPointSpringApplication): Started MidPointSpringApplication in" "midPoint to start" "midPoint did not start" $2 } -# Waits until Shibboleth IDP starts ... TODO refactor using generic waiting function +# Waits until Shibboleth IDP starts function wait_for_shibboleth_idp_start () { generic_wait_for_log $1 "INFO:oejs.Server:main: Started" "shibboleth idp to start" "shibboleth idp did not start" $2 } +# Waits until Grouper UI starts +function wait_for_grouper_ui_start () { + generic_wait_for_log $1 "INFO org.apache.catalina.startup.Catalina- Server startup in" "grouper ui to start" "grouper ui did not start" $2 +} + + # Checks the health of midPoint server function check_health () { echo Checking health... @@ -219,8 +225,8 @@ function delete_object () { # Results of the search are in the $SEARCH_RESULT_FILE # TODO check if the result is valid (i.e. not an error) - return 1 if invalid, otherwise return 0 ("no objects" is considered OK here) function search_objects_by_name () { - TYPE=$1 - NAME="$2" + local TYPE=$1 + local NAME="$2" TMPFILE=$(mktemp /tmp/search.XXXXXX) curl -k --write-out %{http_code} --user administrator:5ecr3t -H "Content-Type: application/xml" -X POST "https://localhost:8443/midpoint/ws/rest/$TYPE/search" -d @- << EOF >$TMPFILE || (rm $TMPFILE ; return 1) @@ -233,15 +239,21 @@ function search_objects_by_name () { EOF - SEARCH_RESULT_FILE=$TMPFILE - - http_code=$(sed '$!d' <<<"$(cat $SEARCH_RESULT_FILE)") + local HTTP_CODE=$(sed '$!d' <<<"$(cat $TMPFILE)") + sed -i '$ d' $TMPFILE + cat $TMPFILE - sed -i '$ d' $SEARCH_RESULT_FILE - cat $SEARCH_RESULT_FILE - if [ "$http_code" -eq 200 ]; then + if [ "$HTTP_CODE" -eq 200 ]; then + SEARCH_RESULT_FILE=$TMPFILE return 0 else + echo "Error code: $HTTP_CODE" + if [ "$HTTP_CODE" -ge 500 ]; then + echo "Error message: Internal server error. Unexpected error occurred, if necessary please contact system administrator." + else + local ERROR_MESSAGE=$(xmllint --xpath "/*/*[local-name()='error']/text()" $TMPFILE) || (echo "Couldn't extract error message from file:" ; cat $TMPFILE ; rm $TMPFILE; return 1) + echo "Error message: $ERROR_MESSAGE" + fi rm $SEARCH_RESULT_FILE return 1 fi @@ -335,7 +347,7 @@ function search_ldap_object_by_filter () { } function check_ldap_account_by_user_name () { - local NAME=$1 + local NAME="$1" local LDAP_CONTAINER=$2 search_ldap_object_by_filter "ou=people,dc=internet2,dc=edu" "uid=$NAME" $LDAP_CONTAINER search_objects_by_name users $NAME @@ -360,8 +372,8 @@ function check_ldap_account_by_user_name () { } function check_of_ldap_membership () { - local NAME_OF_USER=$1 - local NAME_OF_GROUP=$2 + local NAME_OF_USER="$1" + local NAME_OF_GROUP="$2" local LDAP_CONTAINER=$3 search_ldap_object_by_filter "ou=people,dc=internet2,dc=edu" "uid=$NAME_OF_USER" $LDAP_CONTAINER