29 lines
608 B
Go
29 lines
608 B
Go
|
// Copyright (C) 2017 MichaĆ Matczuk
|
||
|
// Use of this source code is governed by a BSD-style
|
||
|
// license that can be found in the LICENSE file.
|
||
|
|
||
|
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)
|
||
|
}
|
||
|
}
|
||
|
}
|