mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-10-12 17:05:01 +03:00
a8255944bf
The MASQUE and XDRIVE commits left four comment blocks over the two-line cap CLAUDE.md sets for committed Go/TS.
43 lines
1.3 KiB
Go
43 lines
1.3 KiB
Go
package xray
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/xtls/xray-core/proxy/masque"
|
|
)
|
|
|
|
// Panel paths hand AddUser the client's "password", the hot diff the emitted user's
|
|
// "pass"; without an account the core adds a MASQUE user it can never authenticate.
|
|
func TestBuildUserAccountMasque(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
user map[string]any
|
|
}{
|
|
{"panel client", map[string]any{"email": "ivy@example.test", "password": "pw-ivy"}},
|
|
{"emitted core user", map[string]any{"email": "ivy@example.test", "pass": "pw-ivy"}},
|
|
}
|
|
for _, tc := range tests {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
typed, err := buildUserAccount("masque", tc.user)
|
|
if err != nil {
|
|
t.Fatalf("buildUserAccount: %v", err)
|
|
}
|
|
if typed == nil {
|
|
t.Fatal("buildUserAccount returned no account")
|
|
}
|
|
instance, err := typed.GetInstance()
|
|
if err != nil {
|
|
t.Fatalf("GetInstance: %v", err)
|
|
}
|
|
account, ok := instance.(*masque.Account)
|
|
if !ok || account.Password != "pw-ivy" {
|
|
t.Fatalf("account = %#v, want a masque.Account with password pw-ivy", instance)
|
|
}
|
|
})
|
|
}
|
|
|
|
if _, err := buildUserAccount("masque", map[string]any{"email": "ivy@example.test"}); err == nil {
|
|
t.Fatal("a MASQUE user without a password must be refused, not added unauthenticatable")
|
|
}
|
|
}
|