package grpc import ( "testing" gamedomain "hyapp/services/game-service/internal/domain/game" ) func TestPlatformToProtoExposesCallbackSecretForAdmin(t *testing.T) { const secret = "leadercc-admin-visible-key" got := platformToProto(gamedomain.Platform{ PlatformCode: "lingxian", CallbackSecretCiphertext: secret, CallbackSecretConfigured: true, }) if got.GetCallbackSecret() != secret { t.Fatalf("callback_secret = %q, want %q", got.GetCallbackSecret(), secret) } if !got.GetCallbackSecretSet() { t.Fatal("callback_secret_set = false, want true") } } func TestNormalizePlatformAcceptsVivaGamesAdapter(t *testing.T) { // 平台创建入口会先规范化 adapter_type;新增厂商必须在这里放行,否则后台配置页会被 gRPC 直接拒绝。 got, err := normalizePlatform(gamedomain.Platform{ PlatformCode: "vivagames", PlatformName: "VIVAGAMES", Status: gamedomain.StatusActive, AdapterType: gamedomain.AdapterVivaGamesV1, AdapterConfigJSON: "{}", }) if err != nil { t.Fatalf("normalizePlatform() error = %v", err) } if got.AdapterType != gamedomain.AdapterVivaGamesV1 { t.Fatalf("adapter_type = %q, want %q", got.AdapterType, gamedomain.AdapterVivaGamesV1) } } func TestNormalizePlatformRejectsDemoAdapter(t *testing.T) { for _, adapterType := range []string{"", gamedomain.AdapterDemo} { _, err := normalizePlatform(gamedomain.Platform{ PlatformCode: "demo", PlatformName: "Demo", Status: gamedomain.StatusActive, AdapterType: adapterType, AdapterConfigJSON: "{}", }) if err == nil { t.Fatalf("normalizePlatform(adapterType=%q) expected error", adapterType) } } }