Skip to content
Permalink
Browse files

Merge remote-tracking branch 'origin/bats'

  • Loading branch information
mederly committed Oct 3, 2018
2 parents 43f7b7a + 38f496d commit 4cc9451b0519a7162a6fcf3533a48e0fb9dfbc5a
@@ -105,15 +105,9 @@ load ../../../library
rm /tmp/testuser230.xml
search_and_check_object users TestUser230

add_object tasks tests/resources/task/recom-role-grouper-sysadmin.xml
search_and_check_object tasks "Recompute role-grouper-sysadmin"
wait_for_task_completion 22c2a3d0-0961-4255-9eec-caasa79aeaaa 6 10
assert_task_success 22c2a3d0-0961-4255-9eec-caasa79aeaaa

add_object tasks tests/resources/task/assign-role-grouper-sysadmin-to-test-user.xml
search_and_check_object tasks "Assign role-grouper-sysadmin to TestUser230"
wait_for_task_completion 22c2a3d0-0961-4255-9eec-c550a791237s 6 10
assert_task_success 22c2a3d0-0961-4255-9eec-c550a791237s
execute_bulk_action tests/resources/bulk-action/recom-role-grouper-sysadmin.xml

execute_bulk_action tests/resources/bulk-action/assign-role-grouper-sysadmin-to-test-user.xml

check_ldap_account_by_user_name TestUser230 complex_directory_1
check_of_ldap_membership TestUser230 sysadmingroup complex_directory_1
@@ -0,0 +1,22 @@
<scext:executeScript xmlns:scext="http://midpoint.evolveum.com/xml/ns/public/model/scripting/extension-3">
<s:search xmlns:s="http://midpoint.evolveum.com/xml/ns/public/model/scripting-3"
xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<s:type>c:UserType</s:type>
<s:searchFilter>
<q:equal>
<q:path>c:name</q:path>
<q:value>TestUser230</q:value>
</q:equal>
</s:searchFilter>
<s:action>
<s:type>assign</s:type>
<s:parameter>
<s:name>role</s:name>
<c:value xsi:type="xsd:string">d48ec05b-fffd-4262-acd3-d9ff63365b62</c:value>
</s:parameter>
</s:action>
</s:search>
</scext:executeScript>
@@ -0,0 +1,16 @@
<scext:executeScript xmlns:scext="http://midpoint.evolveum.com/xml/ns/public/model/scripting/extension-3"
xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3"
xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3">
<s:search xmlns:s="http://midpoint.evolveum.com/xml/ns/public/model/scripting-3">
<s:type>c:RoleType</s:type>
<s:searchFilter>
<q:equal>
<q:path>name</q:path>
<q:value>role-grouper-sysadmin</q:value>
</q:equal>
</s:searchFilter>
<s:action>
<s:type>recompute</s:type>
</s:action>
</s:search>
</scext:executeScript>

This file was deleted.

This file was deleted.

@@ -15,8 +15,7 @@ load ../../../library

@test "020 Initialize and start Shibboleth" {
docker-compose up -d
# TODO implement wait_for_shibboleth_start
sleep 60
wait_for_shibboleth_idp_start shibboleth_idp_1
}

@test "030 Check health" {
@@ -47,24 +47,7 @@ function wait_for_midpoint_start () {

# Waits until Shibboleth IDP starts ... TODO refactor using generic waiting function
function wait_for_shibboleth_idp_start () {
CONTAINER_NAME=$1
ATTEMPT=0
MAX_ATTEMPTS=20
DELAY=10

until [[ $ATTEMPT = $MAX_ATTEMPTS ]]; do
ATTEMPT=$((ATTEMPT+1))
echo "Waiting $DELAY seconds for Shibboleth IDP to start (attempt $ATTEMPT) ..."
sleep $DELAY
docker ps
( docker logs $CONTAINER_NAME 2>&1 | grep "INFO:oejs.Server:main: Started" ) && return 0
done

echo Shibboleth IDP did not start in $(( $MAX_ATTEMPTS * $DELAY )) seconds in $CONTAINER_NAME
echo "========== Container log =========="
docker logs $CONTAINER_NAME 2>&1
echo "========== End of the container log =========="
return 1
generic_wait_for_log $1 "INFO:oejs.Server:main: Started" "shibboleth idp to start" "shibboleth idp did not start" $2
}

# Checks the health of midPoint server
@@ -155,10 +138,41 @@ function add_object () {
fi
return 1
fi
#curl -k --user administrator:5ecr3t -H "Content-Type: application/xml" -X POST "https://localhost:8443/midpoint/ws/rest/$TYPE" -d @$FILE || return 1
#TODO check the returned XML
}

function execute_bulk_action () {
local FILE=$1
echo "Executing bulk action from $FILE..."
TMPFILE=$(mktemp /tmp/execbulkaction.XXXXXX)

curl -k --silent --write-out "%{http_code}" --user administrator:5ecr3t -H "Content-Type: application/xml" -X POST "https://localhost:8443/midpoint/ws/rest/rpc/executeScript" -d @$FILE >$TMPFILE
local HTTP_CODE=$(sed '$!d' $TMPFILE)
sed -i '$ d' $TMPFILE

if [ "$HTTP_CODE" -eq 200 ]; then

local STATUS=$(xmllint --xpath "/*/*/*[local-name()='status']/text()" $TMPFILE) || (echo "Couldn't extract status from file:" ; cat $TMPFILE ; rm $TMPFILE; return 1)
if [ $STATUS = "success" ]; then
rm $TMPFILE
return 0
else
echo "Bulk action status is not OK: $STATUS"
local CONSOLE_OUTPUT=$(xmllint --xpath "/*/*/*[local-name()='consoleOutput']/text()" $TMPFILE) || (echo "Couldn't extract console output from file:" ; cat $TMPFILE ; rm $TMPFILE; return 1)
echo "Console output: $CONSOLE_OUTPUT"
rm $TMPFILE
return 1
fi

else
echo "Error code: $HTTP_CODE"
if [ "$http_code" -eq 500 ]; then
echo "Error message: Internal server error. Unexpected error occurred, if necessary please contact system administrator."
fi
return 1
fi
}


# Tries to find an object with a given name
# 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)

0 comments on commit 4cc9451

Please sign in to comment.
You can’t perform that action at this time.