mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-06-28 00:24:19 +00:00
fa1a19c03c
Add .golangci.yml (v2): the standard linters plus bodyclose, errorlint, noctx, misspell, rowserrcheck, sqlclosecheck, unconvert, usestdlibvars, with gofumpt + goimports formatters. Enable the std-error-handling exclusion preset for idiomatic Close/Remove/Setenv ignores; scope-exclude SA1019 (parser.ParseDir in tools/openapigen) and ST1005 (intentional capitalized user-facing error copy that tests assert verbatim). No inline nolint directives were introduced. Resolve all 217 findings behavior-preserving: gofumpt/goimports formatting, explicit blank assignment on intentionally ignored errors, errors.Is/errors.As and %w wrapping, context-aware stdlib calls (CommandContext/QueryContext/NewRequestWithContext/Dialer), staticcheck simplifications, removed redundant conversions, http.StatusOK and http.MethodGet, inlined the go:fix intPtr helper, and deferred sql rows Close. Add a golangci CI job mirroring the existing Go jobs.
36 lines
1.2 KiB
Go
36 lines
1.2 KiB
Go
package service
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/google/uuid"
|
|
|
|
"github.com/mhsanaei/3x-ui/v3/internal/database/model"
|
|
)
|
|
|
|
// Deleting a client that is attached to more than one inbound must still remove
|
|
// the user from the running runtime of the inbound being deleted from. The
|
|
// runtime user is keyed by inbound tag, so a sibling inbound still carrying the
|
|
// same email (emailShared) must not suppress the per-inbound runtime removal —
|
|
// otherwise the deleted user keeps connecting on that inbound until Xray
|
|
// restart (#5543).
|
|
func TestDelInboundClientByEmail_SharedEmailStillRemovesFromRuntime(t *testing.T) {
|
|
setupBulkDB(t)
|
|
nodeID, fake := setupNodeRuntime(t)
|
|
|
|
shared := []model.Client{{ID: uuid.NewString(), Email: "shared@x", Enable: true}}
|
|
ibA := nodeInbound(t, nodeID, 31001, shared)
|
|
nodeInbound(t, nodeID, 31002, shared)
|
|
|
|
svc := &ClientService{}
|
|
inboundSvc := &InboundService{}
|
|
|
|
if _, err := svc.DelInboundClientByEmail(inboundSvc, ibA.Id, "shared@x", false); err != nil {
|
|
t.Fatalf("DelInboundClientByEmail: %v", err)
|
|
}
|
|
|
|
if got := fake.deleteUser.Load(); got != 1 {
|
|
t.Fatalf("shared-email delete dispatched %d DeleteUser RPCs, want 1 (must remove from the deleted inbound's runtime despite the sibling inbound) (#5543)", got)
|
|
}
|
|
}
|