diff --git a/tests/unit/Makefile.am b/tests/unit/Makefile.am index 3f41d71dda..d24e30f62b 100644 --- a/tests/unit/Makefile.am +++ b/tests/unit/Makefile.am @@ -4,7 +4,7 @@ noinst_PROGRAMS = switch_event switch_hash switch_ivr_originate switch_utils swi switch_ivr_play_say switch_core_codec switch_rtp switch_xml noinst_PROGRAMS += switch_core_video switch_core_db switch_vad switch_packetizer switch_core_session test_sofia switch_ivr_async switch_core_asr switch_log -noinst_PROGRAMS+= switch_hold +noinst_PROGRAMS+= switch_hold switch_sip AM_LDFLAGS += -avoid-version -no-undefined $(SWITCH_AM_LDFLAGS) $(openssl_LIBS) AM_LDFLAGS += $(FREESWITCH_LIBS) $(switch_builddir)/libfreeswitch.la $(CORE_LIBS) $(APR_LIBS) diff --git a/tests/unit/conf_hold/freeswitch.xml b/tests/unit/conf_test/freeswitch.xml similarity index 92% rename from tests/unit/conf_hold/freeswitch.xml rename to tests/unit/conf_test/freeswitch.xml index 883e3846e1..80216bbe7d 100644 --- a/tests/unit/conf_hold/freeswitch.xml +++ b/tests/unit/conf_test/freeswitch.xml @@ -15,6 +15,7 @@ + @@ -39,7 +40,7 @@ - + @@ -62,7 +63,7 @@ - + @@ -104,7 +105,7 @@ - + @@ -144,12 +145,20 @@
+ + + + + + + + - + diff --git a/tests/unit/conf_hold/gw/holdtest.xml b/tests/unit/conf_test/gw/test_gateway.xml similarity index 92% rename from tests/unit/conf_hold/gw/holdtest.xml rename to tests/unit/conf_test/gw/test_gateway.xml index d919ddb2d4..8e8e0ac075 100644 --- a/tests/unit/conf_hold/gw/holdtest.xml +++ b/tests/unit/conf_test/gw/test_gateway.xml @@ -1,5 +1,5 @@ - + diff --git a/tests/unit/switch_hold.c b/tests/unit/switch_hold.c index 9da8ccfc94..e48865155b 100644 --- a/tests/unit/switch_hold.c +++ b/tests/unit/switch_hold.c @@ -1,7 +1,7 @@ #include #include -FST_CORE_DB_BEGIN("./conf_hold") +FST_CORE_DB_BEGIN("./conf_test") { FST_SUITE_BEGIN(switch_hold) { @@ -23,7 +23,7 @@ FST_SUITE_BEGIN(switch_hold) switch_status_t status; switch_call_cause_t cause; - status = switch_ivr_originate(NULL, &session, &cause, "{ignore_early_media=true}sofia/gateway/hold_unhold_test/+15553332900", 2, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL, NULL); + status = switch_ivr_originate(NULL, &session, &cause, "{ignore_early_media=true}sofia/gateway/test_gateway/+15553332900", 2, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL, NULL); fst_requires(session); fst_check(status == SWITCH_STATUS_SUCCESS); diff --git a/tests/unit/switch_sip.c b/tests/unit/switch_sip.c new file mode 100644 index 0000000000..238f00a4d5 --- /dev/null +++ b/tests/unit/switch_sip.c @@ -0,0 +1,95 @@ +#include +#include + +FST_CORE_DB_BEGIN("./conf_test") +{ +FST_SUITE_BEGIN(switch_sip) +{ + FST_SETUP_BEGIN() + { + fst_requires_module("mod_sofia"); + fst_requires_module("mod_hash"); + } + FST_SETUP_END() + + FST_TEARDOWN_BEGIN() + { + } + FST_TEARDOWN_END() + + FST_TEST_BEGIN(identity_compact_check) + { + switch_core_session_t *session = NULL; + switch_call_cause_t cause; + const char *data = "eyJhbGciOiJFUzI1NiIsInBwdCI6InNoYWtlbiI;info="; + char *originate_str = switch_mprintf("{sip_h_Identity=%s}sofia/gateway/test_gateway/+15553332901", data); + + switch_ivr_originate(NULL, &session, &cause, originate_str, 2, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL, NULL); + switch_safe_free(originate_str); + fst_requires(session); + + if (session) { + switch_channel_t *channel = switch_core_session_get_channel(session); + const char *uuid = switch_core_session_get_uuid(session); + + fst_requires(channel); + if (uuid) { + switch_stream_handle_t stream = { 0 }; + SWITCH_STANDARD_STREAM(stream); + + switch_api_execute("hash", "select/realm/identity_check", NULL, &stream); + fst_check_string_equals(stream.data, data); + switch_safe_free(stream.data); + + SWITCH_STANDARD_STREAM(stream); + switch_api_execute("hash", "delete/realm/identity_check", NULL, &stream); + switch_safe_free(stream.data); + } + + switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); + switch_core_session_rwunlock(session); + } + + } + FST_TEST_END() + + FST_TEST_BEGIN(identity_full_check) + { + switch_core_session_t *session = NULL; + switch_call_cause_t cause; + const char *data = "eyJhbGciOiJFUzI1NiIsInBwdCI6InNoYWtlbiI;info=;alg=ES256;ppt=shaken"; + char *originate_str = switch_mprintf("{sip_h_Identity=%s}sofia/gateway/test_gateway/+15553332901", data); + + switch_ivr_originate(NULL, &session, &cause, originate_str, 2, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL, NULL); + switch_safe_free(originate_str); + fst_requires(session); + + if (session) { + switch_channel_t *channel = switch_core_session_get_channel(session); + const char *uuid = switch_core_session_get_uuid(session); + + fst_requires(channel); + if (uuid) { + switch_stream_handle_t stream = { 0 }; + SWITCH_STANDARD_STREAM(stream); + + switch_api_execute("hash", "select/realm/identity_check", NULL, &stream); + fst_check_string_equals(stream.data, data); + switch_safe_free(stream.data); + + SWITCH_STANDARD_STREAM(stream); + switch_api_execute("hash", "delete/realm/identity_check", NULL, &stream); + switch_safe_free(stream.data); + } + + switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); + switch_core_session_rwunlock(session); + } + + } + FST_TEST_END() +} +FST_SUITE_END() +} +FST_CORE_END() +