mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-02 03:38:42 -07:00
Don't erase nonce on reload
Signed-off-by: Derek Collison <derek@nats.io>
This commit is contained in:
@@ -1041,7 +1041,7 @@ func TestServerEventStatsZ(t *testing.T) {
|
||||
if m.Stats.ActiveAccounts != 2 {
|
||||
t.Fatalf("Did not match active accounts of 2, got %d", m.Stats.ActiveAccounts)
|
||||
}
|
||||
if m.Stats.Sent.Msgs != 2 {
|
||||
if m.Stats.Sent.Msgs != 1 {
|
||||
t.Fatalf("Did not match sent msgs of 1, got %d", m.Stats.Sent.Msgs)
|
||||
}
|
||||
if m.Stats.Received.Msgs != 1 {
|
||||
|
||||
@@ -23,13 +23,17 @@ const (
|
||||
nonceLen = 15 // base64.RawURLEncoding.EncodedLen(nonceRawLen)
|
||||
)
|
||||
|
||||
// nonceRequired tells us if we should send a nonce.
|
||||
// Assumes server lock is held
|
||||
func (s *Server) nonceRequired() bool {
|
||||
s.optsMu.RLock()
|
||||
defer s.optsMu.RUnlock()
|
||||
// NonceRequired tells us if we should send a nonce.
|
||||
func (s *Server) NonceRequired() bool {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
return s.nonceRequired()
|
||||
}
|
||||
|
||||
return len(s.opts.Nkeys) > 0 || len(s.opts.TrustedKeys) > 0
|
||||
// nonceRequired tells us if we should send a nonce.
|
||||
// Lock should be held on entry.
|
||||
func (s *Server) nonceRequired() bool {
|
||||
return len(s.nkeys) > 0 || len(s.trustedKeys) > 0
|
||||
}
|
||||
|
||||
// Generate a nonce for INFO challenge.
|
||||
|
||||
@@ -240,6 +240,7 @@ func TestOperatorSigningKeys(t *testing.T) {
|
||||
|
||||
func TestOperatorMemResolverPreload(t *testing.T) {
|
||||
s, opts := RunServerWithConfig("./configs/resolver_preload.conf")
|
||||
defer s.Shutdown()
|
||||
|
||||
// Make sure we can look up the account.
|
||||
acc, _ := s.LookupAccount("ADM2CIIL3RWXBA6T2HW3FODNCQQOUJEHHQD6FKCPVAMHDNTTSMO73ROX")
|
||||
@@ -254,3 +255,20 @@ func TestOperatorMemResolverPreload(t *testing.T) {
|
||||
t.Fatalf("System account does not match, wanted %q, got %q", opts.SystemAccount, sacc.Name)
|
||||
}
|
||||
}
|
||||
|
||||
func TestOperatorConfigReloadDoesntKillNonce(t *testing.T) {
|
||||
s, _ := runOperatorServer(t)
|
||||
defer s.Shutdown()
|
||||
|
||||
if !s.NonceRequired() {
|
||||
t.Fatalf("Error nonce should be required")
|
||||
}
|
||||
|
||||
if err := s.Reload(); err != nil {
|
||||
t.Fatalf("Error on reload: %v", err)
|
||||
}
|
||||
|
||||
if !s.NonceRequired() {
|
||||
t.Fatalf("Error nonce should still be required after reload")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user