#!/bin/bash # (C)2009 DatuX - Released under GPL # Asterisk web gui config test. # Maak asterisk gereed voor tests, door hem te configgen via de webgui source testlib || exit 1 DESCRIPTION1="Sla test over indien we niet de juiste licentieoptie hebben." CMD="cat /etc/webint/REG" VERIFYPOSITIVE='"VAGU"' if ! sshtest; then echo "Dit is geen voiceserver, test overgeslagen" exit 0 fi DESCRIPTION1="Asterisk aanwezig in portal?" URL="http://$IP/syn3/webportal/" VERIFYPOSITIVE="Asterisk" web_add web_test || exit 1 DESCRIPTION1="Main page" URL="http://$IP:8088/asterisk/static/config/index.html" VERIFYPOSITIVE="main_logo" web_add web_test || exit 1 #begin nieuwe asterisk test set asterisk_new() { web_new DESCRIPTION1="Login op webui" URL="http://$IP:8088/asterisk/rawman?action=login&username=admin&secret=syn3" VERIFYPOSITIVE="Response: Success" VERIFYNEGATIVE="Error" #Cookies werken niet goed op 1 of andere manier, door incompatiblility tussen libwwwperl en asterisk_gui, #vandaar dat we de session id zelf meegeven! PARSERESPONSE='mansession_id="|";' web_add } asterisk_new #voeg test toe aan asterisk asterisk_add() { #strip the beginning, so that we can be lazy and pass wrong ip nummers to this function. STRIPPED_REQ=`echo "$1"|cut -f2 -d?` DESCRIPTION1="Asterisk test: $DESCRIPTION1" URL="http://$IP:8088/asterisk/rawman?mansession_id={PARSEDRESULT}&$STRIPPED_REQ" VERIFYPOSITIVE2="Response: (Success|Pong|Follows)" VERIFYNEGATIVE="Error" web_add } #voer asterisk tests uit asterisk_test() { web_test || exit 1 asterisk_new } #voeg data toe die rechtstreeks uit httpfox logs komt. is handiger en sneller #played het ook gelijk asterisk_replay() { asterisk_new for LINE in `echo "$1" | cut -f2 -d'?'`; do asterisk_add "$LINE" done asterisk_test } #Asterisk tests toevoegen: # Het ip adres hoeft niet te kloppen, word gestript, lekker handig met kopieren en plakken vanaf HttpFox firefox extentie. # Je doet iets met de asterisk_gui en copy/paste de 'rawman' dingen uit HttpFox info "Simpelle ping om te kijken of de webgui en asterisk basics werken:"; asterisk_add "http://192.168.13.150:8088/asterisk/rawman?action=ping" info "Voeg onze datux centrale als sip trunk toe: nummer 650, ip 192.168.13.1, password 'test'"; asterisk_add "http://192.168.13.150:8088/asterisk/rawman?action=updateconfig&srcfilename=users.conf&dstfilename=users.conf&Action-000000=delcat&Cat-000000=650&Var-000000=&Value-000000=&Action-000001=newcat&Cat-000001=650&Var-000001=&Value-000001=&Action-000002=append&Cat-000002=650&Var-000002=context&Value-000002=DID_650&Action-000003=append&Cat-000003=650&Var-000003=host&Value-000003=192.168.13.1&Action-000004=append&Cat-000004=650&Var-000004=trunkname&Value-000004=regressie%20test%20%3B%20GUI%20metadata&Action-000005=append&Cat-000005=650&Var-000005=username&Value-000005=650" asterisk_add "http://192.168.13.150:8088/asterisk/rawman?action=updateconfig&srcfilename=users.conf&dstfilename=users.conf&Action-000000=append&Cat-000000=650&Var-000000=secret&Value-000000=test&Action-000001=append&Cat-000001=650&Var-000001=hasiax&Value-000001=no&Action-000002=append&Cat-000002=650&Var-000002=registeriax&Value-000002=no&Action-000003=append&Cat-000003=650&Var-000003=hassip&Value-000003=yes&Action-000004=append&Cat-000004=650&Var-000004=registersip&Value-000004=yes&Action-000005=append&Cat-000005=650&Var-000005=trunkstyle&Value-000005=voip" asterisk_add "http://192.168.13.150:8088/asterisk/rawman?action=updateconfig&srcfilename=users.conf&dstfilename=users.conf&Action-000000=append&Cat-000000=650&Var-000000=hasexten&Value-000000=no&Action-000001=append&Cat-000001=650&Var-000001=disallow&Value-000001=all&Action-000002=append&Cat-000002=650&Var-000002=allow&Value-000002=all" asterisk_add "http://192.168.13.150:8088/asterisk/rawman?action=updateconfig&srcfilename=extensions.conf&dstfilename=extensions.conf&Action-000000=delcat&Cat-000000=DID_650&Var-000000=&Value-000000=&Action-000001=newcat&Cat-000001=DID_650&Var-000001=&Value-000001=&Action-000002=delcat&Cat-000002=DID_650_default&Var-000002=&Value-000002=&Action-000003=newcat&Cat-000003=DID_650_default&Var-000003=&Value-000003=&Action-000004=append&Cat-000004=DID_650&Var-000004=include&Value-000004=DID_650_default&Action-000005=update&Cat-000005=globals&Var-000005=650&Value-000005=SIP%2F650" asterisk_test info "outgoing dial rule voor datux" asterisk_replay " http://192.168.13.150:8088/asterisk/rawman?action=updateconfig&srcfilename=extensions.conf&dstfilename=extensions.conf&Action-000000=delete&Cat-000000=CallingRule_datuxtestnr&Var-000000=exten&Value-000000=&Match-000000=_111%2C1%2CMacro(trunkdial-failover-0.3%2C%24%7B650%7D%2F%24%7BEXTEN%3A0%7D%2C%2C650%2C) http://192.168.13.150:8088/asterisk/rawman?action=updateconfig&srcfilename=extensions.conf&dstfilename=extensions.conf&Action-000000=newcat&Cat-000000=CallingRule_datuxtestnr&Var-000000=&Value-000000=&Action-000001=append&Cat-000001=CallingRule_datuxtestnr&Var-000001=exten&Value-000001=_111%2C1%2CMacro(trunkdial-failover-0.3%2C%24%7B650%7D%2F%24%7BEXTEN%3A0%7D%2C%2C650%2C) " info "Dialplan maken"; asterisk_replay " 00:00:03.214 0.175 1187 153 GET 200 text/plain http://192.168.13.150:8088/asterisk/rawman?action=updateconfig&srcfilename=extensions.conf&dstfilename=extensions.conf&Action-000000=delcat&Cat-000000=DLPN_DialPlan1&Var-000000=&Value-000000=&Action-000001=newcat&Cat-000001=DLPN_DialPlan1&Var-000001=&Value-000001=&Action-000002=append&Cat-000002=DLPN_DialPlan1&Var-000002=include&Value-000002=CallingRule_datuxtestnr&Action-000003=append&Cat-000003=DLPN_DialPlan1&Var-000003=include&Value-000003=default&Action-000004=append&Cat-000004=DLPN_DialPlan1&Var-000004=include&Value-000004=parkedcalls&Action-000005=append&Cat-000005=DLPN_DialPlan1&Var-000005=include&Value-000005=conferences 00:00:03.426 0.820 1209 153 GET 200 text/plain http://192.168.13.150:8088/asterisk/rawman?action=updateconfig&srcfilename=extensions.conf&dstfilename=extensions.conf&Action-000000=append&Cat-000000=DLPN_DialPlan1&Var-000000=include&Value-000000=ringgroups&Action-000001=append&Cat-000001=DLPN_DialPlan1&Var-000001=include&Value-000001=voicemenus&Action-000002=append&Cat-000002=DLPN_DialPlan1&Var-000002=include&Value-000002=queues&Action-000003=append&Cat-000003=DLPN_DialPlan1&Var-000003=include&Value-000003=voicemailgroups&Action-000004=append&Cat-000004=DLPN_DialPlan1&Var-000004=include&Value-000004=directory&Action-000005=append&Cat-000005=DLPN_DialPlan1&Var-000005=include&Value-000005=pagegroups 00:00:03.470 0.114 515 153 GET 200 text/plain http://192.168.13.1:8088/asterisk/rawman?action=ping 00:00:03.543 0.830 766 153 GET 200 text/plain http://192.168.13.150:8088/asterisk/rawman?action=updateconfig&srcfilename=extensions.conf&dstfilename=extensions.conf&Action-000000=append&Cat-000000=DLPN_DialPlan1&Var-000000=include&Value-000000=page_an_extension 00:00:05.150 0.910 605 153 GET 200 text/plain http://192.168.13.150:8088/asterisk/rawman?action=ping " for USER in `seq 100 105`; do info "Add user $USER"; asterisk_replay " http://192.168.13.150:8088/asterisk/rawman?action=updateconfig&srcfilename=users.conf&dstfilename=users.conf&Action-000000=delcat&Cat-000000=$USER&Var-000000=&Value-000000=&Action-000001=newcat&Cat-000001=$USER&Var-000001=&Value-000001=&Action-000002=append&Cat-000002=$USER&Var-000002=username&Value-000002=$USER&Action-000003=append&Cat-000003=$USER&Var-000003=transfer&Value-000003=yes&Action-000004=append&Cat-000004=$USER&Var-000004=disallow&Value-000004=all&Action-000005=append&Cat-000005=$USER&Var-000005=allow&Value-000005=all http://192.168.13.150:8088/asterisk/rawman?action=updateconfig&srcfilename=users.conf&dstfilename=users.conf&Action-000000=append&Cat-000000=$USER&Var-000000=mailbox&Value-000000=$USER&Action-000001=append&Cat-000001=$USER&Var-000001=call-limit&Value-000001=$USER&Action-000002=append&Cat-000002=$USER&Var-000002=fullname&Value-000002=testuser&Action-000003=append&Cat-000003=$USER&Var-000003=registersip&Value-000003=no&Action-000004=append&Cat-000004=$USER&Var-000004=host&Value-000004=dynamic&Action-000005=append&Cat-000005=$USER&Var-000005=callgroup&Value-000005=1 http://192.168.13.150:8088/asterisk/rawman?action=updateconfig&srcfilename=users.conf&dstfilename=users.conf&Action-000000=update&Cat-000000=$USER&Var-000000=fullname&Value-000000=testuser&Action-000001=update&Cat-000001=$USER&Var-000001=context&Value-000001=DLPN_DialPlan1&Action-000002=update&Cat-000002=$USER&Var-000002=cid_number&Value-000002=$USER&Action-000003=update&Cat-000003=$USER&Var-000003=hasvoicemail&Value-000003=yes&Action-000004=update&Cat-000004=$USER&Var-000004=vmsecret&Value-000004=&Action-000005=update&Cat-000005=$USER&Var-000005=email&Value-000005= http://192.168.13.150:8088/asterisk/rawman?action=updateconfig&srcfilename=users.conf&dstfilename=users.conf&Action-000000=update&Cat-000000=$USER&Var-000000=threewaycalling&Value-000000=yes&Action-000001=update&Cat-000001=$USER&Var-000001=hasdirectory&Value-000001=no&Action-000002=update&Cat-000002=$USER&Var-000002=callwaiting&Value-000002=yes&Action-000003=update&Cat-000003=$USER&Var-000003=hasmanager&Value-000003=no&Action-000004=delete&Cat-000004=$USER&Var-000004=managerread&Value-000004=&Action-000005=delete&Cat-000005=$USER&Var-000005=managerwrite&Value-000005= http://192.168.13.150:8088/asterisk/rawman?action=updateconfig&srcfilename=users.conf&dstfilename=users.conf&Action-000000=update&Cat-000000=$USER&Var-000000=hasagent&Value-000000=yes&Action-000001=update&Cat-000001=$USER&Var-000001=hassip&Value-000001=yes&Action-000002=update&Cat-000002=$USER&Var-000002=hasiax&Value-000002=no&Action-000003=update&Cat-000003=$USER&Var-000003=secret&Value-000003=&Action-000004=update&Cat-000004=$USER&Var-000004=nat&Value-000004=yes&Action-000005=update&Cat-000005=$USER&Var-000005=canreinvite&Value-000005=no http://192.168.13.150:8088/asterisk/rawman?action=updateconfig&srcfilename=users.conf&dstfilename=users.conf&Action-000000=update&Cat-000000=$USER&Var-000000=dtmfmode&Value-000000=rfc2833&Action-000001=update&Cat-000001=$USER&Var-000001=insecure&Value-000001=no&Action-000002=update&Cat-000002=$USER&Var-000002=pickupgroup&Value-000002=1&Action-000003=update&Cat-000003=$USER&Var-000003=call-limit&Value-000003=$USER&Action-000004=delete&Cat-000004=$USER&Var-000004=zapchan&Value-000004=&Action-000005=delete&Cat-000005=$USER&Var-000005=disallow&Value-000005= http://192.168.13.150:8088/asterisk/rawman?action=updateconfig&srcfilename=users.conf&dstfilename=users.conf&Action-000000=delete&Cat-000000=$USER&Var-000000=allow&Value-000000=&Action-000001=append&Cat-000001=$USER&Var-000001=disallow&Value-000001=all&Action-000002=append&Cat-000002=$USER&Var-000002=allow&Value-000002=ulaw%2Cgsm&Action-000003=update&Cat-000003=$USER&Var-000003=autoprov&Value-000003=no&Action-000004=update&Cat-000004=$USER&Var-000004=label&Value-000004=&Action-000005=update&Cat-000005=$USER&Var-000005=macaddress&Value-000005= http://192.168.13.150:8088/asterisk/rawman?action=updateconfig&srcfilename=users.conf&dstfilename=users.conf&Action-000000=update&Cat-000000=$USER&Var-000000=linenumber&Value-000000=1&Action-000001=update&Cat-000001=$USER&Var-000001=LINEKEYS&Value-000001=1 " done info "Ringgroup"; asterisk_replay " http://192.168.13.150:8088/asterisk/rawman?action=updateconfig&srcfilename=extensions.conf&dstfilename=extensions.conf&Action-000000=delcat&Cat-000000=ringroups-custom-1&Var-000000=&Value-000000=&Action-000001=delete&Cat-000001=ringgroups&Var-000001=exten&Value-000001=&Match-000001=700%2C1%2CGoto(ringroups-custom-1%7Cs%7C1) http://192.168.13.150:8088/asterisk/rawman?action=updateconfig&srcfilename=extensions.conf&dstfilename=extensions.conf&Action-000000=newcat&Cat-000000=ringroups-custom-1&Var-000000=&Value-000000=&Action-000001=append&Cat-000001=ringroups-custom-1&Var-000001=exten&Value-000001=s%2C1%2CNoOp(testringgroup)&Action-000002=append&Cat-000002=ringroups-custom-1&Var-000002=exten&Value-000002=s%2Cn%2CDial(SIP%2F100%26SIP%2F101%26SIP%2F102%2C20%2Ci)&Action-000003=append&Cat-000003=ringroups-custom-1&Var-000003=exten&Value-000003=s%2Cn%2CHangup http://192.168.13.150:8088/asterisk/rawman?action=updateconfig&srcfilename=extensions.conf&dstfilename=extensions.conf&Action-000000=append&Cat-000000=ringgroups&Var-000000=exten&Value-000000=700%2C1%2CGoto(ringroups-custom-1%7Cs%7C1) " info "Delete call queue" asterisk_replay " 00:03:01.579 0.520 581 153 GET 200 text/plain http://192.168.13.150:8088/asterisk/rawman?action=ping 00:03:03.217 0.158 785 153 GET 200 text/plain http://192.168.13.150:8088/asterisk/rawman?action=updateconfig&srcfilename=extensions.conf&dstfilename=extensions.conf&Action-000000=delete&Cat-000000=queues&Var-000000=exten&Value-000000=&Match-000000=800%2C1%2CQueue(%24%7BEXTEN%7D) 00:03:03.427 0.600 724 153 GET 200 text/plain http://192.168.13.150:8088/asterisk/rawman?action=updateconfig&srcfilename=queues.conf&dstfilename=queues.conf&Action-000000=delcat&Cat-000000=800&Var-000000=&Value-000000= 00:03:04.224 0.114 632 153 GET 200 text/plain http://192.168.13.150:8088/asterisk/rawman?action=getconfig&filename=queues.conf " info "Maak nieuwe queue" asterisk_replay " 00:02:54.873 0.530 581 153 GET 200 text/plain http://192.168.13.150:8088/asterisk/rawman?action=ping 00:02:59.858 0.510 581 153 GET 200 text/plain http://192.168.13.150:8088/asterisk/rawman?action=ping 00:03:03.612 0.710 771 153 GET 200 text/plain http://192.168.13.150:8088/asterisk/rawman?action=updateconfig&srcfilename=extensions.conf&dstfilename=extensions.conf&Action-000000=append&Cat-000000=queues&Var-000000=exten&Value-000000=800%2C1%2CQueue(%24%7BEXTEN%7D) 00:03:03.742 0.490 1087 153 GET 200 text/plain http://192.168.13.150:8088/asterisk/rawman?action=updateconfig&srcfilename=queues.conf&dstfilename=queues.conf&Action-000000=delcat&Cat-000000=800&Var-000000=&Value-000000=&Action-000001=newcat&Cat-000001=800&Var-000001=&Value-000001=&Action-000002=append&Cat-000002=800&Var-000002=fullname&Value-000002=testqueue&Action-000003=append&Cat-000003=800&Var-000003=strategy&Value-000003=ringall&Action-000004=append&Cat-000004=800&Var-000004=timeout&Value-000004=15&Action-000005=append&Cat-000005=800&Var-000005=wrapuptime&Value-000005=15 00:03:03.829 0.590 1106 153 GET 200 text/plain http://192.168.13.150:8088/asterisk/rawman?action=updateconfig&srcfilename=queues.conf&dstfilename=queues.conf&Action-000000=append&Cat-000000=800&Var-000000=autofill&Value-000000=no&Action-000001=append&Cat-000001=800&Var-000001=autopause&Value-000001=no&Action-000002=append&Cat-000002=800&Var-000002=joinempty&Value-000002=yes&Action-000003=append&Cat-000003=800&Var-000003=leavewhenempty&Value-000003=no&Action-000004=append&Cat-000004=800&Var-000004=reportholdtime&Value-000004=no&Action-000005=append&Cat-000005=800&Var-000005=maxlen&Value-000005=0 00:03:03.930 0.490 1136 153 GET 200 text/plain http://192.168.13.150:8088/asterisk/rawman?action=updateconfig&srcfilename=queues.conf&dstfilename=queues.conf&Action-000000=append&Cat-000000=800&Var-000000=musicclass&Value-000000=default&Action-000001=append&Cat-000001=800&Var-000001=member&Value-000001=Agent%2F100&Action-000002=append&Cat-000002=800&Var-000002=member&Value-000002=Agent%2F101&Action-000003=append&Cat-000003=800&Var-000003=member&Value-000003=Agent%2F102&Action-000004=append&Cat-000004=800&Var-000004=member&Value-000004=Agent%2F103&Action-000005=append&Cat-000005=800&Var-000005=member&Value-000005=Agent%2F104 00:03:04.180 0.490 741 153 GET 200 text/plain http://192.168.13.150:8088/asterisk/rawman?action=updateconfig&srcfilename=queues.conf&dstfilename=queues.conf&Action-000000=append&Cat-000000=800&Var-000000=member&Value-000000=Agent%2F105 00:03:04.894 0.830 605 153 GET 200 text/plain http://192.168.13.150:8088/asterisk/rawman?action=ping 00:03:05.675 0.185 632 153 GET 200 text/plain http://192.168.13.150:8088/asterisk/rawman?action=getconfig&filename=queues.conf " info "Voice menu 600" asterisk_replay " 00:00:03.157 0.149 1003 153 GET 200 text/plain http://192.168.13.150:8088/asterisk/rawman?action=updateconfig&srcfilename=extensions.conf&dstfilename=extensions.conf&Action-000000=delcat&Cat-000000=voicemenu-custom-1&Var-000000=&Value-000000=&Action-000001=delete&Cat-000001=voicemenus&Var-000001=exten&Value-000001=&Match-000001=600%2C1%2CGoto(voicemenu-custom-1%7Cs%7C1)&Action-000002=delete&Cat-000002=default&Var-000002=exten&Value-000002=&Match-000002=600%2C1%2CGoto(voicemenu-custom-1%7Cs%7C1) 00:00:03.841 0.650 1262 153 GET 200 text/plain http://192.168.13.150:8088/asterisk/rawman?action=updateconfig&srcfilename=extensions.conf&dstfilename=extensions.conf&Action-000000=delcat&Cat-000000=voicemenu-custom-1&Var-000000=&Value-000000=&Action-000001=newcat&Cat-000001=voicemenu-custom-1&Var-000001=&Value-000001=&Action-000002=append&Cat-000002=voicemenus&Var-000002=exten&Value-000002=600%2C1%2CGoto(voicemenu-custom-1%7Cs%7C1)&Action-000003=append&Cat-000003=voicemenu-custom-1&Var-000003=exten&Value-000003=s%2C1%2CNoOp(testmenu)&Action-000004=append&Cat-000004=voicemenu-custom-1&Var-000004=exten&Value-000004=s%2C2%2CBackground(beep)&Action-000005=append&Cat-000005=voicemenu-custom-1&Var-000005=exten&Value-000005=s%2C3%2CGoto(default%7C100%7C1) " info "Conference menu 500" asterisk_replay " 00:00:01.702 0.119 872 153 GET 200 text/plain http://192.168.13.150:8088/asterisk/rawman?action=updateconfig&srcfilename=extensions.conf&dstfilename=extensions.conf&Action-000000=delete&Cat-000000=conferences&Var-000000=exten&Value-000000=&Match-000000=500%2C1%2CMeetMe(%24%7BEXTEN%7D%7CMsI)&Action-000001=delete&Cat-000001=conferences&Var-000001=exten&Value-000001= 00:00:01.866 0.920 753 153 GET 200 text/plain http://192.168.13.150:8088/asterisk/rawman?action=updateconfig&dstfilename=meetme.conf&srcfilename=meetme.conf&Action-000000=delete&Cat-000000=rooms&Var-000000=conf&Value-000000=&Match-000000=500%2C%2C http://192.168.13.150:8088/asterisk/rawman?action=updateconfig&srcfilename=extensions.conf&dstfilename=extensions.conf&Action-000000=append&Cat-000000=conferences&Var-000000=exten&Value-000000=500%2C1%2CMeetMe(%24%7BEXTEN%7D%7CMsI) http://192.168.13.150:8088/asterisk/rawman?action=updateconfig&srcfilename=meetme.conf&dstfilename=meetme.conf&Action-000000=append&Cat-000000=rooms&Var-000000=conf&Value-000000=500%2C%2C " info "Followme op 103 " asterisk_replay " http://192.168.13.150:8088/asterisk/rawman?action=updateconfig&srcfilename=extensions.conf&dstfilename=extensions.conf&Action-000000=update&Cat-000000=globals&Var-000000=FOLLOWME_103&Value-000000=1 http://192.168.13.150:8088/asterisk/rawman?action=updateconfig&srcfilename=followme.conf&dstfilename=followme.conf&Action-000000=delcat&Cat-000000=103&Var-000000=&Value-000000=&Action-000001=newcat&Cat-000001=103&Var-000001=&Value-000001=&Action-000002=append&Cat-000002=103&Var-000002=musicclass&Value-000002=default&Action-000003=append&Cat-000003=103&Var-000003=context&Value-000003=DLPN_DialPlan1&Action-000004=append&Cat-000004=103&Var-000004=number&Value-000004=100%2C30 " info "Reload asterisk" asterisk_replay "http://192.168.13.1:8088/asterisk/rawman?mansession_id={PARSEDRESULT}&action=command&command=reload"