234_reg_bad_stale_ok.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import inc_sip as sip
  2. import inc_sdp as sdp
  3. # In this test we simulate broken server, where it wants to
  4. # change the nonce, but it fails to set stale to true. In this
  5. # case, we should expect pjsip to retry the authentication until
  6. # PJSIP_MAX_STALE_COUNT is exceeded as it should have detected
  7. # that that nonce has changed
  8. pjsua = "--null-audio --id=sip:CLIENT --registrar sip:127.0.0.1:$PORT " + \
  9. "--realm=python --user=username --password=password " + \
  10. "--auto-update-nat=0"
  11. req1 = sip.RecvfromTransaction("Initial request", 401,
  12. include=["REGISTER sip"],
  13. exclude=["Authorization"],
  14. resp_hdr=["WWW-Authenticate: Digest realm=\"python\", nonce=\"1\""]
  15. )
  16. req2 = sip.RecvfromTransaction("First retry", 401,
  17. include=["REGISTER sip", "Authorization", "nonce=\"1\""],
  18. exclude=["Authorization:[\\s\\S]+Authorization:"],
  19. resp_hdr=["WWW-Authenticate: Digest realm=\"python\", nonce=\"2\""]
  20. )
  21. req3 = sip.RecvfromTransaction("Second retry retry", 401,
  22. include=["REGISTER sip", "Authorization", "nonce=\"2\""],
  23. exclude=["Authorization:[\\s\\S]+Authorization:"],
  24. resp_hdr=["WWW-Authenticate: Digest realm=\"python\", nonce=\"3\""]
  25. )
  26. req4 = sip.RecvfromTransaction("Third retry", 200,
  27. include=["REGISTER sip", "Authorization", "nonce=\"3\""],
  28. exclude=["Authorization:[\\s\\S]+Authorization:"],
  29. expect="registration success"
  30. )
  31. recvfrom_cfg = sip.RecvfromCfg("Successful auth server changes nonce but with stale=false",
  32. pjsua, [req1, req2, req3, req4])