server: basic auth

This commit is contained in:
mmatczuk 2017-02-08 14:15:23 +01:00
parent 96c46be0f0
commit c9768f8c1c
8 changed files with 292 additions and 81 deletions

24
auth_test.go Normal file
View file

@ -0,0 +1,24 @@
package tunnel
import (
"reflect"
"testing"
)
func TestNewAuth(t *testing.T) {
tests := []struct {
actual string
expected *Auth
}{
{"", nil},
{"user", &Auth{User: "user"}},
{"user:password", &Auth{User: "user", Password: "password"}},
{"user:pass:word", &Auth{User: "user", Password: "pass:word"}},
}
for _, tt := range tests {
if !reflect.DeepEqual(NewAuth(tt.actual), tt.expected) {
t.Errorf("Invalid auth for %s", tt.actual)
}
}
}