45 lines
1.6 KiB
Go
45 lines
1.6 KiB
Go
package dto
|
|
|
|
import (
|
|
"encoding/json"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestGameClientBridgeCompanionDeclarationRoundTripsWithoutMaterial(t *testing.T) {
|
|
body := GameClientBridgeManifestBody{
|
|
CommandRetentionSeconds: 86400,
|
|
MaxCommands: 1000,
|
|
Companion: &GameClientBridgeCompanionDeclarationBody{
|
|
ProfileKey: "scum-client-manager",
|
|
ConfigTemplateKey: "client-config",
|
|
ConfigSchemaRef: "schemas/companion/config.schema.json",
|
|
ConfigFormat: "yaml",
|
|
PlatformBaseURLSource: "run-control",
|
|
RegistrationProof: "hmac-sha256",
|
|
ProofMaterialSource: "component-package",
|
|
ProofMaterialEnv: "SCUM_COMPONENT_PROOF",
|
|
SessionMode: "component-session",
|
|
TLSPolicy: "verify-system-roots",
|
|
HeartbeatIntervalSeconds: 30,
|
|
CommandPollIntervalSeconds: 5,
|
|
RequestTimeoutSeconds: 15,
|
|
},
|
|
}
|
|
domainValue := body.ToDomain()
|
|
if domainValue.Companion.ProfileKey != "scum-client-manager" || domainValue.Companion.TLSPolicy != "verify-system-roots" {
|
|
t.Fatalf("companion declaration conversion lost fields: %+v", domainValue.Companion)
|
|
}
|
|
projection := gameClientBridgeManifestFromDomain(domainValue)
|
|
encoded, err := json.Marshal(projection)
|
|
if err != nil {
|
|
t.Fatalf("marshal companion declaration: %v", err)
|
|
}
|
|
serialized := string(encoded)
|
|
for _, forbidden := range []string{"authKey", "componentKey", "sessionToken", "credential", "secretRef", "hostPath", "runSocket"} {
|
|
if strings.Contains(serialized, forbidden) {
|
|
t.Fatalf("companion declaration exposed %q: %s", forbidden, serialized)
|
|
}
|
|
}
|
|
}
|