2
0

enroll_test_helpers.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. static zrtp_test_id_t g_alice, g_bob, g_pbx;
  2. static zrtp_test_id_t g_alice_sid, g_bob_sid, g_pbxa_sid, g_pbxb_sid;
  3. static zrtp_test_id_t g_alice2pbx_channel, g_bob2pbx_channel;
  4. static void pbx_setup() {
  5. zrtp_status_t s;
  6. zrtp_test_endpoint_cfg_t endpoint_cfg;
  7. zrtp_test_endpoint_config_defaults(&endpoint_cfg);
  8. s = zrtp_test_endpoint_create(&endpoint_cfg, "Alice", &g_alice);
  9. assert_int_equal(zrtp_status_ok, s);
  10. assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_alice);
  11. s = zrtp_test_endpoint_create(&endpoint_cfg, "Bob", &g_bob);
  12. assert_int_equal(zrtp_status_ok, s);
  13. assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_bob);
  14. endpoint_cfg.zrtp.is_mitm = 1;
  15. s = zrtp_test_endpoint_create(&endpoint_cfg, "PBX", &g_pbx);
  16. assert_int_equal(zrtp_status_ok, s);
  17. assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_pbx);
  18. }
  19. static void pbx_teardown() {
  20. zrtp_test_endpoint_destroy(g_alice);
  21. zrtp_test_endpoint_destroy(g_bob);
  22. zrtp_test_endpoint_destroy(g_pbx);
  23. }
  24. static void prepare_alice_pbx_bob_setup(zrtp_test_session_cfg_t *alice_sconfig,
  25. zrtp_test_session_cfg_t *bob_sconfig,
  26. zrtp_test_session_cfg_t *pbxa_sconfig,
  27. zrtp_test_session_cfg_t *pbxb_sconfig) {
  28. zrtp_status_t s;
  29. if (alice_sconfig) {
  30. assert_non_null(pbxa_sconfig);
  31. s = zrtp_test_session_create(g_alice, alice_sconfig, &g_alice_sid);
  32. assert_int_equal(zrtp_status_ok, s);
  33. assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_alice_sid);
  34. s = zrtp_test_session_create(g_pbx, pbxa_sconfig, &g_pbxa_sid);
  35. assert_int_equal(zrtp_status_ok, s);
  36. assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_pbxa_sid);
  37. s = zrtp_test_channel_create2(g_alice_sid, g_pbxa_sid, 0, &g_alice2pbx_channel);
  38. assert_int_equal(zrtp_status_ok, s);
  39. assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_alice2pbx_channel);
  40. }
  41. if (bob_sconfig) {
  42. assert_non_null(pbxb_sconfig);
  43. s = zrtp_test_session_create(g_bob, bob_sconfig, &g_bob_sid);
  44. assert_int_equal(zrtp_status_ok, s);
  45. assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_bob_sid);
  46. s = zrtp_test_session_create(g_pbx, pbxb_sconfig, &g_pbxb_sid);
  47. assert_int_equal(zrtp_status_ok, s);
  48. assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_pbxb_sid);
  49. s = zrtp_test_channel_create2(g_bob_sid, g_pbxb_sid, 0, &g_bob2pbx_channel);
  50. assert_int_equal(zrtp_status_ok, s);
  51. assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_bob2pbx_channel);
  52. }
  53. }
  54. static void cleanup_alice_pbx_bob_setup() {
  55. zrtp_test_session_destroy(g_alice_sid);
  56. zrtp_test_session_destroy(g_bob_sid);
  57. zrtp_test_session_destroy(g_pbxa_sid);
  58. zrtp_test_session_destroy(g_pbxb_sid);
  59. zrtp_test_channel_destroy(g_alice2pbx_channel);
  60. zrtp_test_channel_destroy(g_bob2pbx_channel);
  61. }