Skip to content
Permalink
Browse files

Add SIS_PERSONS -> midPoint test

  • Loading branch information
mederly committed Sep 28, 2018
1 parent e73ec49 commit be4a7239f5c23f9067a96443069f458ee1696a90
@@ -4,18 +4,16 @@ 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 1) || true
echo a2 >> /tmp/log
(docker-compose down -v ; sleep 1) || 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 >> /tmp/log
docker ps
! (docker ps | grep complex_midpoint-server_1)
! (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
}

@@ -72,6 +70,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" {
# skip TEMP
docker-compose down -v
}
@@ -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');
@@ -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');
@@ -84,7 +84,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)
@@ -105,8 +105,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
@@ -123,9 +123,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
@@ -138,6 +137,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 be4a723

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