mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-11-21 15:09:21 +00:00
fix: 过滤入口拒绝日志并强化鉴权边界
This commit is contained in:
1 parent
57914967cb
commit
b92bbf0299
101 files changed
+5872
-828
No files matched your search
@@ -5,11 +5,32 @@ package repository
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestMigrationsRunner_ConcurrentInstancesSerializeOnSessionLock(t *testing.T) {
|
||||
const instances = 2
|
||||
errorsByInstance := make([]error, instances)
|
||||
var wg sync.WaitGroup
|
||||
for i := 0; i < instances; i++ {
|
||||
wg.Add(1)
|
||||
go func(index int) {
|
||||
defer wg.Done()
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
defer cancel()
|
||||
errorsByInstance[index] = ApplyMigrations(ctx, integrationDB)
|
||||
}(i)
|
||||
}
|
||||
wg.Wait()
|
||||
for i, err := range errorsByInstance {
|
||||
require.NoErrorf(t, err, "migration instance %d", i)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMigrationsRunner_IsIdempotent_AndSchemaIsUpToDate(t *testing.T) {
|
||||
tx := testTx(t)
|
||||
|
||||
@@ -111,6 +132,13 @@ func TestMigrationsRunner_IsIdempotent_AndSchemaIsUpToDate(t *testing.T) {
|
||||
requireColumn(t, tx, "ops_system_logs", "api_key_id", "bigint", 0, true)
|
||||
requireIndex(t, tx, "ops_system_logs", "idx_ops_system_logs_api_key_id_created_at")
|
||||
|
||||
// Bounded ingress rejection security aggregates.
|
||||
requireColumn(t, tx, "ops_ingress_reject_aggregates", "bucket_start", "timestamp with time zone", 0, false)
|
||||
requireColumn(t, tx, "ops_ingress_reject_aggregates", "client_ip", "inet", 0, false)
|
||||
requireColumn(t, tx, "ops_ingress_reject_aggregates", "request_count", "bigint", 0, false)
|
||||
requireIndex(t, tx, "ops_ingress_reject_aggregates", "idx_ops_ingress_reject_aggregates_bucket")
|
||||
requireIndex(t, tx, "ops_ingress_reject_aggregates", "idx_ops_ingress_reject_aggregates_ip_bucket")
|
||||
|
||||
// user_allowed_groups table should exist
|
||||
var uagRegclass sql.NullString
|
||||
require.NoError(t, tx.QueryRowContext(context.Background(), "SELECT to_regclass('public.user_allowed_groups')").Scan(&uagRegclass))
|
||||
|
||||
Reference in new issue
Block a user