mirror of
https://github.com/mmatczuk/go-http-tunnel.git
synced 2026-05-21 06:45:30 -06:00
server: basic auth
This commit is contained in:
parent
96c46be0f0
commit
c9768f8c1c
8 changed files with 292 additions and 81 deletions
24
auth_test.go
Normal file
24
auth_test.go
Normal 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue