From 639b6a30dda722799737c4d82083449ed6656e1c Mon Sep 17 00:00:00 2001 From: Denys Smirnov Date: Thu, 20 Jun 2024 15:13:05 +0300 Subject: [PATCH] Fix typo in SIP Trunk conversion. --- .changeset/rare-mugs-complain.md | 5 +++++ livekit/sip.go | 4 ++-- livekit/sip_test.go | 37 ++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 .changeset/rare-mugs-complain.md create mode 100644 livekit/sip_test.go diff --git a/.changeset/rare-mugs-complain.md b/.changeset/rare-mugs-complain.md new file mode 100644 index 00000000..1526eb44 --- /dev/null +++ b/.changeset/rare-mugs-complain.md @@ -0,0 +1,5 @@ +--- +"github.com/livekit/protocol": patch +--- + +Fix typo in SIP Trunk conversion. diff --git a/livekit/sip.go b/livekit/sip.go index 3b3ade6c..840a2b90 100644 --- a/livekit/sip.go +++ b/livekit/sip.go @@ -68,8 +68,8 @@ func (p *SIPTrunkInfo) AsOutbound() *SIPOutboundTrunkInfo { Address: p.OutboundAddress, Transport: p.Transport, Numbers: nums, - AuthUsername: p.InboundUsername, - AuthPassword: p.InboundPassword, + AuthUsername: p.OutboundUsername, + AuthPassword: p.OutboundPassword, } } diff --git a/livekit/sip_test.go b/livekit/sip_test.go new file mode 100644 index 00000000..c8e05308 --- /dev/null +++ b/livekit/sip_test.go @@ -0,0 +1,37 @@ +package livekit + +import ( + "github.com/stretchr/testify/require" + "testing" +) + +func TestSIPTrunkAs(t *testing.T) { + t.Run("inbound", func(t *testing.T) { + in := &SIPInboundTrunkInfo{ + SipTrunkId: "id", + Name: "name", + Metadata: "{}", + Numbers: []string{"+1"}, + AllowedAddresses: []string{"sip.com"}, + AllowedNumbers: []string{"+2", "+3"}, + AuthUsername: "user", + AuthPassword: "pass", + } + got := in.AsTrunkInfo().AsInbound() + require.Equal(t, in, got) + }) + t.Run("outbound", func(t *testing.T) { + out := &SIPOutboundTrunkInfo{ + SipTrunkId: "id", + Name: "name", + Metadata: "{}", + Address: "sip.com", + Transport: 1, + Numbers: []string{"+1"}, + AuthUsername: "user", + AuthPassword: "pass", + } + got := out.AsTrunkInfo().AsOutbound() + require.Equal(t, out, got) + }) +}