tun2: fix TestBackendRouting

This commit is contained in:
Cadey Ratio 2017-10-04 00:26:43 -07:00
parent adf2121326
commit 2a06070bec
No known key found for this signature in database
GPG Key ID: D607EE27C2E7F89A
4 changed files with 8 additions and 8 deletions

View File

@ -214,8 +214,8 @@ func (s *Server) backendAuthv1(ctx context.Context, st io.Reader) (string, *Auth
return "", nil, err
}
f["auth_domain"] = auth.Domain
f["stage"] = "checking domain"
ln.Log(ctx, f)
routeUser, err := s.cfg.Storage.HasRoute(auth.Domain)
if err != nil {
@ -225,7 +225,6 @@ func (s *Server) backendAuthv1(ctx context.Context, st io.Reader) (string, *Auth
f["route_user"] = routeUser
f["stage"] = "checking token"
ln.Log(ctx, f)
tokenUser, scopes, err := s.cfg.Storage.HasToken(auth.Token)
if err != nil {
@ -235,7 +234,6 @@ func (s *Server) backendAuthv1(ctx context.Context, st io.Reader) (string, *Auth
f["token_user"] = tokenUser
f["stage"] = "checking token scopes"
ln.Log(ctx, f)
ok := false
for _, sc := range scopes {
@ -251,7 +249,6 @@ func (s *Server) backendAuthv1(ctx context.Context, st io.Reader) (string, *Auth
}
f["stage"] = "user verification"
ln.Log(ctx, f)
if routeUser != tokenUser {
ln.Error(ctx, ErrAuthMismatch, f)

View File

@ -199,6 +199,9 @@ func TestBackendRouting(t *testing.T) {
ServerAddr: l.Addr().String(),
Token: token,
BackendURL: ts.URL,
Domain: domain,
forceTCPClear: true,
}
c, err := NewClient(cc)
@ -206,9 +209,9 @@ func TestBackendRouting(t *testing.T) {
t.Fatal(err)
}
go c.Connect(ctx) //
go c.Connect(ctx) // TODO: fix the client library so this ends up actually getting cleaned up
time.Sleep(5 * time.Second)
time.Sleep(time.Second)
req, err := http.NewRequest("GET", "http://cetacean.club/", nil)
if err != nil {

View File

@ -57,7 +57,7 @@ func (ms *mockStorage) HasRoute(domain string) (string, error) {
user, ok := ms.domains[domain]
if !ok {
return "", nil
return "", errors.New("no such route")
}
return user, nil

View File

@ -199,5 +199,5 @@ func Test() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
shouldWork(ctx, nil, wd, "go", "test", "-race", "-v", "./...")
shouldWork(ctx, nil, wd, "go", "test", "-v", "./...")
}