@@ -20,9 +20,11 @@ import (
2020 "regexp"
2121 "strconv"
2222 "testing"
23+ "time"
2324
2425 "github.com/dennwc/iters"
2526 "google.golang.org/protobuf/proto"
27+ "google.golang.org/protobuf/types/known/durationpb"
2628
2729 "github.com/stretchr/testify/require"
2830
@@ -959,6 +961,29 @@ func TestEvaluateDispatchRule_TrunkOnlyEncryption(t *testing.T) {
959961 require .NotNil (t , res .Media )
960962 require .NotNil (t , res .Media .Encryption )
961963 require .Equal (t , livekit .SIPMediaEncryption_SIP_MEDIA_ENCRYPT_REQUIRE , * res .Media .Encryption )
964+ require .Nil (t , res .Media .MediaTimeout )
965+ }
966+
967+ func TestEvaluateDispatchRule_RespectsRuleMediaTimeout (t * testing.T ) {
968+ d := & livekit.SIPDispatchRuleInfo {
969+ SipDispatchRuleId : "rule" ,
970+ Rule : newDirectDispatch ("room" , "" ),
971+ Media : & livekit.SIPMediaConfig {
972+ MediaTimeout : durationpb .New (5 * time .Minute ),
973+ },
974+ }
975+ r := & rpc.EvaluateSIPDispatchRulesRequest {
976+ SipCallId : "call-id" ,
977+ CallingNumber : "+11112222" ,
978+ CallingHost : "sip.example.com" ,
979+ CalledNumber : "+3333" ,
980+ }
981+ tr := & livekit.SIPInboundTrunkInfo {SipTrunkId : "trunk" }
982+ res , err := EvaluateDispatchRule ("p_123" , tr , d , r )
983+ require .NoError (t , err )
984+ require .NotNil (t , res .Media )
985+ require .NotNil (t , res .Media .MediaTimeout )
986+ require .Equal (t , 5 * time .Minute , res .Media .MediaTimeout .AsDuration ())
962987}
963988
964989func TestMatchIP (t * testing.T ) {
0 commit comments