[Unit-tests] Add a unit-test for the compact form and full form of the Identity header.
This commit is contained in:
parent
7bfc9a514f
commit
715f9e4d28
|
@ -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)
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
<load module="mod_tone_stream"/>
|
||||
<load module="mod_commands"/>
|
||||
<load module="mod_sndfile"/>
|
||||
<load module="mod_hash"/>
|
||||
</modules>
|
||||
</configuration>
|
||||
|
||||
|
@ -39,7 +40,7 @@
|
|||
<profile name="external">
|
||||
<gateways>
|
||||
|
||||
<gateway name="hold_unhold_test">
|
||||
<gateway name="test_gateway">
|
||||
<param name="username" value="not-used"/>
|
||||
<param name="password" value="not-used"/>
|
||||
<param name="proxy" value="$${local_ip_v4}:61068"/>
|
||||
|
@ -62,7 +63,7 @@
|
|||
<param name="p-asserted-id-parse" value="verbatim"/>
|
||||
<param name="username" value="SignalWire-STACK"/>
|
||||
<param name="user-agent-string" value="SignalWire STACK Unit Test"/>
|
||||
<param name="sip-trace" value="yes"/>
|
||||
<param name="sip-trace" value="no"/>
|
||||
<param name="sip-capture" value="no"/>
|
||||
<param name="rfc2833-pt" value="101"/>
|
||||
<param name="sip-port" value="61068"/>
|
||||
|
@ -104,7 +105,7 @@
|
|||
<param name="p-asserted-id-parse" value="verbatim"/>
|
||||
<param name="username" value="SignalWire-STACK"/>
|
||||
<param name="user-agent-string" value="SignalWire STACK Unit Test"/>
|
||||
<param name="sip-trace" value="yes"/>
|
||||
<param name="sip-trace" value="no"/>
|
||||
<param name="sip-capture" value="no"/>
|
||||
<param name="rfc2833-pt" value="101"/>
|
||||
<param name="sip-port" value="61069"/>
|
||||
|
@ -144,12 +145,20 @@
|
|||
|
||||
<section name="dialplan" description="Regex/XML Dialplan">
|
||||
<context name="default">
|
||||
<extension name="two">
|
||||
<condition field="destination_number" expression="^\+15553332901$">
|
||||
<action application="log" data="${sip_h_identity}"/>
|
||||
<action application="hash" data="insert/realm/identity_check/${sip_h_identity}"/>
|
||||
<action application="answer"/>
|
||||
<action application="park"/>
|
||||
</condition>
|
||||
</extension>
|
||||
<extension name="one">
|
||||
<condition field="destination_number" expression="^\+15553332900$">
|
||||
<action application="set" data="absolute_codec_string=PCMU@20i"/>
|
||||
<action application="info"/>
|
||||
<action application="answer"/>
|
||||
<action application="park""/>
|
||||
<action application="park"/>
|
||||
</condition>
|
||||
</extension>
|
||||
</context>
|
|
@ -1,5 +1,5 @@
|
|||
<include/>
|
||||
<gateway name="hold_unhold_test">
|
||||
<gateway name="test_gateway">
|
||||
<param name="username" value="not-used"/>
|
||||
<param name="password" value="not-used"/>
|
||||
<param name="proxy" value="127.0.0.1"/>
|
|
@ -1,7 +1,7 @@
|
|||
#include <switch.h>
|
||||
#include <test/switch_test.h>
|
||||
|
||||
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);
|
||||
|
||||
|
|
|
@ -0,0 +1,95 @@
|
|||
#include <switch.h>
|
||||
#include <test/switch_test.h>
|
||||
|
||||
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=<https://cert.sticr.att.net:8443/certs/att/a937bb15-38b9-45f1-aac0-8cd3f8fe0648>";
|
||||
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=<https://cert.sticr.att.net:8443/certs/att/a937bb15-38b9-45f1-aac0-8cd3f8fe0648>;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()
|
||||
|
Loading…
Reference in New Issue