| 1 |
import inc_sip as sip |
| 2 |
import inc_sdp as sdp |
| 3 |
|
| 4 |
pjsua = "--null-audio --id=sip:CLIENT --registrar sip:127.0.0.1:$PORT " + \ |
| 5 |
"--username theuser1 --realm python1 --password passwd --next-cred " + \ |
| 6 |
"--username theuser2 --realm python2 --password passwd " + \ |
| 7 |
"--auto-update-nat=0" |
| 8 |
|
| 9 |
req1 = sip.RecvfromTransaction("Initial registration", 401, |
| 10 |
include=["REGISTER sip"], |
| 11 |
resp_hdr=["WWW-Authenticate: Digest realm=\"python1\", nonce=\"1234\"", |
| 12 |
"WWW-Authenticate: Digest realm=\"python2\", nonce=\"6789\""], |
| 13 |
expect="SIP/2.0 401" |
| 14 |
) |
| 15 |
|
| 16 |
req2 = sip.RecvfromTransaction("Registration retry with auth (not allowed multiple auth)", 200, |
| 17 |
include=["REGISTER sip", |
| 18 |
"Authorization:", |
| 19 |
"realm=\"python1\"", |
| 20 |
"username=\"theuser1\"", |
| 21 |
"nonce=\"1234\"", |
| 22 |
"response="], |
| 23 |
expect="registration success", |
| 24 |
pj_config="PJSIP_AUTH_ALLOW_MULTIPLE_AUTH_HEADER.*: 0" |
| 25 |
) |
| 26 |
|
| 27 |
req3 = sip.RecvfromTransaction("Registration retry with auth (allowed multiple auth)", 200, |
| 28 |
include=["REGISTER sip", |
| 29 |
"Authorization:[\\s\\S]+Authorization:", |
| 30 |
"realm=\"python1\"", "realm=\"python2\"", |
| 31 |
"username=\"theuser1\"", "username=\"theuser2\"", |
| 32 |
"nonce=\"1234\"", "nonce=\"6789\"", |
| 33 |
"response="], |
| 34 |
expect="registration success", |
| 35 |
pj_config="PJSIP_AUTH_ALLOW_MULTIPLE_AUTH_HEADER.*: 1" |
| 36 |
) |
| 37 |
|
| 38 |
recvfrom_cfg = sip.RecvfromCfg("Multiple authentication challenges", |
| 39 |
pjsua, [req1, req2, req3], pj_config="PJSIP_AUTH_ALLOW_MULTIPLE_AUTH_HEADER") |