From 5ec0c35afb3499a1bc34906973cea59f6eac94a3 Mon Sep 17 00:00:00 2001 From: Waldemar Quevedo Date: Tue, 30 Mar 2021 14:19:15 -0700 Subject: [PATCH] Fix to authentication revoked test Signed-off-by: Waldemar Quevedo --- server/jwt_test.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/server/jwt_test.go b/server/jwt_test.go index f783dd64..02c7e1b0 100644 --- a/server/jwt_test.go +++ b/server/jwt_test.go @@ -4408,11 +4408,12 @@ func TestJWTUserRevocation(t *testing.T) { ncSys.ChanSubscribe(fmt.Sprintf(disconnectEventSubj, apub), ncChan) // observe disconnect message // use credentials that will be revoked ans assure that the connection will be disconnected nc := natsConnect(t, srv.ClientURL(), nats.UserCredentials(aCreds1), - nats.DisconnectErrHandler(func(conn *nats.Conn, err error) { - if lErr := conn.LastError(); lErr != nil && strings.Contains(lErr.Error(), "Authentication Revoked") { + nats.ErrorHandler(func(_ *nats.Conn, _ *nats.Subscription, err error) { + if err != nil && strings.Contains(err.Error(), "authentication revoked") { doneChan <- struct{}{} } - })) + }), + ) defer nc.Close() // update account jwt to contain revocation if updateJwt(t, srv.ClientURL(), sysCreds, ajwt2, 1) != 1 {