215_reg_good_multi_ok.py 1.6 KB

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