#!/bin/bash source $SDK_VERSIONS/testdata/pycipres.conf # These are all email accounts I have and use to create the # pycipres admin, guidemo admin and a pycipres eu account: E1=pycipres_eu@yahoo.com E2=ciprestester1@gmail.com E3=ciprestester2@gmail.com # These are other email accounts I have and can use for # additional end user accounts. E4=ciprestester3@gmail.com E5=cipresrest@gmail.com usage() { echo echo "You must supply username and password of a cipres admin account with -u username and -p password." echo "Note that the Rest Service must be up and running." echo echo "You can delete the accounts with 'userDelete account'. That command will delete" echo "the account, any applications that are owned by that account, and any users that are registered" echo "with the umbrella applications owned by that account." echo exit 1 } if [[ $# < 2 ]] ; then usage fi action=create while [[ $# > 1 ]] do key="$1" shift case $key in -u) AUSER="$1" shift ;; -p) APASS="$1" shift ;; -c) action=create ;; -d) action=delete ;; *) usage ;; esac done if [[ -z $AUSER || -z $APASS ]] ; then usage fi case $action in create) echo "===============================================================================================================" echo "Will create or update:" echo " $PYCIPRES_ADMIN - a rest admin" echo " $PYCIPRES_APP - direct auth application belonging to $PYCIPRES_ADMIN" echo " $PYCIPRES_EU - a direct end user" echo " " echo " $GUIDEMO_ADMIN - a rest admin" echo " $GUIDEMO_APP - umbrella app belonging to $GUIDEMO_ADMIN" echo " " echo " $GUIDEMO2_ADMIN - a rest admin" echo " $GUIDEMO2_APP - umbrella app belonging to $GUIDEMO2_ADMIN" echo "===============================================================================================================" echo " " echo "Contacting service at $URL: as cipres admin user: $AUSER" echo "Running : curl -k -u $AUSER:--- $URL/user/$PYCIPRES_ADMIN " echo "Create/update $PYCIPRES_ADMIN User" curl -k -u $AUSER:$APASS $URL/user/$PYCIPRES_ADMIN \ -d role=REST_ADMIN \ -d password=$TESTPASS\ -d email="$E2" \ -d first_name=$PYCIPRES_ADMIN \ -d last_name=$PYCIPRES_ADMIN echo "Create/update $PYCIPRES_APP Application" curl -k -u $AUSER:$APASS $URL/application/$PYCIPRES_ADMIN/$PYCIPRES_APP \ -d longname="pycipres scripts" \ -d authtype=DIRECT \ -d activate=true echo "Create/update $PYCIPRES_EU End User" curl -k -u $PYCIPRES_EU:$TESTPASS $URL/user/$PYCIPRES_EU \ -d role=REST_END_USER_DIRECT \ -d password=$TESTPASS\ -d appname=$PYCIPRES_APP \ -d email="$E1" \ -d first_name=$PYCIPRES_EU \ -d last_name=$PYCIPRES_EU echo "Create/update $GUIDEMO_ADMIN User" curl -k -u $AUSER:$APASS $URL/user/$GUIDEMO_ADMIN \ -d role=REST_ADMIN \ -d password=$TESTPASS\ -d email="$E3" \ -d first_name=$GUIDEMO_ADMIN \ -d last_name=$GUIDEMO_ADMIN echo "Create/update $GUIDEMO_APP Application" curl -k -u $AUSER:$APASS $URL/application/$GUIDEMO_ADMIN/$GUIDEMO_APP \ -d longname="web application demo" \ -d authtype=UMBRELLA \ -d activate=true echo "Create/update $GUIDEMO2_ADMIN User" curl -k -u $AUSER:$APASS $URL/user/$GUIDEMO2_ADMIN \ -d role=REST_ADMIN \ -d password=$TESTPASS\ -d email="$E4" \ -d first_name=$GUIDEMO2_ADMIN \ -d last_name=$GUIDEMO2_ADMIN echo "Create/update $GUIDEMO2_APP Application" curl -k -u $AUSER:$APASS $URL/application/$GUIDEMO2_ADMIN/$GUIDEMO2_APP \ -d longname="web application TWO demo" \ -d authtype=UMBRELLA \ -d activate=true ;; delete) echo "not implemented, use userDelete command instead." ;; esac