Repository: nats-io/nats-server
Pull request #2717 (2021-12-01 15:09:46)

Stream valid subjects

/cc @nats-io/core


ripienaar: This could be a breaking change and prevent streams from recovering at startup.  Not sure what to do about that.

But this is quite a big deal especially on streams - it caused leafnode protocol errors for example.

Patch:
diff --git a/server/const.go b/server/const.go
index 24369877..86327e2f 100644
--- a/server/const.go
+++ b/server/const.go
@@ -41,7 +41,7 @@ var (
 
 const (
 	// VERSION is the current version for the server.
-	VERSION = "2.6.6-beta"
+	VERSION = "2.6.5"
 
 	// PROTO is the currently supported protocol.
 	// 0 was the original
diff --git a/server/consumer.go b/server/consumer.go
index a506e618..18c7c779 100644
--- a/server/consumer.go
+++ b/server/consumer.go
@@ -325,6 +325,9 @@ func (mset *stream) addConsumerWithAssignment(config *ConsumerConfig, oname stri
 		if !subjectIsLiteral(config.DeliverSubject) {
 			return nil, NewJSConsumerDeliverToWildcardsError()
 		}
+		if !IsValidSubject(config.DeliverSubject) {
+			return nil, NewJSConsumerInvalidDeliverSubjectError()
+		}
 		if mset.deliveryFormsCycle(config.DeliverSubject) {
 			return nil, NewJSConsumerDeliverCycleError()
 		}
@@ -2905,13 +2908,12 @@ func (o *consumer) selectStartingSeqNo() {
 	if o.mset == nil || o.mset.store == nil {
 		o.sseq = 1
 	} else {
-		var state StreamState
-		o.mset.store.FastState(&state)
+		stats := o.mset.store.State()
 		if o.cfg.OptStartSeq == 0 {
 			if o.cfg.DeliverPolicy == DeliverAll {
-				o.sseq = state.FirstSeq
+				o.sseq = stats.FirstSeq
 			} else if o.cfg.DeliverPolicy == DeliverLast {
-				o.sseq = state.LastSeq
+				o.sseq = stats.LastSeq
 				// If we are partitioned here this will be properly set when we become leader.
 				if o.cfg.FilterSubject != _EMPTY_ {
 					ss := o.mset.store.FilteredState(1, o.cfg.FilterSubject)
@@ -2920,31 +2922,31 @@ func (o *consumer) selectStartingSeqNo() {
 			} else if o.cfg.DeliverPolicy == DeliverLastPerSubject {
 				if mss := o.mset.store.SubjectsState(o.cfg.FilterSubject); len(mss) > 0 {
 					o.lss = &lastSeqSkipList{
-						resume: state.LastSeq,
+						resume: stats.LastSeq,
 						seqs:   createLastSeqSkipList(mss),
 					}
 					o.sseq = o.lss.seqs[0]
 				} else {
 					// If no mapping info just set to last.
-					o.sseq = state.LastSeq
+					o.sseq = stats.LastSeq
 				}
 			} else if o.cfg.OptStartTime != nil {
 				// If we are here we are time based.
 				// TODO(dlc) - Once clustered can't rely on this.
 				o.sseq = o.mset.store.GetSeqFromTime(*o.cfg.OptStartTime)
 			} else {
-				o.sseq = state.LastSeq + 1
+				o.sseq = stats.LastSeq + 1
 			}
 		} else {
 			o.sseq = o.cfg.OptStartSeq
 		}
 
-		if state.FirstSeq == 0 {
+		if stats.FirstSeq == 0 {
 			o.sseq = 1
-		} else if o.sseq < state.FirstSeq {
-			o.sseq = state.FirstSeq
-		} else if o.sseq > state.LastSeq {
-			o.sseq = state.LastSeq + 1
+		} else if o.sseq < stats.FirstSeq {
+			o.sseq = stats.FirstSeq
+		} else if o.sseq > stats.LastSeq {
+			o.sseq = stats.LastSeq + 1
 		}
 	}
 
@@ -3296,8 +3298,7 @@ func (o *consumer) setInitialPendingAndStart() {
 	}
 
 	if !filtered && dp != DeliverLastPerSubject {
-		var state StreamState
-		mset.store.FastState(&state)
+		state := mset.store.State()
 		if state.Msgs > 0 {
 			o.sgap = state.Msgs - (o.sseq - state.FirstSeq)
 		}
diff --git a/server/errors.json b/server/errors.json
index 17160c6f..5a2e857c 100644
--- a/server/errors.json
+++ b/server/errors.json
@@ -1089,7 +1089,7 @@
     "url": "",
     "deprecates": ""
   },
-    {
+  {
     "constant": "JSStreamRollupFailedF",
     "code": 500,
     "error_code": 10111,
@@ -1098,5 +1098,15 @@
     "help": "",
     "url": "",
     "deprecates": ""
+  },
+  {
+    "constant": "JSConsumerInvalidDeliverSubject",
+    "code": 400,
+    "error_code": 10112,
+    "description": "invalid push consumer deliver subject",
+    "comment": "",
+    "help": "Returned when the delivery subject on a Push Consumer is not a valid NATS Subject",
+    "url": "",
+    "deprecates": ""
   }
 ]
diff --git a/server/filestore.go b/server/filestore.go
index 0a825367..dd6d795e 100644
--- a/server/filestore.go
+++ b/server/filestore.go
@@ -3367,19 +3367,13 @@ func (fs *fileStore) Type() StorageType {
 }
 
 // FastState will fill in state with only the following.
-// Msgs, Bytes, First and Last Sequence and Time and NumDeleted.
+// Msgs, Bytes, FirstSeq, LastSeq
 func (fs *fileStore) FastState(state *StreamState) {
 	fs.mu.RLock()
 	state.Msgs = fs.state.Msgs
 	state.Bytes = fs.state.Bytes
 	state.FirstSeq = fs.state.FirstSeq
-	state.FirstTime = fs.state.FirstTime
 	state.LastSeq = fs.state.LastSeq
-	state.LastTime = fs.state.LastTime
-	if state.LastSeq > state.FirstSeq {
-		state.NumDeleted = int((state.LastSeq - state.FirstSeq) - state.Msgs + 1)
-	}
-	state.Consumers = len(fs.cfs)
 	fs.mu.RUnlock()
 }
 
diff --git a/server/jetstream_cluster.go b/server/jetstream_cluster.go
index a510179d..5e3fd72c 100644
--- a/server/jetstream_cluster.go
+++ b/server/jetstream_cluster.go
@@ -4724,7 +4724,7 @@ func (mset *stream) calculateSyncRequest(state *StreamState, snap *streamSnapsho
 // processSnapshotDeletes will update our current store based on the snapshot
 // but only processing deletes and new FirstSeq / purges.
 func (mset *stream) processSnapshotDeletes(snap *streamSnapshot) {
-	state := mset.state()
+	state := mset.store.State()
 
 	// Adjust if FirstSeq has moved.
 	if snap.FirstSeq > state.FirstSeq {
diff --git a/server/jetstream_errors_generated.go b/server/jetstream_errors_generated.go
index 86cc1899..9eaf94a5 100644
--- a/server/jetstream_errors_generated.go
+++ b/server/jetstream_errors_generated.go
@@ -95,6 +95,9 @@ const (
 	// JSConsumerHBRequiresPushErr consumer idle heartbeat requires a push based consumer
 	JSConsumerHBRequiresPushErr ErrorIdentifier = 10088
 
+	// JSConsumerInvalidDeliverSubject invalid push consumer deliver subject
+	JSConsumerInvalidDeliverSubject ErrorIdentifier = 10112
+
 	// JSConsumerInvalidPolicyErrF Generic delivery policy error ({err})
 	JSConsumerInvalidPolicyErrF ErrorIdentifier = 10094
 
@@ -368,6 +371,7 @@ var (
 		JSConsumerFCRequiresPushErr:                {Code: 400, ErrCode: 10089, Description: "consumer flow control requires a push based consumer"},
 		JSConsumerFilterNotSubsetErr:               {Code: 400, ErrCode: 10093, Description: "consumer filter subject is not a valid subset of the interest subjects"},
 		JSConsumerHBRequiresPushErr:                {Code: 400, ErrCode: 10088, Description: "consumer idle heartbeat requires a push based consumer"},
+		JSConsumerInvalidDeliverSubject:            {Code: 400, ErrCode: 10112, Description: "invalid push consumer deliver subject"},
 		JSConsumerInvalidPolicyErrF:                {Code: 400, ErrCode: 10094, Description: "{err}"},
 		JSConsumerInvalidSamplingErrF:              {Code: 400, ErrCode: 10095, Description: "failed to parse consumer sampling configuration: {err}"},
 		JSConsumerMaxPendingAckPolicyRequiredErr:   {Code: 400, ErrCode: 10082, Description: "consumer requires ack policy for max ack pending"},
@@ -785,6 +789,16 @@ func NewJSConsumerHBRequiresPushError(opts ...ErrorOption) *ApiError {
 	return ApiErrors[JSConsumerHBRequiresPushErr]
 }
 
+// NewJSConsumerInvalidDeliverSubjectError creates a new JSConsumerInvalidDeliverSubject error: "invalid push consumer deliver subject"
+func NewJSConsumerInvalidDeliverSubjectError(opts ...ErrorOption) *ApiError {
+	eopts := parseOpts(opts)
+	if ae, ok := eopts.err.(*ApiError); ok {
+		return ae
+	}
+
+	return ApiErrors[JSConsumerInvalidDeliverSubject]
+}
+
 // NewJSConsumerInvalidPolicyError creates a new JSConsumerInvalidPolicyErrF error: "{err}"
 func NewJSConsumerInvalidPolicyError(err error, opts ...ErrorOption) *ApiError {
 	eopts := parseOpts(opts)
diff --git a/server/leafnode.go b/server/leafnode.go
index 9c198cc2..6bb3cecf 100644
--- a/server/leafnode.go
+++ b/server/leafnode.go
@@ -2527,15 +2527,7 @@ func (s *Server) leafNodeFinishConnectProcess(c *client) {
 	c.mu.Unlock()
 
 	// Make sure we register with the account here.
-	if err := c.registerWithAccount(acc); err != nil {
-		if err == ErrTooManyAccountConnections {
-			c.maxAccountConnExceeded()
-			return
-		}
-		c.Errorf("Registering leaf with account %s resulted in error: %v", acc.Name, err)
-		c.closeConnection(ProtocolViolation)
-		return
-	}
+	c.registerWithAccount(acc)
 	s.addLeafNodeConnection(c, _EMPTY_, _EMPTY_, false)
 	s.initLeafNodeSmapAndSendSubs(c)
 	if sendSysConnectEvent {
diff --git a/server/memstore.go b/server/memstore.go
index a35bd1d9..7f7f4709 100644
--- a/server/memstore.go
+++ b/server/memstore.go
@@ -737,19 +737,13 @@ func (ms *memStore) Type() StorageType {
 }
 
 // FastState will fill in state with only the following.
-// Msgs, Bytes, First and Last Sequence and Time and NumDeleted.
+// Msgs, Bytes, FirstSeq, LastSeq
 func (ms *memStore) FastState(state *StreamState) {
 	ms.mu.RLock()
 	state.Msgs = ms.state.Msgs
 	state.Bytes = ms.state.Bytes
 	state.FirstSeq = ms.state.FirstSeq
-	state.FirstTime = ms.state.FirstTime
 	state.LastSeq = ms.state.LastSeq
-	state.LastTime = ms.state.LastTime
-	if state.LastSeq > state.FirstSeq {
-		state.NumDeleted = int((state.LastSeq - state.FirstSeq) - state.Msgs + 1)
-	}
-	state.Consumers = ms.consumers
 	ms.mu.RUnlock()
 }
 
diff --git a/server/server.go b/server/server.go
index 54ad808c..51df6842 100644
--- a/server/server.go
+++ b/server/server.go
@@ -23,7 +23,6 @@ import (
 	"fmt"
 	"io"
 	"io/ioutil"
-	"log"
 	"math/rand"
 	"net"
 	"net/http"
@@ -2156,36 +2155,6 @@ func (s *Server) basePath(p string) string {
 	return path.Join(s.httpBasePath, p)
 }
 
-type captureHTTPServerLog struct {
-	s      *Server
-	prefix string
-}
-
-func (cl *captureHTTPServerLog) Write(p []byte) (int, error) {
-	var buf [128]byte
-	var b = buf[:0]
-
-	b = append(b, []byte(cl.prefix)...)
-	offset := 0
-	if bytes.HasPrefix(p, []byte("http:")) {
-		offset = 6
-	}
-	b = append(b, p[offset:]...)
-	cl.s.Errorf(string(b))
-	return len(p), nil
-}
-
-// The TLS configuration is passed to the listener when the monitoring
-// "server" is setup. That prevents TLS configuration updates on reload
-// from being used. By setting this function in tls.Config.GetConfigForClient
-// we instruct the TLS handshake to ask for the tls configuration to be
-// used for a specific client. We don't care which client, we always use
-// the same TLS configuration.
-func (s *Server) getTLSConfig(_ *tls.ClientHelloInfo) (*tls.Config, error) {
-	opts := s.getOpts()
-	return opts.TLSConfig, nil
-}
-
 // Start the monitoring server
 func (s *Server) startMonitoring(secure bool) error {
 	// Snapshot server options.
@@ -2208,7 +2177,6 @@ func (s *Server) startMonitoring(secure bool) error {
 		}
 		hp = net.JoinHostPort(opts.HTTPHost, strconv.Itoa(port))
 		config := opts.TLSConfig.Clone()
-		config.GetConfigForClient = s.getTLSConfig
 		config.ClientAuth = tls.NoClientCert
 		httpListener, err = tls.Listen("tcp", hp, config)
 
@@ -2259,7 +2227,6 @@ func (s *Server) startMonitoring(secure bool) error {
 		Addr:           hp,
 		Handler:        mux,
 		MaxHeaderBytes: 1 << 20,
-		ErrorLog:       log.New(&captureHTTPServerLog{s, "monitoring: "}, _EMPTY_, 0),
 	}
 	s.mu.Lock()
 	if s.shutdown {
diff --git a/server/stream.go b/server/stream.go
index 1513c2ff..9bd47f18 100644
--- a/server/stream.go
+++ b/server/stream.go
@@ -425,8 +425,7 @@ func (a *Account) addStreamWithAssignment(config *StreamConfig, fsConfig *FileSt
 	mset.pubAck = mset.pubAck[:end:end]
 
 	// Set our known last sequence.
-	var state StreamState
-	mset.store.FastState(&state)
+	state := mset.store.State()
 	mset.lseq = state.LastSeq
 
 	// If no msgs (new stream), set dedupe state loaded to true.
@@ -883,6 +882,10 @@ func checkStreamCfg(config *StreamConfig) (StreamConfig, error) {
 				return StreamConfig{}, fmt.Errorf("subjects overlap with jetstream api")
 			}
 
+			if !IsValidSubject(subj) {
+				return StreamConfig{}, fmt.Errorf("invalid subject")
+			}
+
 			dset[subj] = struct{}{}
 		}
 	}
@@ -1787,9 +1790,6 @@ func (mset *stream) setSourceConsumer(iname string, seq uint64) {
 	si.sseq, si.dseq = seq, 0
 	si.last = time.Now()
 	ssi := mset.streamSource(iname)
-	if ssi == nil {
-		return
-	}
 
 	// Determine subjects etc.
 	var deliverSubject string
@@ -3506,6 +3506,11 @@ func (mset *stream) lookupConsumer(name string) *consumer {
 	return mset.consumers[name]
 }
 
+// State will return the current state for this stream.
+func (mset *stream) state() StreamState {
+	return mset.stateWithDetail(false)
+}
+
 func (mset *stream) numDirectConsumers() (num int) {
 	mset.mu.RLock()
 	defer mset.mu.RUnlock()
@@ -3521,11 +3526,6 @@ func (mset *stream) numDirectConsumers() (num int) {
 	return num
 }
 
-// State will return the current state for this stream.
-func (mset *stream) state() StreamState {
-	return mset.stateWithDetail(false)
-}
-
 func (mset *stream) stateWithDetail(details bool) StreamState {
 	mset.mu.RLock()
 	c, store := mset.client, mset.store
@@ -3534,12 +3534,10 @@ func (mset *stream) stateWithDetail(details bool) StreamState {
 		return StreamState{}
 	}
 	// Currently rely on store.
-	if details {
-		return store.State()
+	state := store.State()
+	if !details {
+		state.Deleted = nil
 	}
-	// Here we do the fast version.
-	var state StreamState
-	mset.store.FastState(&state)
 	return state
 }
 
diff --git a/server/websocket.go b/server/websocket.go
index 3dbcd554..b16edf0a 100644
--- a/server/websocket.go
+++ b/server/websocket.go
@@ -1112,7 +1112,7 @@ func (s *Server) startWebsocketServer() {
 		Addr:        hp,
 		Handler:     mux,
 		ReadTimeout: o.HandshakeTimeout,
-		ErrorLog:    log.New(&captureHTTPServerLog{s, "websocket: "}, _EMPTY_, 0),
+		ErrorLog:    log.New(&wsCaptureHTTPServerLog{s}, _EMPTY_, 0),
 	}
 	s.websocket.server = hs
 	s.websocket.listener = hl
@@ -1239,6 +1239,24 @@ func (s *Server) createWSClient(conn net.Conn, ws *websocket) *client {
 	return c
 }
 
+type wsCaptureHTTPServerLog struct {
+	s *Server
+}
+
+func (cl *wsCaptureHTTPServerLog) Write(p []byte) (int, error) {
+	var buf [128]byte
+	var b = buf[:0]
+
+	copy(b, []byte("websocket :"))
+	offset := 0
+	if bytes.HasPrefix(p, []byte("http:")) {
+		offset = 6
+	}
+	b = append(b, p[offset:]...)
+	cl.s.Errorf(string(b))
+	return len(p), nil
+}
+
 func (c *client) wsCollapsePtoNB() (net.Buffers, int64) {
 	var nb net.Buffers
 	var mfs int


Test patch:
diff --git a/server/events_test.go b/server/events_test.go
index ff0855bd..384d284e 100644
--- a/server/events_test.go
+++ b/server/events_test.go
@@ -2257,7 +2257,7 @@ func TestServerEventsFilteredByTag(t *testing.T) {
 			listen: -1
 			no_advertise: true
 			routes [
-				nats-route://127.0.0.1:%d
+				nats-route://localhost:%d
 			]
 		}
 		system_account: SYS
diff --git a/server/jetstream_cluster_test.go b/server/jetstream_cluster_test.go
index d945d29f..2777aeb1 100644
--- a/server/jetstream_cluster_test.go
+++ b/server/jetstream_cluster_test.go
@@ -8732,7 +8732,7 @@ func TestJetStreamClusterMirrorAndSourceCrossNonNeighboringDomain(t *testing.T)
 		system_account = SYS
 		no_auth_user: a1
 		leafnodes: {
-			listen: 127.0.0.1:-1
+			listen: localhost:-1
 		}
 	`, storeDir1)))
 	s1, _ := RunServerWithConfig(conf1)
@@ -8748,8 +8748,8 @@ func TestJetStreamClusterMirrorAndSourceCrossNonNeighboringDomain(t *testing.T)
 		system_account = SYS
 		no_auth_user: a1
 		leafnodes:{
-			remotes:[{ url:nats://a1:a1@127.0.0.1:%d, account: A},
-					 { url:nats://s1:s1@127.0.0.1:%d, account: SYS}]
+			remotes:[{ url:nats://a1:a1@localhost:%d, account: A},
+					 { url:nats://s1:s1@localhost:%d, account: SYS}]
 		}
 	`, storeDir2, s1.opts.LeafNode.Port, s1.opts.LeafNode.Port)))
 	s2, _ := RunServerWithConfig(conf2)
@@ -8765,8 +8765,8 @@ func TestJetStreamClusterMirrorAndSourceCrossNonNeighboringDomain(t *testing.T)
 		system_account = SYS
 		no_auth_user: a1
 		leafnodes:{
-			remotes:[{ url:nats://a1:a1@127.0.0.1:%d, account: A},
-					 { url:nats://s1:s1@127.0.0.1:%d, account: SYS}]
+			remotes:[{ url:nats://a1:a1@localhost:%d, account: A},
+					 { url:nats://s1:s1@localhost:%d, account: SYS}]
 		}
 	`, storeDir3, s1.opts.LeafNode.Port, s1.opts.LeafNode.Port)))
 	s3, _ := RunServerWithConfig(conf3)
diff --git a/server/jetstream_test.go b/server/jetstream_test.go
index c460ed71..43427cba 100644
--- a/server/jetstream_test.go
+++ b/server/jetstream_test.go
@@ -920,16 +920,16 @@ func TestJetStreamAddStreamBadSubjects(t *testing.T) {
 		if err := json.Unmarshal(resp.Data, &scResp); err != nil {
 			t.Fatalf("Unexpected error: %v", err)
 		}
-		e := scResp.Error
-		if e == nil || e.Code != 500 || e.Description != ErrMalformedSubject.Error() {
-			t.Fatalf("Did not get proper error response: %+v", e)
-		}
+
+		require_Error(t, scResp.ToError(), NewJSStreamInvalidConfigError(fmt.Errorf("invalid subject")))
 	}
 
 	expectAPIErr(StreamConfig{Name: "MyStream", Storage: MemoryStorage, Subjects: []string{"foo.bar."}})
 	expectAPIErr(StreamConfig{Name: "MyStream", Storage: MemoryStorage, Subjects: []string{".."}})
 	expectAPIErr(StreamConfig{Name: "MyStream", Storage: MemoryStorage, Subjects: []string{".*"}})
 	expectAPIErr(StreamConfig{Name: "MyStream", Storage: MemoryStorage, Subjects: []string{".>"}})
+	expectAPIErr(StreamConfig{Name: "MyStream", Storage: MemoryStorage, Subjects: []string{" x"}})
+	expectAPIErr(StreamConfig{Name: "MyStream", Storage: MemoryStorage, Subjects: []string{"y "}})
 }
 
 func TestJetStreamMaxConsumers(t *testing.T) {
@@ -13591,6 +13591,27 @@ func TestJetStreamMessagePerSubjectKeepBug(t *testing.T) {
 	})
 }
 
+func TestJetStreamInvalidDeliverSubject(t *testing.T) {
+	s := RunBasicJetStreamServer()
+	defer s.Shutdown()
+
+	config := s.JetStreamConfig()
+	if config != nil {
+		defer removeDir(t, config.StoreDir)
+	}
+
+	nc, js := jsClientConnect(t, s)
+	defer nc.Close()
+
+	_, err := js.AddStream(&nats.StreamConfig{
+		Name: "TEST",
+	})
+	require_NoError(t, err)
+
+	_, err = js.AddConsumer("TEST", &nats.ConsumerConfig{DeliverSubject: " x"})
+	require_Error(t, err, NewJSConsumerInvalidDeliverSubjectError())
+}
+
 ///////////////////////////////////////////////////////////////////////////
 // Simple JetStream Benchmarks
 ///////////////////////////////////////////////////////////////////////////
diff --git a/server/leafnode_test.go b/server/leafnode_test.go
index e7327699..feb6dc5d 100644
--- a/server/leafnode_test.go
+++ b/server/leafnode_test.go
@@ -3911,9 +3911,9 @@ resolver_preload: {
   %s: %s
   %s: %s
 }
-listen: 127.0.0.1:-1
+listen: localhost:-1
 leafnodes: {
-	listen: 127.0.0.1:-1
+	listen: localhost:-1
 }
 jetstream :{
     domain: "cluster"
@@ -3924,7 +3924,7 @@ jetstream :{
 `
 
 	tmplL := `
-listen: 127.0.0.1:-1
+listen: localhost:-1
 accounts :{
     A:{   jetstream: enable, users:[ {user:a1,password:a1}]},
     SYS:{ users:[ {user:s1,password:s1}]},
@@ -3937,8 +3937,8 @@ jetstream: {
     max_file: 50Mb
 }
 leafnodes:{
-    remotes:[{ url:nats://127.0.0.1:%d, account: A, credentials: %s},
-			 { url:nats://127.0.0.1:%d, account: SYS, credentials: %s}]
+    remotes:[{ url:nats://localhost:%d, account: A, credentials: %s},
+			 { url:nats://localhost:%d, account: SYS, credentials: %s}]
 }
 `
 
@@ -3961,7 +3961,7 @@ leafnodes:{
 	ncA := natsConnect(t, sA.ClientURL(), nats.UserCredentials(unlimitedCreds))
 	defer ncA.Close()
 
-	ncL := natsConnect(t, fmt.Sprintf("nats://a1:a1@127.0.0.1:%d", sL.opts.Port))
+	ncL := natsConnect(t, fmt.Sprintf("nats://a1:a1@localhost:%d", sL.opts.Port))
 	defer ncL.Close()
 
 	test := func(subject string, cSub, cPub *nats.Conn, remoteServerForSub *Server, accName string, pass bool) {
diff --git a/server/monitor_test.go b/server/monitor_test.go
index 9b0fb508..ac63eeca 100644
--- a/server/monitor_test.go
+++ b/server/monitor_test.go
@@ -4310,58 +4310,3 @@ func TestMonitorJszAccountReserves(t *testing.T) {
 	reloadUpdateConfig(t, s, conf, fmt.Sprintf(tmplCfg, tmpDir, "jetstream: enabled"))
 	test(4, 0, 0, false)
 }
-
-func TestMonitorReloadTLSConfig(t *testing.T) {
-	template := `
-		listen: "127.0.0.1:-1"
-		https: "127.0.0.1:-1"
-		tls {
-			cert_file: '%s'
-			key_file: '%s'
-			ca_file: '../test/configs/certs/ca.pem'
-		}
-	`
-	conf := createConfFile(t, []byte(fmt.Sprintf(template,
-		"../test/configs/certs/server-noip.pem",
-		"../test/configs/certs/server-key-noip.pem")))
-	defer removeFile(t, conf)
-
-	s, _ := RunServerWithConfig(conf)
-	defer s.Shutdown()
-
-	addr := fmt.Sprintf("127.0.0.1:%d", s.MonitorAddr().Port)
-	c, err := net.Dial("tcp", addr)
-	if err != nil {
-		t.Fatalf("Error creating ws connection: %v", err)
-	}
-	defer c.Close()
-
-	tc := &TLSConfigOpts{CaFile: "../test/configs/certs/ca.pem"}
-	tlsConfig, err := GenTLSConfig(tc)
-	if err != nil {
-		t.Fatalf("Error generating TLS config: %v", err)
-	}
-	tlsConfig.ServerName = "127.0.0.1"
-	tlsConfig.RootCAs = tlsConfig.ClientCAs
-	tlsConfig.ClientCAs = nil
-	c = tls.Client(c, tlsConfig.Clone())
-	if err := c.(*tls.Conn).Handshake(); err == nil || !strings.Contains(err.Error(), "SAN") {
-		t.Fatalf("Unexpected error: %v", err)
-	}
-	c.Close()
-
-	reloadUpdateConfig(t, s, conf, fmt.Sprintf(template,
-		"../test/configs/certs/server-cert.pem",
-		"../test/configs/certs/server-key.pem"))
-
-	c, err = net.Dial("tcp", addr)
-	if err != nil {
-		t.Fatalf("Error creating ws connection: %v", err)
-	}
-	defer c.Close()
-
-	c = tls.Client(c, tlsConfig.Clone())
-	if err := c.(*tls.Conn).Handshake(); err != nil {
-		t.Fatalf("Error on TLS handshake: %v", err)
-	}
-}
diff --git a/server/websocket_test.go b/server/websocket_test.go
index 82eeebb1..8c0c2d04 100644
--- a/server/websocket_test.go
+++ b/server/websocket_test.go
@@ -2366,10 +2366,6 @@ func TestWSHandshakeTimeout(t *testing.T) {
 	// Check that server logs error
 	select {
 	case e := <-logger.errCh:
-		// Check that log starts with "websocket: "
-		if !strings.HasPrefix(e, "websocket: ") {
-			t.Fatalf("Wrong log line start: %s", e)
-		}
 		if !strings.Contains(e, "timeout") {
 			t.Fatalf("Unexpected error: %v", e)
 		}