Alexandre Lision | 8af73cb | 2013-12-10 14:11:20 -0500 | [diff] [blame] | 1 | # $Id$ |
| 2 | import inc_sip as sip |
| 3 | import inc_sdp as sdp |
| 4 | |
| 5 | # Several PUBLISH failure scenarios that should be handled automatically |
| 6 | |
| 7 | |
| 8 | pjsua = "--null-audio --id=sip:127.0.0.1:$PORT --registrar sip:127.0.0.1:$PORT " + \ |
| 9 | "--realm=python --user=username --password=password " + \ |
| 10 | "--auto-update-nat=0 --publish" |
| 11 | #pjsua = "--null-audio --local-port 0 --rtp-port 0" |
| 12 | |
| 13 | # Handle REGISTER first |
| 14 | req1 = sip.RecvfromTransaction("Initial REGISTER", 200, |
| 15 | include=["REGISTER sip"], |
| 16 | exclude=[], |
| 17 | resp_hdr=["Expires: 1800"] |
| 18 | ) |
| 19 | |
| 20 | # First PUBLISH, reply with 412 |
| 21 | req2 = sip.RecvfromTransaction("Initial PUBLISH, will be replied with 412", 412, |
| 22 | include=["PUBLISH sip"], |
| 23 | exclude=["Expires:"] |
| 24 | ) |
| 25 | |
| 26 | # Second PUBLISH |
| 27 | req3 = sip.RecvfromTransaction("Second PUBLISH, will be replied with 200", 200, |
| 28 | include=["PUBLISH sip"], |
| 29 | exclude=["Expires:"], |
| 30 | resp_hdr=["Expires: 60", "SIP-ETag: dx200xyz"] |
| 31 | ) |
| 32 | |
| 33 | # PUBLISH refresh, respond with 408 |
| 34 | req4 = sip.RecvfromTransaction("PUBLISH refresh, will be replied with 408", 408, |
| 35 | include=["PUBLISH sip", "SIP-If-Match: dx200xyz"], |
| 36 | exclude=["Expires:"], |
| 37 | resp_hdr=["Expires: 60", "SIP-ETag: dx200xyz"] |
| 38 | ) |
| 39 | |
| 40 | # After 5 minutes, pjsua should retry again |
| 41 | req5 = sip.RecvfromTransaction("PUBLISH retry", 200, |
| 42 | include=["PUBLISH sip"], |
| 43 | exclude=["Expires:", "SIP-If-Match:"], |
| 44 | resp_hdr=["Expires: 60", "SIP-ETag: abc"] |
| 45 | ) |
| 46 | |
| 47 | |
| 48 | |
| 49 | recvfrom_cfg = sip.RecvfromCfg("PUBLISH scenarios", |
| 50 | pjsua, [req1, req2, req3]) |
| 51 | |