2
0

switch_sip.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #include <switch.h>
  2. #include <test/switch_test.h>
  3. int timeout_sec = 10;
  4. switch_interval_time_t delay_start_ms = 5000;
  5. FST_CORE_DB_BEGIN("./conf_sip")
  6. {
  7. FST_SUITE_BEGIN(switch_sip)
  8. {
  9. FST_SETUP_BEGIN()
  10. {
  11. /* Give mod_sofia time to spinup profile threads */
  12. if (delay_start_ms) {
  13. switch_sleep(delay_start_ms * 1000);
  14. delay_start_ms = 0;
  15. }
  16. fst_requires_module("mod_sofia");
  17. fst_requires_module("mod_hash");
  18. }
  19. FST_SETUP_END()
  20. FST_TEARDOWN_BEGIN()
  21. {
  22. }
  23. FST_TEARDOWN_END()
  24. FST_TEST_BEGIN(identity_compact_check)
  25. {
  26. switch_core_session_t *session = NULL;
  27. switch_call_cause_t cause;
  28. const char *data = "eyJhbGciOiJFUzI1NiIsInBwdCI6InNoYWtlbiI;info=<https://cert.sticr.att.net:8443/certs/att/a937bb15-38b9-45f1-aac0-8cd3f8fe0648>";
  29. char *originate_str = switch_mprintf("{sip_h_Identity=%s}sofia/gateway/test_gateway/+15553332901", data);
  30. switch_ivr_originate(NULL, &session, &cause, originate_str, timeout_sec, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL, NULL);
  31. switch_safe_free(originate_str);
  32. fst_requires(session);
  33. if (session) {
  34. switch_channel_t *channel = switch_core_session_get_channel(session);
  35. const char *uuid = switch_core_session_get_uuid(session);
  36. fst_requires(channel);
  37. if (uuid) {
  38. switch_stream_handle_t stream = { 0 };
  39. SWITCH_STANDARD_STREAM(stream);
  40. switch_api_execute("hash", "select/realm/identity_check", NULL, &stream);
  41. fst_check_string_equals(stream.data, data);
  42. switch_safe_free(stream.data);
  43. SWITCH_STANDARD_STREAM(stream);
  44. switch_api_execute("hash", "delete/realm/identity_check", NULL, &stream);
  45. switch_safe_free(stream.data);
  46. }
  47. switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
  48. switch_core_session_rwunlock(session);
  49. }
  50. }
  51. FST_TEST_END()
  52. FST_TEST_BEGIN(identity_full_check)
  53. {
  54. switch_core_session_t *session = NULL;
  55. switch_call_cause_t cause;
  56. const char *data = "eyJhbGciOiJFUzI1NiIsInBwdCI6InNoYWtlbiI;info=<https://cert.sticr.att.net:8443/certs/att/a937bb15-38b9-45f1-aac0-8cd3f8fe0648>;alg=ES256;ppt=shaken";
  57. char *originate_str = switch_mprintf("{sip_h_Identity=%s}sofia/gateway/test_gateway/+15553332901", data);
  58. switch_ivr_originate(NULL, &session, &cause, originate_str, timeout_sec, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL, NULL);
  59. switch_safe_free(originate_str);
  60. fst_requires(session);
  61. if (session) {
  62. switch_channel_t *channel = switch_core_session_get_channel(session);
  63. const char *uuid = switch_core_session_get_uuid(session);
  64. fst_requires(channel);
  65. if (uuid) {
  66. switch_stream_handle_t stream = { 0 };
  67. SWITCH_STANDARD_STREAM(stream);
  68. switch_api_execute("hash", "select/realm/identity_check", NULL, &stream);
  69. fst_check_string_equals(stream.data, data);
  70. switch_safe_free(stream.data);
  71. SWITCH_STANDARD_STREAM(stream);
  72. switch_api_execute("hash", "delete/realm/identity_check", NULL, &stream);
  73. switch_safe_free(stream.data);
  74. }
  75. switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
  76. switch_core_session_rwunlock(session);
  77. }
  78. }
  79. FST_TEST_END()
  80. }
  81. FST_SUITE_END()
  82. }
  83. FST_CORE_END()