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 | # In this test we simulate broken server, where: |
| 6 | # - it wants to signal that NONCE has change |
| 7 | # - but it sets stale=false |
| 8 | # For this case pjsip will retry authentication until |
| 9 | # PJSIP_MAX_STALE_COUNT is exceeded. |
| 10 | # |
| 11 | |
| 12 | pjsua = "--null-audio --id=sip:CLIENT --registrar sip:127.0.0.1:$PORT " + \ |
| 13 | "--realm=python --user=username --password=password" |
| 14 | |
| 15 | req1 = sip.RecvfromTransaction("Initial request", 401, |
| 16 | include=["REGISTER sip"], |
| 17 | exclude=["Authorization"], |
| 18 | resp_hdr=["WWW-Authenticate: Digest realm=\"python\", nonce=\"1\""] |
| 19 | ) |
| 20 | |
| 21 | req2 = sip.RecvfromTransaction("First retry", 401, |
| 22 | include=["REGISTER sip", "Authorization", "nonce=\"1\""], |
| 23 | exclude=["Authorization:[\\s\\S]+Authorization:"], |
| 24 | resp_hdr=["WWW-Authenticate: Digest realm=\"python\", nonce=\"2\", stale=true"] |
| 25 | ) |
| 26 | |
| 27 | req3 = sip.RecvfromTransaction("Second retry retry", 401, |
| 28 | include=["REGISTER sip", "Authorization", "nonce=\"2\""], |
| 29 | exclude=["Authorization:[\\s\\S]+Authorization:"], |
| 30 | resp_hdr=["WWW-Authenticate: Digest realm=\"python\", nonce=\"3\", stale=true"] |
| 31 | ) |
| 32 | |
| 33 | req4 = sip.RecvfromTransaction("Third retry", 401, |
| 34 | include=["REGISTER sip", "Authorization", "nonce=\"3\""], |
| 35 | exclude=["Authorization:[\\s\\S]+Authorization:"], |
| 36 | resp_hdr=["WWW-Authenticate: Digest realm=\"python\", nonce=\"4\", stale=true"], |
| 37 | expect="PJSIP_EAUTHSTALECOUNT" |
| 38 | ) |
| 39 | |
| 40 | recvfrom_cfg = sip.RecvfromCfg("Failed registration retry (server rejects with stale=true) ", |
| 41 | pjsua, [req1, req2, req3, req4]) |