Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
skublik committed Sep 28, 2018
2 parents baca108 + 5e531e0 commit 0939675
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 24 deletions.
2 changes: 1 addition & 1 deletion container_files/httpd/conf/midpoint.conf.auth.internal
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ Timeout 2400
ProxyTimeout 2400
ProxyBadHeader Ignore

ProxyPass /midpoint ajp://localhost:9090/midpoint timeout=2400
ProxyPass /midpoint ajp://localhost:9090/midpoint timeout=2400 retry=0
2 changes: 1 addition & 1 deletion container_files/httpd/conf/midpoint.conf.auth.shibboleth
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Timeout 2400
ProxyTimeout 2400
ProxyBadHeader Ignore

ProxyPass /midpoint ajp://localhost:9090/midpoint timeout=2400
ProxyPass /midpoint ajp://localhost:9090/midpoint timeout=2400 retry=0

<Location /midpoint>
AuthType shibboleth
Expand Down
42 changes: 32 additions & 10 deletions demo/complex/tests/main.bats
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ load ../../../common
load ../../../library

@test "000 Cleanup before running the tests" {
pwd > /tmp/log
echo a1 >> /tmp/log
(cd ../shibboleth ; docker-compose down -v ; sleep 60) || true
echo a2 >> /tmp/log
(docker-compose down -v ; sleep 60) || true
echo a3 >> /tmp/log
(cd ../simple ; docker-compose down -v)
(cd ../shibboleth ; docker-compose down -v)
docker-compose down -v
}

@test "010 Initialize and start the composition" {
docker ps -a
docker-compose up -d
docker ps -a >> /tmp/log
docker ps
! (docker ps | grep -E "shibboleth_(idp|directory)_1|complex_(midpoint-server|midpoint-data)_1|simple_(midpoint-server|midpoint-data)_1")
cp tests/resources/sql/* sources/container_files/seed-data/
docker-compose up -d --build
}

@test "020 Wait until components are started" {
touch $BATS_TMPDIR/not-started
wait_for_midpoint_start complex_midpoint-server_1
wait_for_midpoint_start complex_midpoint-server_1 complex_midpoint-data_1
wait_for_shibboleth_idp_start complex_idp_1
rm $BATS_TMPDIR/not-started
# TODO wait for shibboleth, grouper-ui, (also something other?)
Expand Down Expand Up @@ -76,6 +76,28 @@ load ../../../library
test_resource 4d70a0da-02dd-41cf-b0a1-00e75d3eaa15
}

@test "220 Import SIS_PERSONS" {
if [ -e $BATS_TMPDIR/not-started ]; then skip 'not started'; fi

add_object tasks midpoint-objects-manual/tasks/task-import-sis-persons.xml
search_and_check_object tasks "Import from SIS persons"
wait_for_task_completion 22c2a3d0-0961-4255-9eec-c550a79aeaaa
assert_task_success 22c2a3d0-0961-4255-9eec-c550a79aeaaa

search_and_check_object users jsmith
search_and_check_object users banderson
search_and_check_object users kwhite
search_and_check_object users whenderson
search_and_check_object users ddavis
search_and_check_object users cmorrison
search_and_check_object users danderson
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
}

@test "999 Clean up" {
# docker-compose down -v
# skip TEMP
docker-compose down -v
}
31 changes: 31 additions & 0 deletions demo/complex/tests/resources/sql/courses.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
CREATE TABLE SIS_COURSES (
uid varchar(255) NOT NULL,
surname varchar(255) default NULL,
givenName varchar(255) default NULL,
courseId varchar(255) default NULL,
PRIMARY KEY (uid, courseId)
);

INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('kwhite','White','Karl','CS252');
INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('kwhite','White','Karl','ACCT201');
INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('kwhite','White','Karl','SCI404');
INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('kwhite','White','Karl','MATH100');
INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('whenderson','Henderson','William','ACCT101');
INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('ddavis','Davis','David','CS251');
INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('ddavis','Davis','David','MATH100');
INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('cmorrison','Morrison','Colin','ACCT101');
INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('cmorrison','Morrison','Colin','CS251');
INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('cmorrison','Morrison','Colin','MATH101');
INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('cmorrison','Morrison','Colin','ACCT201');
INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('danderson','Anderson','Donna','SCI123');
INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('danderson','Anderson','Donna','ACCT201');
INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('danderson','Anderson','Donna','MATH100');
INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('amorrison','Morrison','Ann','CS251');
INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('amorrison','Morrison','Ann','ACCT101');
INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('amorrison','Morrison','Ann','MATH101');
INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('wprice','Price','William','MATH100');
INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('wprice','Price','William','SCI404');
INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('mroberts','Roberts','Marie','SCI123');
INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('mroberts','Roberts','Marie','ACCT101');
INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('mroberts','Roberts','Marie','CS251');
INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('mroberts','Roberts','Marie','MATH101');
38 changes: 38 additions & 0 deletions demo/complex/tests/resources/sql/persons.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
CREATE TABLE SIS_PERSONS (
uid varchar(255) NOT NULL,
surname varchar(255) default NULL,
givenName varchar(255) default NULL,
fullName varchar(255) default NULL,
department varchar(255) default NULL,
mail varchar(255) default NULL,
PRIMARY KEY (uid)
);

CREATE TABLE SIS_AFFILIATIONS (
uid varchar(255) NOT NULL,
affiliation varchar(255) NOT NULL,
PRIMARY KEY (uid, affiliation)
);

INSERT INTO SIS_PERSONS (uid, surname, givenName, fullName, department, mail) VALUES ('jsmith','Smith','Joe','John Smith',NULL,NULL);
INSERT INTO SIS_PERSONS (uid, surname, givenName, fullName, department, mail) VALUES ('banderson','Anderson','Bob','Bob Anderson',NULL,NULL);
INSERT INTO SIS_PERSONS (uid, surname, givenName, fullName, department, mail) VALUES ('kwhite','White','Karl','Karl White','Law','kwhite@example.edu');
INSERT INTO SIS_AFFILIATIONS (uid, affiliation) VALUES ('kwhite','member');
INSERT INTO SIS_AFFILIATIONS (uid, affiliation) VALUES ('kwhite','student');
INSERT INTO SIS_PERSONS (uid, surname, givenName, fullName, department, mail) VALUES ('whenderson','Henderson','William','William Henderson','Advising','whenderson@example.edu');
INSERT INTO SIS_AFFILIATIONS (uid, affiliation) VALUES ('whenderson','community');
INSERT INTO SIS_PERSONS (uid, surname, givenName, fullName, department, mail) VALUES ('ddavis','Davis','David','David Davis','Computer Science','ddavis@example.edu');
INSERT INTO SIS_AFFILIATIONS (uid, affiliation) VALUES ('ddavis','staff');
INSERT INTO SIS_PERSONS (uid, surname, givenName, fullName, department, mail) VALUES ('cmorrison','Morrison','Colin','Colin Morrison','Financial Aid','cmorrison@example.edu');
INSERT INTO SIS_AFFILIATIONS (uid, affiliation) VALUES ('cmorrison','member');
INSERT INTO SIS_AFFILIATIONS (uid, affiliation) VALUES ('cmorrison','faculty');
INSERT INTO SIS_PERSONS (uid, surname, givenName, fullName, department, mail) VALUES ('danderson','Anderson','Donna','Donna Anderson','Account Payable','danderson@example.edu');
INSERT INTO SIS_AFFILIATIONS (uid, affiliation) VALUES ('danderson','member');
INSERT INTO SIS_PERSONS (uid, surname, givenName, fullName, department, mail) VALUES ('amorrison','Morrison','Ann','Ann Morrison','Law','amorrison@example.edu');
INSERT INTO SIS_AFFILIATIONS (uid, affiliation) VALUES ('amorrison','student');
INSERT INTO SIS_AFFILIATIONS (uid, affiliation) VALUES ('amorrison','alum');
INSERT INTO SIS_PERSONS (uid, surname, givenName, fullName, department, mail) VALUES ('wprice','Price','William','William Price','Account Payable','wprice@example.edu');
INSERT INTO SIS_AFFILIATIONS (uid, affiliation) VALUES ('wprice','community');
INSERT INTO SIS_PERSONS (uid, surname, givenName, fullName, department, mail) VALUES ('mroberts','Roberts','Marie','Marie Roberts','Law','mroberts@example.edu');
INSERT INTO SIS_AFFILIATIONS (uid, affiliation) VALUES ('mroberts','student');
INSERT INTO SIS_AFFILIATIONS (uid, affiliation) VALUES ('mroberts','community');
10 changes: 5 additions & 5 deletions demo/shibboleth/tests/main.bats
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,24 @@ load ../../../library
curl -k --write-out %{redirect_url} --silent --output /dev/null https://localhost:8443/midpoint | grep 'https:\/\/localhost:4443\/idp\/profile\/SAML2\/Redirect'
}

@test "041 Check Shibboleth redirection (/midpoint/)" {
@test "041 Check Shibboleth redirection (/midpoint/)" {
curl -k --write-out %{redirect_url} --silent --output /dev/null https://localhost:8443/midpoint/ | grep 'https:\/\/localhost:4443\/idp\/profile\/SAML2\/Redirect'
}

@test "042 Check Shibboleth redirection (/midpoint/login)" {
@test "042 Check Shibboleth redirection (/midpoint/login)" {
curl -k --write-out %{redirect_url} --silent --output /dev/null https://localhost:8443/midpoint/login | grep 'https:\/\/localhost:4443\/idp\/profile\/SAML2\/Redirect'
}

@test "043 Check Shibboleth redirection (/midpoint/something)" {
@test "043 Check Shibboleth redirection (/midpoint/something)" {
curl -k --write-out %{redirect_url} --silent --output /dev/null https://localhost:8443/midpoint/something | grep 'https:\/\/localhost:4443\/idp\/profile\/SAML2\/Redirect'
}

@test "044 Check SOAP without Shibboleth redirection (/midpoint/ws/)" {
@test "044 Check SOAP without Shibboleth redirection (/midpoint/ws/)" {
status="$(curl -k --write-out %{http_code} --silent --output /dev/null https://localhost:8443/midpoint/ws/)"
[ "$status" -eq 200 ]
}

@test "045 Check SOAP without Shibboleth redirection (/midpoint/model/)" {
@test "045 Check SOAP without Shibboleth redirection (/midpoint/model/)" {
status="$(curl -k --write-out %{http_code} --silent --output /dev/null https://localhost:8443/midpoint/model/)"
[ "$status" -eq 200 ]
}
Expand Down
27 changes: 20 additions & 7 deletions library.bash
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# Waits until midPoint starts
function wait_for_midpoint_start () {
CONTAINER_NAME=$1
DATABASE_CONTAINER_NAME=$2
ATTEMPT=0
MAX_ATTEMPTS=30
DELAY=10
Expand All @@ -23,6 +24,11 @@ function wait_for_midpoint_start () {
echo "========== Container log =========="
docker logs $CONTAINER_NAME 2>&1
echo "========== End of the container log =========="
if [ -n "$DATABASE_CONTAINER_NAME" ]; then
echo "========== Container log ($DATABASE_CONTAINER_NAME) =========="
docker logs $DATABASE_CONTAINER_NAME 2>&1
echo "========== End of the container log ($DATABASE_CONTAINER_NAME) =========="
fi
return 1
}

Expand Down Expand Up @@ -116,7 +122,7 @@ function add_object () {
# 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
NAME="$2"
TMPFILE=$(mktemp /tmp/search.XXXXXX)

curl -k --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)
Expand All @@ -137,8 +143,8 @@ EOF
# Searches for object with a given name and verifies it was found
function search_and_check_object () {
local TYPE=$1
local NAME=$2
search_objects_by_name $TYPE $NAME || return 1
local NAME="$2"
search_objects_by_name $TYPE "$NAME" || return 1
if (grep -q "<name>$NAME</name>" <$SEARCH_RESULT_FILE); then
echo "Object $TYPE/'$NAME' is OK"
rm $SEARCH_RESULT_FILE
Expand All @@ -155,9 +161,8 @@ function search_and_check_object () {
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)
curl -k --user administrator:5ecr3t -H "Content-Type: application/xml" -X POST "https://localhost:8443/midpoint/ws/rest/resources/$OID/test" >$TMPFILE || (rm $TMPFILE ; return 1)
if [[ $(xmllint --xpath "/*/*[local-name()='status']/text()" $TMPFILE) == "success" ]]; then
echo "Resource $OID test succeeded"
rm $TMPFILE
Expand All @@ -170,6 +175,14 @@ function test_resource () {
fi
}

function get_xpath () {
echo ok
function assert_task_success () {
local OID=$1
# TODO
return 0
}

function wait_for_task_completion () {
local OID=$1
sleep 60 # TODO
return 0
}

0 comments on commit 0939675

Please sign in to comment.