diff --git a/.travis.yml b/.travis.yml index 05e63442..f4229c8e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: go go: -- 1.9.x -- 1.10.x +- 1.9.6 +- 1.10.2 install: - go get github.com/nats-io/go-nats - go get github.com/mattn/goveralls diff --git a/server/auth.go b/server/auth.go index 25b94815..21c8a1bd 100644 --- a/server/auth.go +++ b/server/auth.go @@ -122,6 +122,14 @@ func (s *Server) checkAuthorization(c *client) bool { } } +// hasUsers leyt's us know if we have a users array. +func (s *Server) hasUsers() bool { + s.mu.Lock() + hu := s.users != nil + s.mu.Unlock() + return hu +} + // isClientAuthorized will check the client against the proper authorization method and data. // This could be token or username/password based. func (s *Server) isClientAuthorized(c *client) bool { @@ -131,7 +139,7 @@ func (s *Server) isClientAuthorized(c *client) bool { // Check custom auth first, then multiple users, then token, then single user/pass. if opts.CustomClientAuthentication != nil { return opts.CustomClientAuthentication.Check(c) - } else if s.users != nil { + } else if s.hasUsers() { user, ok := s.users[c.opts.Username] if !ok { return false diff --git a/server/routes_test.go b/server/routes_test.go index 3ef0885d..5b6a0c99 100644 --- a/server/routes_test.go +++ b/server/routes_test.go @@ -943,7 +943,7 @@ func TestRoutedQueueAutoUnsubscribe(t *testing.T) { c.Flush() } - wait := time.Now().Add(5 * time.Second) + wait := time.Now().Add(10 * time.Second) for time.Now().Before(wait) { nbar := atomic.LoadInt32(&rbar) nbaz := atomic.LoadInt32(&rbaz) @@ -962,7 +962,7 @@ func TestRoutedQueueAutoUnsubscribe(t *testing.T) { } return } - time.Sleep(10 * time.Millisecond) + time.Sleep(100 * time.Millisecond) } t.Fatalf("Did not receive all %d queue messages, received %d for 'bar' and %d for 'baz'\n", expected, atomic.LoadInt32(&rbar), atomic.LoadInt32(&rbaz)) diff --git a/test/cluster_test.go b/test/cluster_test.go index 3c968187..a5b58a21 100644 --- a/test/cluster_test.go +++ b/test/cluster_test.go @@ -515,23 +515,9 @@ func TestRouteFormTimeWithHighSubscriptions(t *testing.T) { checkClusterFormed(t, srvA, srvB) // Now wait for all subscriptions to be processed. - if err := checkExpectedSubs(subsTotal, srvB); err != nil { t.Fatalf("%v", err) } - /* - maxTime := time.Now().Add(5 * time.Second) - for time.Now().Before(maxTime) { - if srvB.NumSubscriptions() == subsTotal { - break - } - time.Sleep(10 * time.Millisecond) - } - if srvB.NumSubscriptions() != subsTotal { - t.Fatalf("srvB did not receive all subscriptions in allocated time: %d", - srvB.NumSubscriptions()) - } - */ fmt.Printf("Cluster formed after %v\n", time.Since(now)) }