END_TEST START_TEST(register_1_1_2) { nua_handle_t *nh; struct message *m; S2_CASE("1.1.2", "Register with dual authentication", "Register, authenticate"); nh = nua_handle(nua, NULL, TAG_END()); nua_register(nh, TAG_END()); m = s2_sip_wait_for_request(SIP_METHOD_REGISTER); fail_if(!m); s2_sip_respond_to(m, NULL, SIP_407_PROXY_AUTH_REQUIRED, SIPTAG_PROXY_AUTHENTICATE_STR(s2_auth_digest_str), TAG_END()); s2_sip_free_message(m); fail_unless_event(nua_r_register, 407); nua_authenticate(nh, NUTAG_AUTH(s2_auth_credentials), TAG_END()); m = s2_sip_wait_for_request(SIP_METHOD_REGISTER); fail_if(!m); s2_sip_respond_to(m, NULL, SIP_401_UNAUTHORIZED, SIPTAG_WWW_AUTHENTICATE_STR(s2_auth2_digest_str), SIPTAG_PROXY_AUTHENTICATE_STR(s2_auth_digest_str), TAG_END()); s2_sip_free_message(m); fail_unless_event(nua_r_register, 401); nua_authenticate(nh, NUTAG_AUTH(s2_auth2_credentials), TAG_END()); m = s2_sip_wait_for_request(SIP_METHOD_REGISTER); fail_if(!m); fail_if(!m->sip->sip_authorization); fail_if(!m->sip->sip_proxy_authorization); s2_save_register(m); s2_sip_respond_to(m, NULL, SIP_200_OK, SIPTAG_CONTACT(s2->registration->contact), TAG_END()); s2_sip_free_message(m); assert(s2->registration->contact != NULL); fail_unless_event(nua_r_register, 200); s2->registration->nh = nh; s2_register_teardown(); }
END_TEST START_TEST(message_6_4_3) { nua_handle_t *nh; struct message *message; struct event *response; sip_call_id_t *i; S2_CASE("6.4.1", "SIMPLE MESSAGE", "Send MESSAGE"); nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END()); nua_message(nh, SIPTAG_CONTENT_TYPE_STR("text/plain"), SIPTAG_PAYLOAD_STR("hello"), TAG_END()); message = s2_sip_wait_for_request(SIP_METHOD_MESSAGE); s2_sip_respond_to(message, NULL, SIP_407_PROXY_AUTH_REQUIRED, SIPTAG_PROXY_AUTHENTICATE_STR(s2_auth_digest_str), TAG_END()); i = sip_call_id_dup(NULL, message->sip->sip_call_id); fail_unless(i != NULL); s2_sip_free_message(message); fail_unless_event(nua_r_message, 407); nua_authenticate(nh, NUTAG_AUTH(s2_auth_credentials), TAG_END()); message = s2_sip_wait_for_request(SIP_METHOD_MESSAGE); s2_sip_respond_to(message, NULL, SIP_202_ACCEPTED, TAG_END()); fail_unless(su_strmatch(i->i_id, message->sip->sip_call_id->i_id)); s2_sip_free_message(message); response = s2_wait_for_event(nua_r_message, 202); s2_free_event(response); nua_handle_destroy(nh); }
END_TEST START_TEST(register_1_2_2_2) { nua_handle_t *nh = nua_handle(nua, NULL, TAG_END()); struct message *m; S2_CASE("1.2.2.2", "Register behind NAT", "Authenticate, outbound activated, " "authenticate OPTIONS probe, " "NAT binding change"); mark_point(); make_auth_natted_register(nh, TAG_END()); s2->registration->nh = nh; mark_point(); m = s2_sip_wait_for_request(SIP_METHOD_OPTIONS); fail_if(!m); s2_sip_respond_to(m, NULL, SIP_407_PROXY_AUTH_REQUIRED, SIPTAG_VIA(natted_via(m, receive_natted)), SIPTAG_PROXY_AUTHENTICATE_STR(s2_auth_digest_str), TAG_END()); s2_sip_free_message(m); mark_point(); m = s2_sip_wait_for_request(SIP_METHOD_OPTIONS); fail_if(!m); fail_if(!m->sip->sip_proxy_authorization); s2_sip_respond_to(m, NULL, SIP_200_OK, SIPTAG_VIA(natted_via(m, receive_natted)), TAG_END()); s2_sip_free_message(m); su_root_step(s2base->root, 20); su_root_step(s2base->root, 20); s2_nua_fast_forward(120, s2base->root); /* Default keepalive interval */ mark_point(); m = s2_sip_wait_for_request(SIP_METHOD_OPTIONS); s2_sip_respond_to(m, NULL, SIP_200_OK, SIPTAG_VIA(natted_via(m, receive_natted)), TAG_END()); s2_sip_free_message(m); su_root_step(s2base->root, 20); su_root_step(s2base->root, 20); s2_nua_fast_forward(120, s2base->root); /* Default keepalive interval */ mark_point(); m = s2_sip_wait_for_request(SIP_METHOD_OPTIONS); s2_sip_respond_to(m, NULL, SIP_200_OK, SIPTAG_VIA(natted_via(m, receive_natted2)), TAG_END()); s2_sip_free_message(m); fail_unless_event(nua_i_outbound, 0); m = s2_sip_wait_for_request(SIP_METHOD_REGISTER); fail_if(!m); fail_if(!m->sip->sip_authorization); fail_if(!m->sip->sip_contact || !m->sip->sip_contact->m_next); s2_save_register(m); s2_sip_respond_to(m, NULL, SIP_200_OK, SIPTAG_CONTACT(s2->registration->contact), SIPTAG_VIA(natted_via(m, receive_natted2)), TAG_END()); s2_sip_free_message(m); fail_unless_event(nua_r_register, 200); fail_unless(s2->registration->contact != NULL); fail_if(s2->registration->contact->m_next != NULL); s2_register_teardown(); } END_TEST