Skip to content

Commit

Permalink
Add assert_task_success method
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Oct 1, 2018
1 parent ceafa77 commit 2d8dee2
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions library.bash
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ function wait_for_shibboleth_idp_start () {
return 1
}


# Checks the health of midPoint server
function check_health () {
echo Checking health...
Expand Down Expand Up @@ -98,6 +97,15 @@ function check_health_shibboleth_idp () {
}


function get_object () {
local TYPE=$1
local OID=$2
TMPFILE=$(mktemp /tmp/get.XXXXXX)
echo tmp file is $TMPFILE
curl -k --user administrator:5ecr3t -H "Content-Type: application/xml" -X GET "https://localhost:8443/midpoint/ws/rest/$TYPE/$OID" >$TMPFILE || (rm $TMPFILE ; return 1)
return 0
}

# Retrieves XML object and checks if the name matches
function get_and_check_object () {
TYPE=$1
Expand Down Expand Up @@ -190,8 +198,18 @@ function test_resource () {

function assert_task_success () {
local OID=$1
# TODO
return 0
get_object tasks $OID
TASK_STATUS=$(xmllint --xpath "/*/*[local-name()='resultStatus']/text()" $TMPFILE) || (echo "Couldn't extract task status from task $OID" ; cat $TMPFILE ; rm $TMPFILE ; return 1)
if [[ $TASK_STATUS = "success" ]]; then
echo "Task $OID status is OK"
rm $TMPFILE
return 0
else
echo "Task $OID status is not OK: $TASK_STATUS"
cat $TMPFILE
rm $TMPFILE
return 1
fi
}

function wait_for_task_completion () {
Expand Down

0 comments on commit 2d8dee2

Please sign in to comment.