From 2a06070becfa89b77171297207b04b91ff3587b5 Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Wed, 4 Oct 2017 00:26:43 -0700 Subject: [PATCH] tun2: fix TestBackendRouting --- internal/tun2/server.go | 5 +---- internal/tun2/server_test.go | 7 +++++-- internal/tun2/storage_test.go | 2 +- mage.go | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/internal/tun2/server.go b/internal/tun2/server.go index c131d3c..810c1d0 100644 --- a/internal/tun2/server.go +++ b/internal/tun2/server.go @@ -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) diff --git a/internal/tun2/server_test.go b/internal/tun2/server_test.go index 0ead668..f84d300 100644 --- a/internal/tun2/server_test.go +++ b/internal/tun2/server_test.go @@ -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 { diff --git a/internal/tun2/storage_test.go b/internal/tun2/storage_test.go index f7e068f..ed50fb8 100644 --- a/internal/tun2/storage_test.go +++ b/internal/tun2/storage_test.go @@ -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 diff --git a/mage.go b/mage.go index 6c50aac..cdddede 100644 --- a/mage.go +++ b/mage.go @@ -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", "./...") }