diff --git a/Jenkinsfile b/Jenkinsfile
index e854504..e200e2b 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -34,7 +34,7 @@ pipeline {
steps {
script {
try {
- sh '(docker image ls ; echo Destroying ; bin/destroy.sh ; docker image ls) 2>&1 | tee debug' // temporary
+ sh '(ls -l ; docker ps -a ; docker image ls ; echo Destroying ; bin/destroy.sh ; docker image ls) 2>&1 | tee debug' // temporary
sh './download-midpoint 2>&1 | tee -a debug'
sh 'bin/rebuild.sh 2>&1 | tee -a debug'
//sh 'echo Build output ; cat debug'
@@ -54,6 +54,8 @@ pipeline {
sh 'bin/test.sh 2>&1 | tee debug'
sh '(cd demo/simple ; bats tests ) 2>&1 | tee -a debug'
sh '(cd demo/shibboleth ; bats tests ) 2>&1 | tee -a debug'
+ sh '(echo Checking if xpath is present ; xpath || true ) 2>&1 | tee -a debug'
+ sh '(cd demo/complex ; bats tests ) 2>&1 | tee -a debug'
// sh 'echo Test output ; cat debug'
} catch (error) {
def error_details = readFile('./debug')
diff --git a/demo/complex/tests/main.bats b/demo/complex/tests/main.bats
new file mode 100755
index 0000000..3009bd5
--- /dev/null
+++ b/demo/complex/tests/main.bats
@@ -0,0 +1,60 @@
+#!/usr/bin/env bats
+
+load ../../../common
+load ../../../library
+
+@test "000 Cleanup before running the tests" {
+# skip
+ run docker-compose down -v
+}
+
+@test "010 Initialize and start the composition" {
+# skip
+ docker-compose up -d
+ wait_for_midpoint_start complex_midpoint-server_1
+# TODO wait for shibboleth, grouper-ui, (also something other?)
+}
+
+@test "010 Check midPoint health" {
+ check_health
+}
+
+@test "020 Check Grouper health" {
+ skip TODO
+}
+
+@test "100 Get 'administrator'" {
+ check_health
+ get_and_check_object users 00000000-0000-0000-0000-000000000002 administrator
+}
+
+@test "110 And and get 'test110'" {
+ check_health
+ echo "test110" >/tmp/test110.xml
+ add_object users /tmp/test110.xml
+ rm /tmp/test110.xml
+ search_and_check_object users test110
+# TODO delete user after
+}
+
+@test "200 Upload objects" {
+ 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
+}
+
+@test "210 Test resource" {
+ test_resource 0a37121f-d515-4a23-9b6d-554c5ef61272
+ test_resource 6dcb84f5-bf82-4931-9072-fbdf87f96442
+ test_resource 13660d60-071b-4596-9aa1-5efcd1256c04
+ test_resource 4d70a0da-02dd-41cf-b0a1-00e75d3eaa15
+}
+
+@test "999 Clean up" {
+ docker-compose down -v
+}
diff --git a/library.bash b/library.bash
index e605ab5..3fa16cd 100644
--- a/library.bash
+++ b/library.bash
@@ -62,8 +62,8 @@ function get_and_check_object () {
# TODO Returns the OID in OID variable
# it can be found in the following HTTP reader returned: Location: "https://localhost:8443/midpoint/ws/rest/users/85e62669-d36b-41ce-b4f1-1ffdd9f66262"
function add_object () {
- TYPE=$1
- FILE=$2
+ local TYPE=$1
+ local FILE=$2
echo "Adding to $TYPE from $FILE..."
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
@@ -95,8 +95,8 @@ EOF
# Searches for object with a given name and verifies it was found
function search_and_check_object () {
- TYPE=$1
- NAME=$2
+ local TYPE=$1
+ local NAME=$2
search_objects_by_name $TYPE $NAME || return 1
if (grep -q "$NAME" <$SEARCH_RESULT_FILE); then
echo "Object $TYPE/'$NAME' is OK"
@@ -109,3 +109,22 @@ function search_and_check_object () {
return 1
fi
}
+
+# Tests a resource
+function test_resource () {
+ local OID=$1
+ local TMPFILE=$(mktemp /tmp/test.resource.XXXXXX)
+ local TMPFILE_ERR=$(mktemp /tmp/test.resource.err.XXXXXX)
+
+ curl -k --user administrator:5ecr3t -H "Content-Type: application/xml" -X POST "https://localhost:8443/midpoint/ws/rest/resources/$OID/test" >$TMPFILE || (rm $TMPFILE $TMPFILE_ERR ; return 1)
+ if [[ $(xpath -q -e "*/status/text()" < $TMPFILE) == "success" ]]; then
+ echo "Resource $OID test succeeded"
+ rm $TMPFILE
+ return 0
+ else
+ echo "Resource $OID test failed"
+ cat $TMPFILE
+ rm $TMPFILE
+ return 1
+ fi
+}