-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for validating a sip uri in the From and To fields
Add ParsedNumber to provide details about different types of To and From values including SIP URI's
- Loading branch information
Showing
4 changed files
with
219 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package twiml | ||
|
||
import "testing" | ||
|
||
func Test_validSipURI(t *testing.T) { | ||
type args struct { | ||
v interface{} | ||
param string | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
wantErr bool | ||
}{ | ||
{name: "Valid SIPS URI", args: args{v: "sips:user@yourdomain.sip.us1.twilio.com:5061", param: ""}, wantErr: false}, | ||
{name: "Valid SIP URI", args: args{v: "sip:user@yourdomain.sip.us1.twilio.com:5061", param: ""}, wantErr: false}, | ||
{name: "Valid", args: args{v: "", param: "allowempty"}, wantErr: false}, | ||
{name: "Invaid", args: args{v: "", param: ""}, wantErr: true}, | ||
{name: "Invalid SIP URI", args: args{v: "+18002368945", param: ""}, wantErr: true}, | ||
{name: "Invalid URL", args: args{v: "https://user@yourdomain.sip.us1.twilio.com:5061", param: ""}, wantErr: true}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if err := validSipURI(tt.args.v, tt.args.param); (err != nil) != tt.wantErr { | ||
t.Errorf("validSipURI() error = %v, wantErr %v", err, tt.wantErr) | ||
} | ||
}) | ||
} | ||
} |