api/pkg/plugins/tls_interceptor/addr_utils_test.go
Peter Kurfer a720b0ee41
Initial working version
* supports HTTP
* support TLS interception e.g. for HTTPS
* support CA generation via cli
* first draft of plugin API
* support commands from plugins
* includes Dockerfile
* includes basic configuration
2020-04-01 04:08:21 +02:00

44 lines
847 B
Go

package main
import "testing"
func Test_extractIPFromAddress(t *testing.T) {
type args struct {
addr string
}
tests := []struct {
name string
args args
want string
wantErr bool
}{
{
name: "Get address for IPv4 address",
want: "127.0.0.1",
wantErr: false,
args: args{
addr: "127.0.0.1:23492",
},
},
{
name: "Get address for IPv6 address",
want: "::1",
wantErr: false,
args: args{
addr: "[::1]:23492",
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := extractIPFromAddress(tt.args.addr)
if (err != nil) != tt.wantErr {
t.Errorf("extractIPFromAddress() error = %v, wantErr %v", err, tt.wantErr)
return
}
if got != tt.want {
t.Errorf("extractIPFromAddress() got = %v, want %v", got, tt.want)
}
})
}
}