feat: shard group messages by month
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/tinode/chat/server/store"
|
||||
@@ -18,6 +19,20 @@ func (internalAdminQueryNotFound) Query(types.TenantID, string, string, []any, i
|
||||
return nil, types.ErrNotFound
|
||||
}
|
||||
|
||||
func TestClaimInternalNonceRejectsReplay(t *testing.T) {
|
||||
oldConfig := internalAPI.config
|
||||
internalAPI = internalAPIRuntime{config: oldConfig}
|
||||
defer func() { internalAPI = internalAPIRuntime{config: oldConfig} }()
|
||||
|
||||
expiresAt := time.Now().Add(time.Minute)
|
||||
if !claimInternalNonce("manager-test", "single-use-nonce", "request-claim", expiresAt) {
|
||||
t.Fatal("first nonce claim was rejected")
|
||||
}
|
||||
if claimInternalNonce("manager-test", "single-use-nonce", "request-claim", expiresAt) {
|
||||
t.Fatal("replayed nonce was accepted")
|
||||
}
|
||||
}
|
||||
|
||||
func (internalAdminQueryNotFound) QueryOne(types.TenantID, string, []any) (map[string]any, error) {
|
||||
return nil, types.ErrNotFound
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user