feat: build vehicle data platform and production pipeline

This commit is contained in:
lingniu
2026-07-14 12:35:33 +08:00
parent b452be3b94
commit bb59303a4b
270 changed files with 88016 additions and 1975 deletions

View File

@@ -416,6 +416,32 @@ func TestAutoResponderBuildsVersionedGeneralAck(t *testing.T) {
}
}
func TestAutoResponderRejectsEnforcedInvalidAuthentication(t *testing.T) {
request := buildFrame(0x0102, "064646848757", 13, []byte("wrong-code"))
env, err := ParseFrame(request, 1782918600000, "127.0.0.1:808")
if err != nil {
t.Fatal(err)
}
env.AuthenticationEnforced = true
env.AuthenticationStatus = "rejected"
response, ok, err := NewAutoResponder("issued-code").Respond(request, env)
if err != nil || !ok {
t.Fatalf("Respond() ok=%v err=%v", ok, err)
}
frames, remainder, err := ExtractFrames(response)
if err != nil || len(frames) != 1 || len(remainder) != 0 {
t.Fatalf("ExtractFrames() frames=%d remainder=%x err=%v", len(frames), remainder, err)
}
payload := frames[0]
if got := binary.BigEndian.Uint16(payload[0:2]); got != msgPlatformGeneralResponse {
t.Fatalf("message id = 0x%04x", got)
}
if result := payload[len(payload)-2]; result != 1 {
t.Fatalf("authentication response result = %d, want 1", result)
}
}
func TestExtractFramesHandlesEscapedPayload(t *testing.T) {
payload := []byte{0x02, 0x00, 0x00, 0x02, 0x01, 0x33, 0x07, 0x79, 0x54, 0x25, 0x00, 0x01, 0x7e, 0x7d}
frame := append([]byte{0x7e}, escape(append(payload, checksum(payload)))...)

View File

@@ -49,6 +49,9 @@ func (r AutoResponder) Respond(raw []byte, env envelope.FrameEnvelope) ([]byte,
binary.BigEndian.PutUint16(body[0:2], header.sequence)
binary.BigEndian.PutUint16(body[2:4], header.messageID)
body[4] = 0
if header.messageID == 0x0102 && env.AuthenticationEnforced && env.AuthenticationStatus != "accepted" {
body[4] = 1
}
return encodeResponse(msgPlatformGeneralResponse, header, body), true, nil
}